Start implementing actions in modules. Change terminator to xterm as it doesnt spawn another child process
This commit is contained in:
@@ -22,6 +22,9 @@ for_window [class="FLOAT_PAVU"] floating enable
|
|||||||
for_window [class="FLOAT_PAVU"] resize set 800 540
|
for_window [class="FLOAT_PAVU"] resize set 800 540
|
||||||
for_window [class="FLOAT_PAVU"] border pixel 3
|
for_window [class="FLOAT_PAVU"] border pixel 3
|
||||||
for_window [class="FLOAT_PAVU"] move absolute position $pavuX px $below_barY px
|
for_window [class="FLOAT_PAVU"] move absolute position $pavuX px $below_barY 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"] floating enable
|
||||||
for_window [window_role="FLOAT_TERM"] move absolute position $htopX px $below_barY px
|
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 [window_role="FLOAT_TERM"] border pixel 3
|
||||||
|
|||||||
@@ -25,8 +25,7 @@ class bar_mode(Enum):
|
|||||||
mode = bar_mode.normal
|
mode = bar_mode.normal
|
||||||
|
|
||||||
floatterm_args = lambda prog : ['terminator', '-r', 'FLOAT_TERM', '-p'
|
floatterm_args = lambda prog : ['terminator', '-r', 'FLOAT_TERM', '-p'
|
||||||
, 'dark', '-e', 'echo kill_unfocus $$ > {}; exec {}'.format(
|
, 'dark', '-e', 'exec {}'.format(prog)] # TODO implement kill on lost focus
|
||||||
config.fifo_file_executor, prog)] # TODO URGENT solve without fifo
|
|
||||||
def date_comm(args):
|
def date_comm(args):
|
||||||
subprocess.Popen(['yad', '--no-buttons', '--calendar', '--sticky'
|
subprocess.Popen(['yad', '--no-buttons', '--calendar', '--sticky'
|
||||||
, '--on-top' , '--class' , '"YADWIN"', '--posx=1650', '--posy=24'
|
, '--on-top' , '--class' , '"YADWIN"', '--posx=1650', '--posy=24'
|
||||||
@@ -76,7 +75,7 @@ def toggle_secs(args):
|
|||||||
|
|
||||||
# Keymaps
|
# Keymaps
|
||||||
def_keymap = 'pl'
|
def_keymap = 'pl'
|
||||||
keymaps = {'Firefox': 'se'}
|
keymaps = {'firefox': 'se'}
|
||||||
cur_class = ''
|
cur_class = ''
|
||||||
def set_lang(args):
|
def set_lang(args):
|
||||||
global keymaps
|
global keymaps
|
||||||
@@ -87,7 +86,7 @@ commands_dict = {'toggle_secs': toggle_secs
|
|||||||
,'date': date_comm
|
,'date': date_comm
|
||||||
,'pavu': pavu_comm
|
,'pavu': pavu_comm
|
||||||
,'load': htop_comm
|
,'load': htop_comm
|
||||||
,'wlan': nmtui_comm
|
#,'wlan': nmtui_comm
|
||||||
,'dpms': dpms_comm
|
,'dpms': dpms_comm
|
||||||
,'i3-msg': i3msg_comm
|
,'i3-msg': i3msg_comm
|
||||||
,'switch_lang': lang_comm
|
,'switch_lang': lang_comm
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ def exec_commands():
|
|||||||
if data[:l] == key:
|
if data[:l] == key:
|
||||||
func(data)
|
func(data)
|
||||||
break
|
break
|
||||||
|
modules.do_action(data.split()[0])
|
||||||
|
|
||||||
except:
|
except:
|
||||||
common.logger.debug('Exception occured executing command\n Line in: {}\n Data: {}'.format(data, data[l:].split()))
|
common.logger.debug('Exception occured executing command\n Line in: {}\n Data: {}'.format(data, data[l:].split()))
|
||||||
|
|||||||
@@ -9,10 +9,12 @@ import i3_lemonbar_parser as parser
|
|||||||
import i3_workspaces as wspaces
|
import i3_workspaces as wspaces
|
||||||
|
|
||||||
class LemonModule(threading.Thread):
|
class LemonModule(threading.Thread):
|
||||||
# Module generates some status message, parses it, and handles on click actions
|
# Module spawns process that generates some status message, which the module parses and
|
||||||
|
# sends to lemonbar queue. On click actions are registered with the module.
|
||||||
# Every module runs in its own thread
|
# Every module runs in its own thread
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.actions = {}
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._start_module()
|
self._start_module()
|
||||||
|
|
||||||
@@ -43,6 +45,15 @@ class LemonModule(threading.Thread):
|
|||||||
formatted_line = parser.format_line() # Construct entire line
|
formatted_line = parser.format_line() # Construct entire line
|
||||||
return formatted_line
|
return formatted_line
|
||||||
|
|
||||||
|
def register_action(self, keyword, do_action):
|
||||||
|
self.actions[keyword] = do_action
|
||||||
|
|
||||||
|
def do_action(self, keyword):
|
||||||
|
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):
|
def format_load(data, module, alert):
|
||||||
# Helper function to format network modules
|
# Helper function to format network modules
|
||||||
# Changes colors scheme to inactive when interfaces are down, or to alert when
|
# Changes colors scheme to inactive when interfaces are down, or to alert when
|
||||||
@@ -85,6 +96,7 @@ class ConkyFastModule(LemonModule):
|
|||||||
parser.g_parser.register_unit(self.date)
|
parser.g_parser.register_unit(self.date)
|
||||||
parser.g_parser.register_unit(self.time)
|
parser.g_parser.register_unit(self.time)
|
||||||
|
|
||||||
|
self.register_action('wlan', self.nmtui)
|
||||||
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()
|
||||||
@@ -116,6 +128,9 @@ class ConkyFastModule(LemonModule):
|
|||||||
self.date.items = [(config.icon_clock, ' '.join(data[0:3]))]
|
self.date.items = [(config.icon_clock, ' '.join(data[0:3]))]
|
||||||
self.time.items = [('', data[3] if common.show_secs else data[3][:-3])]
|
self.time.items = [('', data[3] if common.show_secs else data[3][:-3])]
|
||||||
|
|
||||||
|
def nmtui(self):
|
||||||
|
subprocess.Popen(['xterm', '-class', 'FLOAT_TERM', '-e', 'nmtui'])
|
||||||
|
|
||||||
class ConkySlowModule(LemonModule):
|
class ConkySlowModule(LemonModule):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -462,9 +477,18 @@ class PowerOptionsModule(LemonModule):
|
|||||||
, ' Abort (Esc) | System (l) lock, (e) logout, (s) suspend, (h) hibernate'
|
, ' Abort (Esc) | System (l) lock, (e) logout, (s) suspend, (h) hibernate'
|
||||||
, ', (r) reboot, (Shift+s) shutdown'])
|
, ', (r) reboot, (Shift+s) shutdown'])
|
||||||
|
|
||||||
def start_all():
|
def do_action(keyword):
|
||||||
global m_conky_fast, m_conky_slow, m_i3ws
|
global m_conky_fast, m_conky_slow, m_i3ws
|
||||||
|
|
||||||
|
m_i3ws.do_action(keyword)
|
||||||
|
m_conky_slow.do_action(keyword)
|
||||||
|
m_conky_fast.do_action(keyword)
|
||||||
|
m_screen.do_action(keyword)
|
||||||
|
m_power.do_action(keyword)
|
||||||
|
|
||||||
|
def start_all():
|
||||||
|
global m_conky_fast, m_conky_slow, m_i3ws, m_screen, m_power
|
||||||
|
|
||||||
m_i3ws = i3Module()
|
m_i3ws = i3Module()
|
||||||
m_conky_slow = ConkySlowModule()
|
m_conky_slow = ConkySlowModule()
|
||||||
m_conky_fast = ConkyFastModule()
|
m_conky_fast = ConkyFastModule()
|
||||||
@@ -478,7 +502,7 @@ def start_all():
|
|||||||
m_power.start()
|
m_power.start()
|
||||||
|
|
||||||
def stop_all():
|
def stop_all():
|
||||||
global m_conky_fast, m_conky_slow, m_i3ws
|
global m_conky_fast, m_conky_slow, m_i3ws, m_screen, m_power
|
||||||
|
|
||||||
m_i3ws.stop()
|
m_i3ws.stop()
|
||||||
m_conky_slow.stop()
|
m_conky_slow.stop()
|
||||||
|
|||||||
Reference in New Issue
Block a user