Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.PHONY: test
test:
emacs --batch -L . -l unity-launcher-api-tests -f ert-run-tests-batch
emacs --batch -L . -l dock-tests -f ert-run-tests-batch
14 changes: 7 additions & 7 deletions unity-launcher-api-tests.el → dock-tests.el
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
;;; unity-launcher-api-tests.el --- Tests for Unity Launcher API -*- lexical-binding: t; -*-
;;; dock-tests.el --- Tests for Unity Launcher API -*- lexical-binding: t; -*-
;;
;; Copyright (C) 2025 Aleksei Gusev
;;
;; Author: Aleksei Gusev <aleksei.gusev@gmail.com>
;; Maintainer: Aleksei Gusev <aleksei.gusev@gmail.com>
;; Created: July 16, 2025
;; Version: 0.0.1
;; Homepage: https://github.com/hron/unity-launcher-api.el
;; Homepage: https://github.com/hron/dock.el
;; Package-Requires: ((emacs "28.1"))
;;
;; This file is not part of GNU Emacs.
Expand All @@ -17,14 +17,14 @@
;;
;;; Code:

(require 'unity-launcher-api)
(require 'dock)
(require 'ert)

(ert-deftest unity-launcher-api-tests-build-dbus-args ()
(ert-deftest dock-tests-build-dbus-args ()
(should
(equal (unity-launcher-api--build-dbus-args '((urgent . t) (count . 42)))
(equal (dock--build-dbus-args '((urgent . t) (count . 42)))
`((:dict-entry "urgent" (:variant :boolean t))
(:dict-entry "count" (:variant :uint32 42))))))

(provide 'unity-launcher-api-tests)
;;; unity-launcher-api-tests.el ends here
(provide 'dock-tests)
;;; dock-tests.el ends here
46 changes: 30 additions & 16 deletions unity-launcher-api.el → dock.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; unity-launcher-api.el --- Unity Launcher API -*- lexical-binding: t; -*-
;;; dock.el --- Unity Launcher API -*- lexical-binding: t; -*-
;;
;; Copyright (C) 2025 Aleksei Gusev
;;
Expand All @@ -7,27 +7,41 @@
;; Created: July 16, 2025
;; Version: 0.0.1
;; Keywords: lisp
;; Homepage: https://github.com/hron/unity-launcher-api.el
;; Homepage: https://github.com/hron/dock.el
;; Package-Requires: ((emacs "28.1"))
;;
;; This file is not part of GNU Emacs.
;;
;;; Commentary:
;;
;; Control taskbar entry of Emacs to have count badge, progress and
;; urgent status
;; Integrate desktop environment's taskbar/dock with Emacs.
;;
;;; Code:

(require 'dbus)

(defun unity-launcher-api-update (api-uri properties-alist)
"Send D-Bus signal to com.canonical.Unity.LauncherEntry.
(defgroup dock nil
"Integrate desktop environment's taskbar/dock with Emacs."
:link '(url-link :tag "Website" "https://github.com/hron/dock.el")
:link '(emacs-library-link :tag "Library Source" "dock.el")
:group 'convenience
:group 'environment
:group 'frames
:prefix "dock-")

(defcustom dock-desktop-file "emacs.desktop"
"The desktop file id of Emacs.

API-URI: a string on the form application://$desktop_file_id. The
desktop file id of an application is defined to be the basename of the
application's .desktop-file including the extension. So taking Emacs as
an example it would be application://emacs.desktop
This is used when sending D-Bus messages to pinpoint the taskbar entry
for updating the properties. Usually, this is just `emacs.desktop', but
in case Emacs is used as a dedicated window for applications like
`org-mode', with separate desktop file, you might want to set it
accordingly to match such entry on the taskbar."
:group 'dock
:type 'string)

(defun dock-update (properties-alist)
"Send D-Bus signal to com.canonical.Unity.LauncherEntry.

PROPERTIES-ALIST: The properties to set on the launcher icon. Valid
properties are:
Expand Down Expand Up @@ -60,11 +74,11 @@ updated, to inform the user."
"/"
"com.canonical.Unity.LauncherEntry"
"Update"
api-uri
(unity-launcher-api--build-dbus-args properties-alist)))
(concat "application://" dock-desktop-file)
(dock--build-dbus-args properties-alist)))

(defun unity-launcher-api--build-dbus-args (properties-alist)
"Convert PROPERTIES-ALIST to args for dbus-send-signal."
(defun dock--build-dbus-args (properties-alist)
"Convert PROPERTIES-ALIST to args for `dbus-send-signal'."
(seq-map
(lambda (prop)
(let* ((key (symbol-name (car prop)))
Expand All @@ -81,5 +95,5 @@ updated, to inform the user."
`(:dict-entry ,key ,value)))
properties-alist))

(provide 'unity-launcher-api)
;;; unity-launcher-api.el ends here
(provide 'dock)
;;; dock.el ends here