mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-26 10:49:33 +00:00
Add new function xdg-current-desktop to xdg.el
* lisp/xdg.el (xdg-current-desktop): New function. * test/lisp/xdg-tests.el (xdg-current-desktop): New test.
This commit is contained in:
parent
d0b2eee278
commit
fd70791218
8
etc/NEWS
8
etc/NEWS
@ -3458,6 +3458,14 @@ version 0.8 (8th May 2021), "contains state data that should persist
|
||||
between (application) restarts, but that is not important or portable
|
||||
enough to the user that it should be stored in $XDG_DATA_HOME".
|
||||
|
||||
---
|
||||
*** New function 'xdg-current-desktop'.
|
||||
It returns a list of strings, corresponding to the colon-separated
|
||||
list of names in the 'XDG_CURRENT_DESKTOP' environment variable, which
|
||||
identify the current desktop environment.
|
||||
(This variable was introduced in XDG Desktop Entry Specification
|
||||
version 1.2.)
|
||||
|
||||
+++
|
||||
** New macro 'with-delayed-message'.
|
||||
This macro is like 'progn', but will output the specified message if
|
||||
|
12
lisp/xdg.el
12
lisp/xdg.el
@ -281,6 +281,18 @@ Optional argument GROUP defaults to the string \"Desktop Entry\"."
|
||||
(when (null (string-match-p "[^[:blank:]]" (car res))) (pop res))
|
||||
(nreverse res)))
|
||||
|
||||
(defun xdg-current-desktop ()
|
||||
"Return a list of strings identifying the current desktop environment.
|
||||
|
||||
According to the XDG Desktop Entry Specification version 0.5:
|
||||
|
||||
If $XDG_CURRENT_DESKTOP is set then it contains a
|
||||
colon-separated list of strings ... $XDG_CURRENT_DESKTOP
|
||||
should have been set by the login manager, according to the
|
||||
value of the DesktopNames found in the session file."
|
||||
(when-let ((ret (getenv "XDG_CURRENT_DESKTOP")))
|
||||
(string-split ret ":")))
|
||||
|
||||
|
||||
;; MIME apps specification
|
||||
;; https://standards.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.1.html
|
||||
|
@ -59,6 +59,16 @@
|
||||
(should (equal (xdg-desktop-strings " ") nil))
|
||||
(should (equal (xdg-desktop-strings "a; ;") '("a" " "))))
|
||||
|
||||
(ert-deftest xdg-current-desktop ()
|
||||
(let ((env (getenv "XDG_CURRENT_DESKTOP")))
|
||||
(unwind-protect
|
||||
(progn
|
||||
(setenv "XDG_CURRENT_DESKTOP" "KDE")
|
||||
(should (equal (xdg-current-desktop) '("KDE")))
|
||||
(setenv "XDG_CURRENT_DESKTOP" "ubuntu:GNOME")
|
||||
(should (equal (xdg-current-desktop) '("ubuntu" "GNOME"))))
|
||||
(setenv "XDG_CURRENT_DESKTOP" env))))
|
||||
|
||||
(ert-deftest xdg-mime-associations ()
|
||||
"Test reading MIME associations from files."
|
||||
(let* ((apps (ert-resource-file "mimeapps.list"))
|
||||
|
Loading…
Reference in New Issue
Block a user