From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrew Tropin Newsgroups: gmane.emacs.devel Subject: [PATCH v4] notifications: Allow to use Icon Naming Specification for app-icon Date: Thu, 27 Jul 2023 12:03:22 +0400 Message-ID: <20230727080325.4372-1-andrew@trop.in> References: <877cqpsnct.fsf@trop.in> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35144"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Andrew Tropin To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Jul 27 10:53:59 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qOwkx-0008t2-3P for ged-emacs-devel@m.gmane-mx.org; Thu, 27 Jul 2023 10:53:59 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qOwgC-0008Hr-WE; Thu, 27 Jul 2023 04:49:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qOvyr-00046T-4B for emacs-devel@gnu.org; Thu, 27 Jul 2023 04:04:17 -0400 Original-Received: from relay7-d.mail.gandi.net ([2001:4b98:dc4:8::227]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qOvyo-0006TD-S1 for emacs-devel@gnu.org; Thu, 27 Jul 2023 04:04:16 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 575272000A; Thu, 27 Jul 2023 08:04:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop.in; s=gm1; t=1690445049; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bZNfj1rB0NzgLqPr6dcjZj0uYgrFapstMMDQ4T7BUAc=; b=m1KIkRGWr48MFySMKbr/Wafy9YXqxtjcXa4bMqDgKnGhp9Xnmvj6b0RWsEQYJoPpYH/vIE U0Z1yrgecAi54UosVltXEiDSfr0kL5yMIl1LKR/cJuIqdx1cjc8/rZCFa6D2WGxes4po+2 SE7e0dR3LvXEJ5zU+od8NJjBF0nkcQ7smn+gminAMdcW6qSLj2GyhLMkwwxGSHH9a0N8yK b8VuVB0h/tPmAYCuGvnFbjafPxQ5TwN7Pwsg9FnglJijcVU6HSMB3zDkPWgXphUJf2NXS4 ApMhAun938OxRGoaFuoyWGNkZcQRpJuJHIFKrG2YNflxmZ4KRQx5qCGQ1rSjcA== X-Mailer: git-send-email 2.41.0 In-Reply-To: <877cqpsnct.fsf@trop.in> X-GND-Sasl: andrew@trop.in Received-SPF: pass client-ip=2001:4b98:dc4:8::227; envelope-from=andrew@trop.in; helo=relay7-d.mail.gandi.net X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 27 Jul 2023 04:48:58 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:308139 Archived-At: Icon is not always a file name, but can be just an icon name. https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html * lisp/notifications.el (notifications-notify): Allow to use Icon Naming Specification for app-icon. --- doc/lispref/os.texi | 7 +++++++ etc/NEWS | 10 ++++++++++ lisp/notifications.el | 11 ++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index 4bcc9d5fea6..ebedfe82087 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi @@ -2885,6 +2885,13 @@ Desktop Notifications @item :app-icon @var{icon-file} The file name of the notification icon. If set to @code{nil}, no icon is displayed. The default is @code{notifications-application-icon}. +If the value is a string, the function interprets it as a file name +and converts to absolute by using @code{expand-file-name}; if it is a +symbol, the function will use its name (which is useful when using the +Icon Naming Specification @footnote{For more information about icon +naming convention see +@uref{https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html, +Icon Naming Specification}}). @item :actions (@var{key} @var{title} @var{key} @var{title} ...) A list of actions to be applied. @var{key} and @var{title} are both diff --git a/etc/NEWS b/etc/NEWS index 5883b4df2a7..51c7fe6a363 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -548,6 +548,16 @@ Similarly to buffer restoration by Desktop, 'recentf-mode' checking of the accessibility of remote files can now time out if 'remote-file-name-access-timeout' is set to a positive number. +** Notifications + ++++ +*** Allow to use Icon Naming Specification for app-icon +You can use a symbol as the value for ':app-icon' to provide icon name +without specifying a file, like this: + + (notifications-notify + :title "I am playing music" :app-icon 'multimedia-player) + * New Modes and Packages in Emacs 30.1 diff --git a/lisp/notifications.el b/lisp/notifications.el index 984ddbec5e9..a694b38e52e 100644 --- a/lisp/notifications.el +++ b/lisp/notifications.el @@ -137,6 +137,12 @@ notifications-notify :app-icon The notification icon. Default is `notifications-application-icon'. Set to nil if you do not want any icon displayed. + If the value is a string, the function + interprets it as a file name and converts to + absolute by using `expand-file-name'; if it is a + symbol, the function will use its name (which is + useful when using the Icon Naming + Specification). :actions A list of actions in the form: (KEY TITLE KEY TITLE ...) where KEY and TITLE are both strings. @@ -304,7 +310,10 @@ notifications-notify notifications-application-name) :uint32 (or replaces-id 0) :string (if app-icon - (expand-file-name app-icon) + (if (stringp app-icon) + (expand-file-name app-icon) + ;; Convert symbol to string + (symbol-name app-icon)) ;; If app-icon is nil because user ;; requested it to be so, send the ;; empty string -- 2.41.0