[packaging/pip] Make binary utility tools functional

This commit is contained in:
tobi-wan-kenobi 2020-05-10 12:52:20 +02:00
parent 92577e7d26
commit c560c07890
5 changed files with 19 additions and 10 deletions

View file

@ -8,5 +8,16 @@ def discover():
) )
sys.path.append(libdir) 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 # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4

View file

@ -22,15 +22,15 @@ import core.decorators
import util.cli import util.cli
import util.format import util.format
from bumblebee_status.discover import utility
# list of repositories. # list of repositories.
# the last one should always be other # the last one should always be other
repos = ["core", "extra", "community", "multilib", "testing", "other"] repos = ["core", "extra", "community", "multilib", "testing", "other"]
def get_pacman_info(widget, path): def get_pacman_info(widget, path):
cmd = "{}/../../bin/pacman-updates".format(path) cmd = utility("pacman-updates")
if not os.path.exists(cmd):
cmd = "/usr/share/bumblebee-status/bin/pacman-update"
result = util.cli.execute(cmd, ignore_errors=True) result = util.cli.execute(cmd, ignore_errors=True)
count = len(repos) * [0] count = len(repos) * [0]

View file

@ -24,6 +24,8 @@ import core.module
import core.input import core.input
import core.decorators import core.decorators
from bumblebee_status.discover import utility
import util.cli import util.cli
import util.format import util.format
@ -36,8 +38,7 @@ except:
class Module(core.module.Module): class Module(core.module.Module):
@core.decorators.every(seconds=5) # takes up to 5s to detect a new screen @core.decorators.every(seconds=5) # takes up to 5s to detect a new screen
def __init__(self, config, theme): def __init__(self, config, theme):
widgets = [] super().__init__(config, theme, [])
super().__init__(config, theme, widgets)
self._autoupdate = util.format.asbool(self.parameter("autoupdate", True)) self._autoupdate = util.format.asbool(self.parameter("autoupdate", True))
self._needs_update = True self._needs_update = True
@ -85,10 +86,9 @@ class Module(core.module.Module):
def _toggle(self, event): def _toggle(self, event):
self._refresh(self, event) self._refresh(self, event)
path = os.path.dirname(os.path.abspath(__file__))
if util.format.asbool(self.parameter("overwrite_i3config", False)) == True: 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: else:
toggle_cmd = "xrandr" toggle_cmd = "xrandr"

View file

@ -39,9 +39,6 @@ packages = find:
scripts = scripts =
./bumblebee-status ./bumblebee-status
./bumblebee-ctl ./bumblebee-ctl
./bin/load-i3-bars.sh
./bin/pacman-updates
./bin/toggle-display.sh
[versioneer] [versioneer]
VCS = git VCS = git

View file

@ -56,5 +56,6 @@ setup(
data_files=[ data_files=[
("share/bumblebee-status/themes", glob.glob("themes/*.json")), ("share/bumblebee-status/themes", glob.glob("themes/*.json")),
("share/bumblebee-status/themes/icons", glob.glob("themes/icons/*.json")), ("share/bumblebee-status/themes/icons", glob.glob("themes/icons/*.json")),
("share/bumblebee-status/utility", glob.glob("bin/*")),
], ],
) )