lemonbar: Some progress with screen

This commit is contained in:
kuben
2019-08-07 21:54:47 +02:00
parent fc82366233
commit 0b0b6382e0
2 changed files with 21 additions and 14 deletions

View File

@@ -3,7 +3,6 @@ from enum import Enum
import i3_lemonbar_config as config import i3_lemonbar_config as config
p_screen = None
kill_on_unfocus = [] kill_on_unfocus = []
# Loggers, initialized in main function # Loggers, initialized in main function
@@ -21,7 +20,8 @@ class bar_mode(Enum):
mode = bar_mode.normal mode = bar_mode.normal
screen_args = ['screen', '-D', '-R', '-U' '-S' 'lemonbar'] screen_args = ['screen', '-d', '-m', '-U', '-S', 'lemonbar'
, '-L', '-Logfile', config.fifo_screen_log]
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', 'echo kill_unfocus $$ > {}; exec {}'.format(
@@ -65,16 +65,17 @@ def set_mode(args):
def bluetooth(args): def bluetooth(args):
btcargs = args.split()[1:] btcargs = args.split()[1:]
btcargs = [a.replace('pxc550', '00:16:94:22:29:0E') for a in btcargs] btcargs = [a.replace('pxc550', '00:16:94:22:29:0E') for a in btcargs]
btcargs.append('\n')
inp = ' '.join(btcargs) inp = ' '.join(btcargs)
p_screen.stdin.write(inp) stuff_screen(inp)
p_screen.stdin.flush()
show_secs = False show_secs = False
def toggle_secs(args): def toggle_secs(args):
global show_secs global show_secs
show_secs = not show_secs show_secs = not show_secs
def stuff_screen(cmd):
subprocess.run(['screen', '-S', 'lemonbar', '-X', 'stuff', "echo " + cmd + "\\n"])
# Keymaps # Keymaps
def_keymap = 'pl' def_keymap = 'pl'
keymaps = {'Firefox': 'se'} keymaps = {'Firefox': 'se'}

View File

@@ -110,7 +110,7 @@ def clean_up():
nice_delete(config.fifo_file_executor) nice_delete(config.fifo_file_executor)
nice_term(p_conky_slow) nice_term(p_conky_slow)
nice_term(p_conky_fast) nice_term(p_conky_fast)
nice_term(common.p_screen) common.stuff_screen('kill')
if i3_ws_obj is not None: if i3_ws_obj is not None:
i3_ws_obj.quit() i3_ws_obj.quit()
sys.exit(0) sys.exit(0)
@@ -192,20 +192,26 @@ def strip_ansi_unicode(s):
return strip_unicode return strip_unicode
def user_screen(): def user_screen():
# Attach to screen session, creating if needed, in UTF-8 mode # Create screen session, in UTF-8 mode, logging to fifo
common.p_screen = subprocess.Popen(common.screen_args # TODO lemonbar_user create_new_fifo(config.fifo_screen_log)
,stdin=subprocess.PIPE, stdout=subprocess.PIPE, text=True) subprocess.Popen(common.screen_args) # TODO lemonbar_user
for line in common.p_screen.stdout: with open(config.fifo_screen_log, 'r', buffering=1) as screen_read:
#try: while True:
common.logger.debug('Screen read line {}'.format(line.strip('\n'))) try:
line = screen_read.readline()
if not line:
break
common.logger.debug('Screen read line {}'.format(line.strip('\n')))
# with open(config.fifo_file_status, 'w') as fifo: # with open(config.fifo_file_status, 'w') as fifo:
# clean_line = strip_ansi_unicode(line) # clean_line = strip_ansi_unicode(line)
# if (not clean_line.startswith('[bluetooth]') # if (not clean_line.startswith('[bluetooth]')
# and not clean_line.startswith('[CHG]') # and not clean_line.startswith('[CHG]')
# and not clean_line.isspace()): # and not clean_line.isspace()):
# fifo.write('RESP [bluetoothctl] ' + clean_line) # fifo.write('RESP [bluetoothctl] ' + clean_line)
#except: except:
# raise raise
nice_delete(config.fifo_screen_log)
class i3_thread: class i3_thread:
""" Helper class to start and stop threads""" """ Helper class to start and stop threads"""