From 93b24030af3d02775e98594638c0a81e76150cab Mon Sep 17 00:00:00 2001 From: Aleksei Gusev Date: Thu, 17 Jul 2025 13:46:00 +0300 Subject: [PATCH 1/2] Introduce a constant to track desktop-file-id --- unity-launcher-api.el | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/unity-launcher-api.el b/unity-launcher-api.el index 1c223e8..16f56b7 100644 --- a/unity-launcher-api.el +++ b/unity-launcher-api.el @@ -14,20 +14,34 @@ ;; ;;; 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 unity-launcher-api nil + "Integrate desktop environment's taskbar/dock with Emacs." + :link '(url-link :tag "Website" "https://github.com/hron/unity-launcher-api.el") + :link '(emacs-library-link :tag "Library Source" "unity-launcher-api.el") + :group 'convenience + :group 'environment + :group 'frames + :prefix "unity-launcher-api-") + +(defcustom unity-launcher-api-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 'unity-launcher-api + :type 'string) + +(defun unity-launcher-api-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: @@ -60,11 +74,11 @@ updated, to inform the user." "/" "com.canonical.Unity.LauncherEntry" "Update" - api-uri + (concat "application://" unity-launcher-api-desktop-file) (unity-launcher-api--build-dbus-args properties-alist))) (defun unity-launcher-api--build-dbus-args (properties-alist) - "Convert PROPERTIES-ALIST to args for dbus-send-signal." + "Convert PROPERTIES-ALIST to args for `dbus-send-signal'." (seq-map (lambda (prop) (let* ((key (symbol-name (car prop))) From c6486624e69c9e2d8785b81fb7caa8ea2b3566b9 Mon Sep 17 00:00:00 2001 From: Aleksei Gusev Date: Thu, 17 Jul 2025 13:48:41 +0300 Subject: [PATCH 2/2] Rename to `dock` --- Makefile | 2 +- unity-launcher-api-tests.el => dock-tests.el | 14 +++++----- unity-launcher-api.el => dock.el | 28 ++++++++++---------- 3 files changed, 22 insertions(+), 22 deletions(-) rename unity-launcher-api-tests.el => dock-tests.el (54%) rename unity-launcher-api.el => dock.el (78%) diff --git a/Makefile b/Makefile index 7632a01..76488d1 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/unity-launcher-api-tests.el b/dock-tests.el similarity index 54% rename from unity-launcher-api-tests.el rename to dock-tests.el index c8b0cba..50f9f42 100644 --- a/unity-launcher-api-tests.el +++ b/dock-tests.el @@ -1,4 +1,4 @@ -;;; 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 ;; @@ -6,7 +6,7 @@ ;; Maintainer: Aleksei Gusev ;; 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. @@ -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 diff --git a/unity-launcher-api.el b/dock.el similarity index 78% rename from unity-launcher-api.el rename to dock.el index 16f56b7..79f7709 100644 --- a/unity-launcher-api.el +++ b/dock.el @@ -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 ;; @@ -7,7 +7,7 @@ ;; 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. @@ -20,16 +20,16 @@ (require 'dbus) -(defgroup unity-launcher-api nil +(defgroup dock nil "Integrate desktop environment's taskbar/dock with Emacs." - :link '(url-link :tag "Website" "https://github.com/hron/unity-launcher-api.el") - :link '(emacs-library-link :tag "Library Source" "unity-launcher-api.el") + :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 "unity-launcher-api-") + :prefix "dock-") -(defcustom unity-launcher-api-desktop-file "emacs.desktop" +(defcustom dock-desktop-file "emacs.desktop" "The desktop file id of Emacs. This is used when sending D-Bus messages to pinpoint the taskbar entry @@ -37,10 +37,10 @@ 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 'unity-launcher-api + :group 'dock :type 'string) -(defun unity-launcher-api-update (properties-alist) +(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 @@ -74,10 +74,10 @@ updated, to inform the user." "/" "com.canonical.Unity.LauncherEntry" "Update" - (concat "application://" unity-launcher-api-desktop-file) - (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) +(defun dock--build-dbus-args (properties-alist) "Convert PROPERTIES-ALIST to args for `dbus-send-signal'." (seq-map (lambda (prop) @@ -95,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