diff --git a/.i3/home.config b/.i3/home.config index 71e0d4d..01b6041 100644 --- a/.i3/home.config +++ b/.i3/home.config @@ -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"] border pixel 3 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"] move absolute position $htopX px $below_barY px for_window [window_role="FLOAT_TERM"] border pixel 3 diff --git a/.i3/lemonbar/i3_lemonbar_common.py b/.i3/lemonbar/i3_lemonbar_common.py index ebd024a..b832db0 100755 --- a/.i3/lemonbar/i3_lemonbar_common.py +++ b/.i3/lemonbar/i3_lemonbar_common.py @@ -25,8 +25,7 @@ class bar_mode(Enum): mode = bar_mode.normal floatterm_args = lambda prog : ['terminator', '-r', 'FLOAT_TERM', '-p' - , 'dark', '-e', 'echo kill_unfocus $$ > {}; exec {}'.format( - config.fifo_file_executor, prog)] # TODO URGENT solve without fifo + , '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' @@ -76,7 +75,7 @@ def toggle_secs(args): # Keymaps def_keymap = 'pl' -keymaps = {'Firefox': 'se'} +keymaps = {'firefox': 'se'} cur_class = '' def set_lang(args): global keymaps @@ -87,7 +86,7 @@ commands_dict = {'toggle_secs': toggle_secs ,'date': date_comm ,'pavu': pavu_comm ,'load': htop_comm - ,'wlan': nmtui_comm + #,'wlan': nmtui_comm ,'dpms': dpms_comm ,'i3-msg': i3msg_comm ,'switch_lang': lang_comm diff --git a/.i3/lemonbar/i3_lemonbar_launcher.py b/.i3/lemonbar/i3_lemonbar_launcher.py index e8b4400..274fa12 100755 --- a/.i3/lemonbar/i3_lemonbar_launcher.py +++ b/.i3/lemonbar/i3_lemonbar_launcher.py @@ -157,6 +157,7 @@ def exec_commands(): if data[:l] == key: func(data) break + modules.do_action(data.split()[0]) except: common.logger.debug('Exception occured executing command\n Line in: {}\n Data: {}'.format(data, data[l:].split())) diff --git a/.i3/lemonbar/i3_lemonbar_modules.py b/.i3/lemonbar/i3_lemonbar_modules.py index cd3e96a..5db7d50 100644 --- a/.i3/lemonbar/i3_lemonbar_modules.py +++ b/.i3/lemonbar/i3_lemonbar_modules.py @@ -9,10 +9,12 @@ import i3_lemonbar_parser as parser import i3_workspaces as wspaces 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 def __init__(self): + self.actions = {} super().__init__() self._start_module() @@ -43,6 +45,15 @@ class LemonModule(threading.Thread): formatted_line = parser.format_line() # Construct entire 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): # Helper function to format network modules # 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.time) + self.register_action('wlan', self.nmtui) def _stop_module(self): if self.p_handle is not None: self.p_handle.terminate() @@ -116,6 +128,9 @@ class ConkyFastModule(LemonModule): self.date.items = [(config.icon_clock, ' '.join(data[0: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): def __init__(self): @@ -462,9 +477,18 @@ class PowerOptionsModule(LemonModule): , ' Abort (Esc) | System (l) lock, (e) logout, (s) suspend, (h) hibernate' , ', (r) reboot, (Shift+s) shutdown']) -def start_all(): +def do_action(keyword): 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_conky_slow = ConkySlowModule() m_conky_fast = ConkyFastModule() @@ -478,7 +502,7 @@ def start_all(): m_power.start() 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_conky_slow.stop()