Move htop and pavu actions to modules
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import threading
|
||||
import subprocess
|
||||
import contextlib
|
||||
import os, getpass
|
||||
import os, signal, getpass
|
||||
|
||||
import i3_lemonbar_config as config
|
||||
import i3_lemonbar_common as common
|
||||
@@ -52,7 +52,6 @@ class LemonModule(threading.Thread):
|
||||
if (keyword in self.actions):
|
||||
func = self.actions[keyword]
|
||||
func()
|
||||
# TODO If this is a floating window action, save handle to thread, so we may kill it
|
||||
|
||||
def format_load(data, module, alert):
|
||||
# Helper function to format network modules
|
||||
@@ -97,6 +96,8 @@ class ConkyFastModule(LemonModule):
|
||||
parser.g_parser.register_unit(self.time)
|
||||
|
||||
self.register_action('wlan', self.nmtui)
|
||||
self.register_action('load', self.htop)
|
||||
self.register_action('pavu', self.pavu)
|
||||
def _stop_module(self):
|
||||
if self.p_handle is not None:
|
||||
self.p_handle.terminate()
|
||||
@@ -129,7 +130,16 @@ class ConkyFastModule(LemonModule):
|
||||
self.time.items = [('', data[3] if common.show_secs else data[3][:-3])]
|
||||
|
||||
def nmtui(self):
|
||||
subprocess.Popen(['xterm', '-class', 'FLOAT_TERM', '-e', 'nmtui'])
|
||||
p = subprocess.Popen(['xterm', '-class', 'FLOAT_TERM', '-e', 'nmtui'])
|
||||
common.kill_on_unfocus.append(p.pid)
|
||||
|
||||
def htop(self):
|
||||
p = subprocess.Popen(['xterm', '-class', 'FLOAT_TERM', '-e', 'htop'])
|
||||
common.kill_on_unfocus.append(p.pid)
|
||||
|
||||
def pavu(self):
|
||||
p = subprocess.Popen(['pavucontrol', '--class=FLOAT_PAVU'])
|
||||
common.kill_on_unfocus.append(p.pid)
|
||||
|
||||
class ConkySlowModule(LemonModule):
|
||||
|
||||
@@ -347,10 +357,9 @@ class i3Module(LemonModule):
|
||||
if i3ws.focused_window is None:
|
||||
return
|
||||
|
||||
role = i3ws.focused_window.window_role
|
||||
wclass = i3ws.focused_window.window_class
|
||||
|
||||
if role != 'FLOAT_TERM' and wclass != 'FLOAT_PAVU' and wclass != 'YADWINBR':
|
||||
if wclass != 'FLOAT_TERM' and wclass != 'FLOAT_PAVU' and wclass != 'YADWINBR':
|
||||
# Is there a window that the bar has opened?
|
||||
for pid in common.kill_on_unfocus:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user