lemonbar: Get rid of wlan dummy on kubaDesktop
This commit is contained in:
@@ -175,30 +175,33 @@ conky.config = {{
|
|||||||
}}
|
}}
|
||||||
""".format(update_interval)
|
""".format(update_interval)
|
||||||
|
|
||||||
|
def conky_net(iface):
|
||||||
|
return """\\
|
||||||
|
${{if_up {iface}}}${{downspeedf {iface}}} ${{upspeedf {iface}}}\\
|
||||||
|
${{else}}down down${{endif}} """.format(iface=iface)
|
||||||
|
|
||||||
|
conky_begin_body = """
|
||||||
|
conky.text = [["""
|
||||||
|
|
||||||
|
conky_end_body = """
|
||||||
|
]]"""
|
||||||
class ConkyFastModule(LemonModule):
|
class ConkyFastModule(LemonModule):
|
||||||
if common.hostname() == 'kubaDesktop':
|
if common.hostname() == 'kubaDesktop':
|
||||||
conky_config = conky_config(update_interval=1) + """
|
conky_config = (conky_config(update_interval=1)
|
||||||
conky.text = [[
|
+ conky_begin_body
|
||||||
${exec ~/.i3/lemonbar/get_vol.sh} \
|
+ """\\
|
||||||
down down\
|
${exec ~/.i3/lemonbar/get_vol.sh} """
|
||||||
\
|
+ conky_net('enp5s0')
|
||||||
${if_up enp5s0}${downspeedf enp5s0} ${upspeedf enp5s0}\
|
+ conky_end_body)
|
||||||
${else}down down${endif}\
|
|
||||||
\
|
|
||||||
]]
|
|
||||||
"""
|
|
||||||
else:
|
else:
|
||||||
conky_config = conky_config(update_interval=2) + """
|
conky_config = (conky_config(update_interval=1)
|
||||||
conky.text = [[
|
+ conky_begin_body
|
||||||
${exec ~/.i3/lemonbar/get_vol.sh} \
|
+ """\\
|
||||||
${if_up wlp3s0}${downspeedf wlp3s0} ${upspeedf wlp3s0}\
|
${exec ~/.i3/lemonbar/get_vol.sh} """
|
||||||
${else}down down${endif}\
|
+ conky_net('wlp3s0')
|
||||||
\
|
+ conky_net('enp2s0')
|
||||||
${if_up enp2s0}${downspeedf enp2s0} ${upspeedf enp2s0}\
|
+ conky_end_body)
|
||||||
${else}down down${endif}\
|
|
||||||
\
|
|
||||||
]]
|
|
||||||
"""
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
@@ -209,20 +212,26 @@ ${else}down down${endif}\
|
|||||||
self.p_handle.stdin.close() # Otherwise conky doesn't load
|
self.p_handle.stdin.close() # Otherwise conky doesn't load
|
||||||
self.status_handle = self.p_handle.stdout
|
self.status_handle = self.p_handle.stdout
|
||||||
|
|
||||||
self.wlan_load = parser.IconTextUnit('wlan_load', action='wlan', order=13)
|
|
||||||
self.eth_load = parser.IconTextUnit('eth_load', action='eth', order=14)
|
self.eth_load = parser.IconTextUnit('eth_load', action='eth', order=14)
|
||||||
self.volume = parser.IconTextUnit('volume', action='pavu', order=20)
|
self.volume = parser.IconTextUnit('volume', action='pavu', order=20)
|
||||||
|
|
||||||
|
|
||||||
self.register_action('wlan' , self.nmtui)
|
|
||||||
self.register_action('pavu', self.pavu)
|
self.register_action('pavu', self.pavu)
|
||||||
|
|
||||||
|
if common.hostname() != 'kubaDesktop':
|
||||||
|
self.wlan_load = parser.IconTextUnit('wlan_load', action='wlan', order=13)
|
||||||
|
self.register_action('wlan', self.nmtui)
|
||||||
|
self._parse_data = self._parse_data_w_wlan
|
||||||
|
else:
|
||||||
|
self._parse_data = self._parse_data_wo_wlan
|
||||||
|
|
||||||
|
|
||||||
def _stop_module(self):
|
def _stop_module(self):
|
||||||
if self.p_handle is not None:
|
if self.p_handle is not None:
|
||||||
self.p_handle.terminate()
|
self.p_handle.terminate()
|
||||||
|
|
||||||
|
|
||||||
def _parse_data(self, data):
|
def _parse_data_w_wlan(self, data):
|
||||||
# wlan and eth
|
# wlan and eth
|
||||||
(wland_v, wlanu_v) = format_load(data[1:3], self.wlan_load, config.net_alert)
|
(wland_v, wlanu_v) = format_load(data[1:3], self.wlan_load, config.net_alert)
|
||||||
self.wlan_load.items = [(config.icon_wlan + config.icon_dl, wland_v)
|
self.wlan_load.items = [(config.icon_wlan + config.icon_dl, wland_v)
|
||||||
@@ -239,6 +248,18 @@ ${else}down down${endif}\
|
|||||||
config.icon_vol_low if vol < 50 else config.icon_vol
|
config.icon_vol_low if vol < 50 else config.icon_vol
|
||||||
self.volume.items = [(icon_v, vols)]
|
self.volume.items = [(icon_v, vols)]
|
||||||
|
|
||||||
|
def _parse_data_wo_wlan(self, data):
|
||||||
|
(ethd_v, ethu_v) = format_load(data[1:3], self.eth_load, config.net_alert)
|
||||||
|
self.eth_load.items = [(config.icon_eth + config.icon_dl, ethd_v)
|
||||||
|
,(config.icon_ul, ethu_v)]
|
||||||
|
|
||||||
|
# Volume
|
||||||
|
mute = data[0] == 'MUTE' or data[0] == 'NONE'
|
||||||
|
(vol,vols) = (-1,'×') if mute else (int(data[0]), data[0]+'%')
|
||||||
|
icon_v = config.icon_vol_mute if vol == 0 else \
|
||||||
|
config.icon_vol_low if vol < 50 else config.icon_vol
|
||||||
|
self.volume.items = [(icon_v, vols)]
|
||||||
|
|
||||||
def nmtui(self):
|
def nmtui(self):
|
||||||
p = subprocess.Popen(['xterm', '-class', 'FLOAT_TERM', '-e', 'nmtui'])
|
p = subprocess.Popen(['xterm', '-class', 'FLOAT_TERM', '-e', 'nmtui'])
|
||||||
common.kill_on_unfocus.append(p.pid)
|
common.kill_on_unfocus.append(p.pid)
|
||||||
|
|||||||
Reference in New Issue
Block a user