lemonbar: Implement modular approach for conky slow and conky fast
This commit is contained in:
@@ -14,7 +14,7 @@ battery = ''
|
||||
date = ''
|
||||
language = ''
|
||||
time = ''
|
||||
response = '%{r}'
|
||||
response = ''
|
||||
|
||||
blank = ' '
|
||||
|
||||
@@ -87,7 +87,7 @@ def control_sect(sec_color=None, head='', buttons=[], actions=[]):
|
||||
# Constants
|
||||
power_opts = ''.join([block(fg=conf.color_fore, bg=conf.color_poweropts)
|
||||
, ' Abort (Esc) | System (l) lock, (e) logout, (s) suspend, (h) hibernate'
|
||||
, ', (r) reboot, (Shift+s) shutdown %{r}'])
|
||||
, ', (r) reboot, (Shift+s) shutdown'])
|
||||
controls = ' '.join([block(fg=conf.color_head, bg=conf.color_sec_b2)
|
||||
, conf.sep_right, block(fg=conf.color_head, bg=conf.color_sec_b2, click='mode cycle')
|
||||
, conf.icon_prog
|
||||
@@ -102,7 +102,7 @@ def update_response(data):
|
||||
|
||||
resp = ' '.join(data)
|
||||
#common.logger.debug('Got response {}'.format(resp))
|
||||
response= ''.join(['%{r}', single_sect(text=resp)])
|
||||
response= single_sect(text=resp)
|
||||
|
||||
def update_displays(data):
|
||||
global displays
|
||||
@@ -146,36 +146,6 @@ def update_workspaces(data):
|
||||
|
||||
workspaces = ''.join([prefix, ' '.join(wspces)])
|
||||
|
||||
def update_conky_slow(data):
|
||||
global sys_load, battery
|
||||
# System load
|
||||
if int(data[0]) > int(conf.cpu_alert):
|
||||
cpu_alt = COLOR_SCHEME.CPU_ALERT
|
||||
else:
|
||||
cpu_alt = COLOR_SCHEME.A2
|
||||
|
||||
sys_load = ''.join(['%{r}'
|
||||
, double_sect(text1 = (data[0] + '%'), text2 = data[1], icon1 = conf.icon_cpu
|
||||
, icon2 = conf.icon_mem, alt=cpu_alt , click = 'load')
|
||||
, double_sect(text1 = (data[2] + '%'), text2 = (data[3] + '%')
|
||||
, icon1 = conf.icon_hd, icon2 = conf.icon_home, alt=COLOR_SCHEME.A1)
|
||||
]) # cpu mem disk_r disk_home
|
||||
|
||||
#sec_color = conf.color_sec_b1 if (b == 1) else conf.color_sec_b2
|
||||
|
||||
(batt_stat, batt) = (data[4][0], int(data[4][1:]))
|
||||
icon_batt = conf.icon_charging if batt_stat == 'C' else \
|
||||
conf.icon_charged if batt_stat == 'F' else \
|
||||
conf.icon_batt_0 if batt < 20 else \
|
||||
conf.icon_batt_1 if batt < 40 else \
|
||||
conf.icon_batt_2 if batt < 60 else \
|
||||
conf.icon_batt_3 if batt < 80 else \
|
||||
conf.icon_batt_4
|
||||
battery = single_sect(icon=icon_batt, click='dpms', text=(str(batt)+'%')
|
||||
, alt=COLOR_SCHEME.A2)
|
||||
update_bright([data[5]])
|
||||
update_lang([data[6]])
|
||||
|
||||
def update_lang(data):
|
||||
global language
|
||||
language = single_sect(icon=conf.icon_lang, click='lang', text=data[0]
|
||||
@@ -187,22 +157,6 @@ def update_bright(data):
|
||||
brightness = single_sect(icon=conf.icon_bright, click='adj_br'
|
||||
, text=(brtxt+'%'), alt=COLOR_SCHEME.A1)
|
||||
|
||||
def update_conky_fast(data):
|
||||
global date, time, volume
|
||||
mute = data[4] == 'MUTE' or data[4] == 'NONE'
|
||||
(vol,vols) = (-1,'×') if mute else (int(data[4]), data[4]+'%')
|
||||
icon_v = conf.icon_vol_mute if vol == 0 else \
|
||||
conf.icon_vol_low if vol < 50 else conf.icon_vol
|
||||
volume = single_sect(icon=icon_v, click='pavu', text=vols
|
||||
, alt=COLOR_SCHEME.A2)
|
||||
|
||||
tme = data[3] if common.show_secs else data[3][:-3]
|
||||
date = single_sect(icon=conf.icon_clock, click='date'
|
||||
, text=' '.join(data[0:3]), alt=COLOR_SCHEME.A1)
|
||||
time = single_sect(click='toggle_secs', text=tme, alt=COLOR_SCHEME.SPECIAL)
|
||||
|
||||
update_net(data[5:9])
|
||||
|
||||
def update_net(data):
|
||||
global net_load
|
||||
|
||||
@@ -245,19 +199,17 @@ def update_title(data):
|
||||
def format_line():
|
||||
# Need to end with a reset block, otherwise the color fills the %{r} spacer
|
||||
if common.mode == common.bar_mode.normal:
|
||||
return ''.join(['%{l}', reset, displays, workspaces, win_title, sys_load, net_load
|
||||
return ''.join(['%{l}', reset, displays, workspaces, win_title, '%{r}', sys_load, net_load
|
||||
, volume, brightness, battery, date, language, time, reset])
|
||||
elif common.mode == common.bar_mode.power:
|
||||
return ''.join(['%{l}', reset, power_opts, sys_load, net_load
|
||||
return ''.join(['%{l}', reset, power_opts, '%{r}', sys_load, net_load
|
||||
, volume, brightness, battery, date, language, time, reset_power])
|
||||
elif common.mode == common.bar_mode.control:
|
||||
return ''.join(['%{l}', reset, displays, workspaces, controls, response, time, reset])
|
||||
return ''.join(['%{l}', reset, displays, workspaces, controls, '%{r}', response, time, reset])
|
||||
else:
|
||||
return ''.join(['%{l}', reset, displays, workspaces, 'Not normal' , time, reset])
|
||||
return ''.join(['%{l}', reset, displays, workspaces, 'Not normal', '%{r}', time, reset])
|
||||
|
||||
parsers_dict = { 'CNK_FAST':update_conky_fast
|
||||
,'CNK_SLOW':update_conky_slow
|
||||
,'WSP':update_workspaces
|
||||
parsers_dict = { 'WSP':update_workspaces
|
||||
,'LANG':update_lang
|
||||
,'BRIGHT':update_bright
|
||||
,'WIN':update_title
|
||||
|
||||
Reference in New Issue
Block a user