unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Vasilij Schneidermann <v.schneidermann@gmail.com>
To: 25778@debbugs.gnu.org
Subject: bug#25778: 25.1; [PATCH] Drastically simplify xdg-open check
Date: Fri, 17 Feb 2017 19:16:48 +0100	[thread overview]
Message-ID: <CAPGgwWRPPCSjYiLV8dQVtijP=Zm3Ok67d898Aasi_J0AseCfkg@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 710 bytes --]

A user on #emacs brought it to my attention that the xdg-open detection
for browse-url is more complex than it should be and fails detecting
their Linux desktop.  Looking at the definition of
`browse-url-can-use-xdg-open' reveals that it replicates the desktop
environment check as done by `xdg-open` (which is done to detect the
DE-specific default browser setting, not to prevent people not using a
popular desktop environment from using xdg-open).  As enumerating all
possible kinds of Linux desktop is a futile endeavor, I've completely
eliminated this check from it so that the only ones left are whether
we're in a graphical session (by checking $DISPLAY) and whether
`xdg-open` has been found on $PATH.

[-- Attachment #2: 0001-Drastically-simplify-check-for-xdg-open.patch --]
[-- Type: text/x-patch, Size: 2714 bytes --]

From 6c99e7ace3110b73a5b212203acc728165be092b Mon Sep 17 00:00:00 2001
From: Vasilij Schneidermann <v.schneidermann@gmail.com>
Date: Fri, 17 Feb 2017 19:08:54 +0100
Subject: [PATCH] Drastically simplify check for xdg-open

* browse-url.el (browse-url-can-use-xdg-open): Simplify xdg-open check
---
 lisp/net/browse-url.el | 34 +++-------------------------------
 1 file changed, 3 insertions(+), 31 deletions(-)

diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index a7c879cbfb..bf7561306c 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -45,7 +45,7 @@
 ;; browse-url-generic                 arbitrary
 ;; browse-url-default-windows-browser MS-Windows browser
 ;; browse-url-default-macosx-browser  macOS browser
-;; browse-url-xdg-open                Free Desktop xdg-open on Gnome, KDE, Xfce4, LXDE
+;; browse-url-xdg-open                Free Desktop xdg-open
 ;; browse-url-kde                     KDE konqueror (kfm)
 ;; browse-url-elinks                  Elinks      Don't know (tried with 0.12.GIT)
 
@@ -944,36 +944,8 @@ instead of `browse-url-new-window-flag'."
 
 (defun browse-url-can-use-xdg-open ()
   "Return non-nil if the \"xdg-open\" program can be used.
-xdg-open is a desktop utility that calls your preferred web browser.
-This requires you to be running either Gnome, KDE, Xfce4 or LXDE."
-  (and (getenv "DISPLAY")
-       (executable-find "xdg-open")
-       ;; xdg-open may call gnome-open and that does not wait for its child
-       ;; to finish.  This child may then be killed when the parent dies.
-       ;; Use nohup to work around.  See bug#7166, bug#8917, bug#9779 and
-       ;; http://lists.gnu.org/archive/html/emacs-devel/2009-07/msg00279.html
-       (executable-find "nohup")
-       (or (getenv "GNOME_DESKTOP_SESSION_ID")
-	   ;; GNOME_DESKTOP_SESSION_ID is deprecated, check on Dbus also.
-	   (condition-case nil
-	       (eq 0 (call-process
-		      "dbus-send" nil nil nil
-				  "--dest=org.gnome.SessionManager"
-				  "--print-reply"
-				  "/org/gnome/SessionManager"
-				  "org.gnome.SessionManager.CanShutdown"))
-	     (error nil))
-	   (equal (getenv "KDE_FULL_SESSION") "true")
-	   (condition-case nil
-	       (eq 0 (call-process
-		      "/bin/sh" nil nil nil
-		      "-c"
-		      ;; FIXME use string-match rather than grep.
-		      "xprop -root _DT_SAVE_MODE|grep xfce4"))
-	     (error nil))
-	   (member (getenv "DESKTOP_SESSION") '("LXDE" "Lubuntu"))
-	   (equal (getenv "XDG_CURRENT_DESKTOP") "LXDE"))))
-
+xdg-open is a desktop utility that calls your preferred web browser."
+  (and (getenv "DISPLAY") (executable-find "xdg-open")))
 
 ;;;###autoload
 (defun browse-url-xdg-open (url &optional ignored)
-- 
2.11.0


             reply	other threads:[~2017-02-17 18:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-17 18:16 Vasilij Schneidermann [this message]
2017-02-17 18:38 ` bug#25778: 25.1; [PATCH] Drastically simplify xdg-open check Eli Zaretskii
2017-02-17 18:55   ` Vasilij Schneidermann
2017-02-18  3:39     ` Glenn Morris
2017-02-18  3:46       ` Glenn Morris
2017-02-18  8:55         ` Vasilij Schneidermann
2017-02-19  0:31           ` Glenn Morris
2017-02-19 13:06             ` Vasilij Schneidermann
2017-02-18  7:58     ` Eli Zaretskii
2017-02-18  8:50       ` Vasilij Schneidermann
2017-03-10  3:13 ` Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPGgwWRPPCSjYiLV8dQVtijP=Zm3Ok67d898Aasi_J0AseCfkg@mail.gmail.com' \
    --to=v.schneidermann@gmail.com \
    --cc=25778@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).