Move htop and pavu actions to modules
This commit is contained in:
@@ -25,9 +25,6 @@ for_window [class="FLOAT_PAVU"] move absolute position $pavuX px $
|
||||
for_window [class="FLOAT_TERM"] floating enable
|
||||
for_window [class="FLOAT_TERM"] move absolute position $htopX px $below_barY px
|
||||
for_window [class="FLOAT_TERM"] border pixel 3
|
||||
for_window [window_role="FLOAT_TERM"] floating enable
|
||||
for_window [window_role="FLOAT_TERM"] move absolute position $htopX px $below_barY px
|
||||
for_window [window_role="FLOAT_TERM"] border pixel 3
|
||||
for_window [title="Memory"] floating enable
|
||||
for_window [class="Matplotlib"] floating enable
|
||||
for_window [class="Chromium"] border pixel 0
|
||||
|
||||
@@ -24,23 +24,11 @@ class bar_mode(Enum):
|
||||
|
||||
mode = bar_mode.normal
|
||||
|
||||
floatterm_args = lambda prog : ['terminator', '-r', 'FLOAT_TERM', '-p'
|
||||
, 'dark', '-e', 'exec {}'.format(prog)] # TODO implement kill on lost focus
|
||||
def date_comm(args):
|
||||
subprocess.Popen(['yad', '--no-buttons', '--calendar', '--sticky'
|
||||
, '--on-top' , '--class' , '"YADWIN"', '--posx=1650', '--posy=24'
|
||||
, '--close-on-unfocus'])
|
||||
|
||||
def pavu_comm(args):
|
||||
global kill_on_unfocus
|
||||
p = subprocess.Popen(['pavucontrol', '--class=FLOAT_PAVU'])
|
||||
kill_on_unfocus.append(p.pid)
|
||||
|
||||
def htop_comm(args):
|
||||
subprocess.Popen(floatterm_args('htop'))
|
||||
|
||||
def nmtui_comm(args):
|
||||
subprocess.Popen(floatterm_args('nmtui'))
|
||||
def lang_comm(args):
|
||||
subprocess.Popen(['sh', '/home/kuba/.i3/scripts/lang.sh', 'next'])
|
||||
def dpms_comm(args):
|
||||
@@ -49,9 +37,6 @@ def adj_br(args):
|
||||
subprocess.Popen(['/home/kuba/.i3/scripts/adjbr.sh', '-b', config.fifo_file_executor])
|
||||
def i3msg_comm(args):
|
||||
subprocess.Popen(args.split())
|
||||
def add_tokill(args):
|
||||
global kill_on_unfocus
|
||||
kill_on_unfocus.append(int(args.split()[1]))
|
||||
def set_mode(args):
|
||||
global mode
|
||||
new_mode = args.split()[1]
|
||||
@@ -84,13 +69,9 @@ def set_lang(args):
|
||||
|
||||
commands_dict = {'toggle_secs': toggle_secs
|
||||
,'date': date_comm
|
||||
,'pavu': pavu_comm
|
||||
,'load': htop_comm
|
||||
#,'wlan': nmtui_comm
|
||||
,'dpms': dpms_comm
|
||||
,'i3-msg': i3msg_comm
|
||||
,'switch_lang': lang_comm
|
||||
,'kill_unfocus': add_tokill
|
||||
,'mode': set_mode
|
||||
,'adj_br': adj_br
|
||||
,'setlang': set_lang
|
||||
|
||||
@@ -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