From 8d88b23947542aca7622fe46a4efc36467e80165 Mon Sep 17 00:00:00 2001 From: tobi-wan-kenobi Date: Sat, 13 Mar 2021 13:17:20 +0100 Subject: [PATCH] [modules] add a module "keys" that shows whether a key is pressed also, add backend functionality to hide individual widgets of a module. --- bumblebee_status/core/module.py | 4 +- bumblebee_status/core/output.py | 2 + bumblebee_status/core/widget.py | 3 +- themes/gruvbox-powerline.json | 65 ++++++++++++++++++++------------- 4 files changed, 46 insertions(+), 28 deletions(-) diff --git a/bumblebee_status/core/module.py b/bumblebee_status/core/module.py index 5de00ee..5be7a4f 100644 --- a/bumblebee_status/core/module.py +++ b/bumblebee_status/core/module.py @@ -190,9 +190,9 @@ class Module(core.input.Object): :rtype: bumblebee_status.widget.Widget """ - def add_widget(self, full_text="", name=None): + def add_widget(self, full_text="", name=None, hidden=False): widget_id = "{}::{}".format(self.name, len(self.widgets())) - widget = core.widget.Widget(full_text=full_text, name=name, widget_id=widget_id) + widget = core.widget.Widget(full_text=full_text, name=name, widget_id=widget_id, hidden=hidden) self.widgets().append(widget) widget.module = self return widget diff --git a/bumblebee_status/core/output.py b/bumblebee_status/core/output.py index e3ec476..1760309 100644 --- a/bumblebee_status/core/output.py +++ b/bumblebee_status/core/output.py @@ -216,6 +216,8 @@ class i3(object): continue if module.hidden(): continue + if widget.hidden: + continue if "critical" in widget.state() and self.__config.errorhide(widget.module.name): continue blocks.extend(self.separator_block(module, widget)) diff --git a/bumblebee_status/core/widget.py b/bumblebee_status/core/widget.py index b1c3b4e..5d823ea 100644 --- a/bumblebee_status/core/widget.py +++ b/bumblebee_status/core/widget.py @@ -10,12 +10,13 @@ log = logging.getLogger(__name__) class Widget(util.store.Store, core.input.Object): - def __init__(self, full_text="", name=None, widget_id=None): + def __init__(self, full_text="", name=None, widget_id=None, hidden=False): super(Widget, self).__init__() self.__full_text = full_text self.module = None self.name = name self.id = widget_id or self.id + self.hidden = hidden @property def module(self): diff --git a/themes/gruvbox-powerline.json b/themes/gruvbox-powerline.json index 3481dbc..d199243 100644 --- a/themes/gruvbox-powerline.json +++ b/themes/gruvbox-powerline.json @@ -44,29 +44,44 @@ "bg": "#b8bb26" } }, - "bluetooth": { - "ON": { - "fg": "#1d2021", - "bg": "#b8bb26" - } - }, - "git": { - "modified": { "bg": "#458588" }, - "deleted": { "bg": "#9d0006" }, - "new": { "bg": "#b16286" } - }, - "pomodoro": { - "paused": { - "fg": "#1d2021", - "bg": "#d79921" - }, - "work": { - "fg": "#1d2021", - "bg": "#b8bb26" - }, - "break": { - "fg": "#002b36", - "bg": "#859900" - } - } + "bluetooth": { + "ON": { + "fg": "#1d2021", + "bg": "#b8bb26" + } + }, + "git": { + "modified": { "bg": "#458588" }, + "deleted": { "bg": "#9d0006" }, + "new": { "bg": "#b16286" } + }, + "pomodoro": { + "paused": { + "fg": "#1d2021", + "bg": "#d79921" + }, + "work": { + "fg": "#1d2021", + "bg": "#b8bb26" + }, + "break": { + "fg": "#002b36", + "bg": "#859900" + } + }, + "keys": { + "Key.cmd": { + "bg": "#8ec07c", + "full_text": "***" + }, + "Key.shift": { + "bg": "#fabd2f" + }, + "Key.ctrl": { + "bg": "#83a598" + }, + "Key.alt": { + "bg": "#f28019" + } + } }