From 6866dfa3a08591aee3ebbc417fd459754b12a0fb Mon Sep 17 00:00:00 2001 From: Samuel Walladge Date: Tue, 23 Jul 2019 17:17:37 +0930 Subject: support wayland condition for rifle - also support wayland for flag t (opening in new terminal) --- ranger/config/rifle.conf | 4 +++- ranger/core/runner.py | 2 +- ranger/ext/rifle.py | 9 +++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ranger/config/rifle.conf b/ranger/config/rifle.conf index a90646e2..baff30f8 100644 --- a/ranger/config/rifle.conf +++ b/ranger/config/rifle.conf @@ -27,6 +27,8 @@ # number | change the number of this command to n # terminal | stdin, stderr and stdout are connected to a terminal # X | $DISPLAY is not empty (i.e. Xorg runs) +# W | $WAYLAND_DISPLAY is not empty (i.e. Wayland runs) +# XW or WX | Wayland OR Xorg runs # # There are also pseudo-conditions which have a "side effect": # flag | Change how the program is run. See below. @@ -70,7 +72,7 @@ ext x?html?, has chromium-browser, X, flag f = chromium-browser -- "$@" ext x?html?, has chromium, X, flag f = chromium -- "$@" ext x?html?, has google-chrome, X, flag f = google-chrome -- "$@" ext x?html?, has opera, X, flag f = opera -- "$@" -ext x?html?, has firefox, X, flag f = firefox -- "$@" +ext x?html?, has firefox, XW, flag f = firefox -- "$@" ext x?html?, has seamonkey, X, flag f = seamonkey -- "$@" ext x?html?, has iceweasel, X, flag f = iceweasel -- "$@" ext x?html?, has epiphany, X, flag f = epiphany -- "$@" diff --git a/ranger/core/runner.py b/ranger/core/runner.py index f38b026a..08d7f85d 100644 --- a/ranger/core/runner.py +++ b/ranger/core/runner.py @@ -214,7 +214,7 @@ class Runner(object): # pylint: disable=too-few-public-methods toggle_ui = True context.wait = True if 't' in context.flags: - if 'DISPLAY' not in os.environ: + if 'DISPLAY' not in os.environ and 'WAYLAND_DISPLAY' not in os.environ: return self._log("Can not run with 't' flag, no display found!") term = get_term() if isinstance(action, str): diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py index a55e14c7..a5cf4aed 100755 --- a/ranger/ext/rifle.py +++ b/ranger/ext/rifle.py @@ -236,8 +236,13 @@ class Rifle(object): # pylint: disable=too-many-instance-attributes elif function == 'flag': self._app_flags = argument return True - elif function == 'X': - return sys.platform == 'darwin' or 'DISPLAY' in os.environ + elif function.isupper(): + if 'X' in function and 'W' in function: + return 'WAYLAND_DISPLAY' in os.environ or sys.platform == 'darwin' or 'DISPLAY' in os.environ + elif 'X' in function: + return sys.platform == 'darwin' or 'DISPLAY' in os.environ + elif 'W' in function: + return 'WAYLAND_DISPLAY' in os.environ elif function == 'env': return bool(os.environ.get(argument)) elif function == 'else': -- cgit 1.4.1-2-gfad0 From 3098fd36cd717646e48768f6cdd48cd6f0167d80 Mon Sep 17 00:00:00 2001 From: Samuel Walladge Date: Wed, 24 Jul 2019 09:21:05 +0930 Subject: expand X condition only --- ranger/config/rifle.conf | 6 ++---- ranger/core/runner.py | 2 +- ranger/ext/rifle.py | 9 ++------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/ranger/config/rifle.conf b/ranger/config/rifle.conf index baff30f8..f593b781 100644 --- a/ranger/config/rifle.conf +++ b/ranger/config/rifle.conf @@ -26,9 +26,7 @@ # directory | $1 is a directory # number | change the number of this command to n # terminal | stdin, stderr and stdout are connected to a terminal -# X | $DISPLAY is not empty (i.e. Xorg runs) -# W | $WAYLAND_DISPLAY is not empty (i.e. Wayland runs) -# XW or WX | Wayland OR Xorg runs +# X | A graphical environment is available (darwin, Xorg, or Wayland) # # There are also pseudo-conditions which have a "side effect": # flag | Change how the program is run. See below. @@ -72,7 +70,7 @@ ext x?html?, has chromium-browser, X, flag f = chromium-browser -- "$@" ext x?html?, has chromium, X, flag f = chromium -- "$@" ext x?html?, has google-chrome, X, flag f = google-chrome -- "$@" ext x?html?, has opera, X, flag f = opera -- "$@" -ext x?html?, has firefox, XW, flag f = firefox -- "$@" +ext x?html?, has firefox, X, flag f = firefox -- "$@" ext x?html?, has seamonkey, X, flag f = seamonkey -- "$@" ext x?html?, has iceweasel, X, flag f = iceweasel -- "$@" ext x?html?, has epiphany, X, flag f = epiphany -- "$@" diff --git a/ranger/core/runner.py b/ranger/core/runner.py index 08d7f85d..efb307da 100644 --- a/ranger/core/runner.py +++ b/ranger/core/runner.py @@ -214,7 +214,7 @@ class Runner(object): # pylint: disable=too-few-public-methods toggle_ui = True context.wait = True if 't' in context.flags: - if 'DISPLAY' not in os.environ and 'WAYLAND_DISPLAY' not in os.environ: + if not ('WAYLAND_DISPLAY' in os.environ or sys.platform == 'darwin' or 'DISPLAY' in os.environ): return self._log("Can not run with 't' flag, no display found!") term = get_term() if isinstance(action, str): diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py index a5cf4aed..cdf0d729 100755 --- a/ranger/ext/rifle.py +++ b/ranger/ext/rifle.py @@ -236,13 +236,8 @@ class Rifle(object): # pylint: disable=too-many-instance-attributes elif function == 'flag': self._app_flags = argument return True - elif function.isupper(): - if 'X' in function and 'W' in function: - return 'WAYLAND_DISPLAY' in os.environ or sys.platform == 'darwin' or 'DISPLAY' in os.environ - elif 'X' in function: - return sys.platform == 'darwin' or 'DISPLAY' in os.environ - elif 'W' in function: - return 'WAYLAND_DISPLAY' in os.environ + elif function == 'X': + return 'WAYLAND_DISPLAY' in os.environ or sys.platform == 'darwin' or 'DISPLAY' in os.environ elif function == 'env': return bool(os.environ.get(argument)) elif function == 'else': -- cgit 1.4.1-2-gfad0