lemonbar: Move last actions to modules and remove command dict

This commit is contained in:
2019-11-14 19:08:45 +01:00
committed by kuben
parent b8bf0c0f61
commit 1367be34be
3 changed files with 40 additions and 42 deletions

View File

@@ -13,6 +13,7 @@ health_logger = None
screen_send_cmd = lambda s : None # TODO temporary until move actions to modules
write_queue = None # TODO Actually, why is this a queue? Just last element is important
# TODO bar mode can be moved to i3Module
class bar_mode(Enum):
power, normal, control = range(-1,2) # Don't cycle through power
@@ -24,40 +25,12 @@ class bar_mode(Enum):
mode = bar_mode.normal
def i3msg_comm(args):
subprocess.Popen(args.split())
def set_mode(args):
global mode
new_mode = args.split()[1]
if new_mode == "cycle":
mode = mode.cycle()
for m in bar_mode:
if new_mode == m.name:
mode = m
break
def bluetooth(args):
btcargs = args.split()[1:]
btcargs = [a.replace('pxc550', '00:16:94:22:29:0E') for a in btcargs]
inp = ' '.join(btcargs)
screen_send_cmd('bluetoothctl ' + inp)
show_secs = False
# Keymaps
def_keymap = 'pl'
keymaps = {'firefox': 'se'}
cur_class = ''
def set_lang(args):
global keymaps
lang = args.split()[1]
keymaps[cur_class] = lang
commands_dict = {'i3-msg': i3msg_comm
,'mode': set_mode
,'setlang': set_lang
,'bluetooth': bluetooth
}
# Helper functions
ansi_escape = re.compile(r'(\x9B|\x1B\[)[0-?]*[ -/]*[@-~]')