[main] Redraw on click
Whenever a module in the bar is clicked, immediately redraw the line, to make for a snappier user experience (especially when muting/unmuting).
This commit is contained in:
parent
89b97d7283
commit
b99c454a5a
3 changed files with 15 additions and 5 deletions
|
@ -1,9 +1,15 @@
|
||||||
|
|
||||||
class Output(object):
|
class Output(object):
|
||||||
def __init__(self, theme):
|
def __init__(self, refresh, theme):
|
||||||
self._theme = theme
|
self._theme = theme
|
||||||
|
self._refresh = refresh
|
||||||
self._callbacks = {}
|
self._callbacks = {}
|
||||||
|
|
||||||
|
def redraw(self):
|
||||||
|
self._refresh.acquire()
|
||||||
|
self._refresh.notify()
|
||||||
|
self._refresh.release()
|
||||||
|
|
||||||
def add_callback(self, cmd, button, module=None):
|
def add_callback(self, cmd, button, module=None):
|
||||||
if module:
|
if module:
|
||||||
module = module.replace("bumblebee.modules.", "")
|
module = module.replace("bumblebee.modules.", "")
|
||||||
|
|
|
@ -25,10 +25,11 @@ def read_input(output):
|
||||||
button = event.get("button", -1)
|
button = event.get("button", -1)
|
||||||
)
|
)
|
||||||
subprocess.Popen(shlex.split(cb), stdout=DEVNULL, stderr=DEVNULL)
|
subprocess.Popen(shlex.split(cb), stdout=DEVNULL, stderr=DEVNULL)
|
||||||
|
output.redraw()
|
||||||
|
|
||||||
class i3bar(bumblebee.output.Output):
|
class i3bar(bumblebee.output.Output):
|
||||||
def __init__(self, theme):
|
def __init__(self, refresh, theme):
|
||||||
super(i3bar, self).__init__(theme)
|
super(i3bar, self).__init__(refresh, theme)
|
||||||
self._data = []
|
self._data = []
|
||||||
|
|
||||||
self.add_callback("i3-msg workspace prev_on_output", 4)
|
self.add_callback("i3-msg workspace prev_on_output", 4)
|
||||||
|
|
|
@ -7,6 +7,7 @@ import glob
|
||||||
import pkgutil
|
import pkgutil
|
||||||
import argparse
|
import argparse
|
||||||
import textwrap
|
import textwrap
|
||||||
|
import threading
|
||||||
import importlib
|
import importlib
|
||||||
import bumblebee.theme
|
import bumblebee.theme
|
||||||
import bumblebee.modules
|
import bumblebee.modules
|
||||||
|
@ -83,8 +84,9 @@ def main():
|
||||||
print_theme_list()
|
print_theme_list()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
refresh = threading.Condition()
|
||||||
theme = bumblebee.theme.Theme(args.theme) if args.theme else bumblebee.theme.Theme()
|
theme = bumblebee.theme.Theme(args.theme) if args.theme else bumblebee.theme.Theme()
|
||||||
output = bumblebee.outputs.i3.i3bar(theme)
|
output = bumblebee.outputs.i3.i3bar(refresh, theme)
|
||||||
|
|
||||||
modules = []
|
modules = []
|
||||||
for m in args.modules:
|
for m in args.modules:
|
||||||
|
@ -96,6 +98,7 @@ def main():
|
||||||
print output.start()
|
print output.start()
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
refresh.acquire()
|
||||||
while True:
|
while True:
|
||||||
theme.reset()
|
theme.reset()
|
||||||
for m in modules:
|
for m in modules:
|
||||||
|
@ -103,7 +106,7 @@ def main():
|
||||||
theme.next()
|
theme.next()
|
||||||
print output.get()
|
print output.get()
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
time.sleep(args.interval)
|
refresh.wait(args.interval)
|
||||||
|
|
||||||
print output.stop()
|
print output.stop()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue