From c560c078902fefe3e033a5d7d09cfc3ba1624b33 Mon Sep 17 00:00:00 2001 From: tobi-wan-kenobi Date: Sun, 10 May 2020 12:52:20 +0200 Subject: [PATCH] [packaging/pip] Make binary utility tools functional --- bumblebee_status/discover.py | 11 +++++++++++ bumblebee_status/modules/contrib/pacman.py | 6 +++--- bumblebee_status/modules/core/xrandr.py | 8 ++++---- setup.cfg | 3 --- setup.py | 1 + 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/bumblebee_status/discover.py b/bumblebee_status/discover.py index 5c9e1bc..503be7d 100644 --- a/bumblebee_status/discover.py +++ b/bumblebee_status/discover.py @@ -8,5 +8,16 @@ def discover(): ) sys.path.append(libdir) +def utility(name): + current_path = os.path.dirname(os.path.abspath(__file__)) + + for path in [ + os.path.join(current_path, "..", "bin"), + os.path.join(current_path, "..", "..", "..", "..", "share", "bumblebee-status", "utility"), + "/usr/share/bumblebee-status/bin/", + ]: + if os.path.exists(os.path.abspath(os.path.join(path, name))): + return os.path.abspath(os.path.join(path, name)) + raise Exception("{} not found".format(name)) # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 diff --git a/bumblebee_status/modules/contrib/pacman.py b/bumblebee_status/modules/contrib/pacman.py index 8566112..b50ed53 100644 --- a/bumblebee_status/modules/contrib/pacman.py +++ b/bumblebee_status/modules/contrib/pacman.py @@ -22,15 +22,15 @@ import core.decorators import util.cli import util.format +from bumblebee_status.discover import utility + # list of repositories. # the last one should always be other repos = ["core", "extra", "community", "multilib", "testing", "other"] def get_pacman_info(widget, path): - cmd = "{}/../../bin/pacman-updates".format(path) - if not os.path.exists(cmd): - cmd = "/usr/share/bumblebee-status/bin/pacman-update" + cmd = utility("pacman-updates") result = util.cli.execute(cmd, ignore_errors=True) count = len(repos) * [0] diff --git a/bumblebee_status/modules/core/xrandr.py b/bumblebee_status/modules/core/xrandr.py index f3eabb6..04278ba 100644 --- a/bumblebee_status/modules/core/xrandr.py +++ b/bumblebee_status/modules/core/xrandr.py @@ -24,6 +24,8 @@ import core.module import core.input import core.decorators +from bumblebee_status.discover import utility + import util.cli import util.format @@ -36,8 +38,7 @@ except: class Module(core.module.Module): @core.decorators.every(seconds=5) # takes up to 5s to detect a new screen def __init__(self, config, theme): - widgets = [] - super().__init__(config, theme, widgets) + super().__init__(config, theme, []) self._autoupdate = util.format.asbool(self.parameter("autoupdate", True)) self._needs_update = True @@ -85,10 +86,9 @@ class Module(core.module.Module): def _toggle(self, event): self._refresh(self, event) - path = os.path.dirname(os.path.abspath(__file__)) if util.format.asbool(self.parameter("overwrite_i3config", False)) == True: - toggle_cmd = "{}/../../bin/toggle-display.sh".format(path) + toggle_cmd = utility("toggle-display.sh") else: toggle_cmd = "xrandr" diff --git a/setup.cfg b/setup.cfg index 5caf4e6..9352f13 100644 --- a/setup.cfg +++ b/setup.cfg @@ -39,9 +39,6 @@ packages = find: scripts = ./bumblebee-status ./bumblebee-ctl - ./bin/load-i3-bars.sh - ./bin/pacman-updates - ./bin/toggle-display.sh [versioneer] VCS = git diff --git a/setup.py b/setup.py index 79ccd29..5a100d4 100755 --- a/setup.py +++ b/setup.py @@ -56,5 +56,6 @@ setup( data_files=[ ("share/bumblebee-status/themes", glob.glob("themes/*.json")), ("share/bumblebee-status/themes/icons", glob.glob("themes/icons/*.json")), + ("share/bumblebee-status/utility", glob.glob("bin/*")), ], )