Changeset - e38429c283bc
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 20 months ago 2023-06-04 01:30:58
drewp@bigasterisk.com
make service namaes more visible in terminal titles
1 file changed with 5 insertions and 0 deletions:
0 comments (0 inline, 0 general)
light9/run_local.py
Show inline comments
 
# bootstrap
 

	
 
import re
 
import logging
 
import os
 
import socket
 
import sys
 
from colorsys import hsv_to_rgb
 

	
 
import coloredlogs
 

	
 
try:
 
    import faulthandler
 
    faulthandler.enable()
 
except ImportError:
 
@@ -36,23 +37,27 @@ coloredlogs.install(
 
    level_styles={
 
        'debug': dict(color=115),
 
        'info': dict(color=250),
 
        'warning': dict(color=208),
 
        'error': dict(color=161),
 
        'critical': dict(color=196),
 
    },
 
)
 

	
 

	
 
def setTerminalTitle(s):
 
    if os.environ.get('TERM', '') in ['xterm', 'rxvt', 'rxvt-unicode-256color']:
 
        m = re.search(r'(light9\..*):', s)
 
        if m is not None:
 
            s = m.group(1)
 
        s = s.replace('/home/drewp/own/proj/','')
 
        print("\033]0;%s\007" % s)  # not escaped/protected correctly
 
        hue = (hash(progName) % 255) / 255
 
        r, g, b = [int(x * 255) for x in hsv_to_rgb(hue, s=.2, v=.1)]
 
        print(f"\033]11;#{r:02x}{g:02x}{b:02x}\007")
 

	
 

	
 
if 'listsongs' not in sys.argv[0] and 'homepageConfig' not in sys.argv[0]:
 
    setTerminalTitle('[%s] %s' % (socket.gethostname(), ' '.join(sys.argv).replace('bin/', '')))
 

	
 
# see http://www.youtube.com/watch?v=3cIOT9kM--g for commands that make
 
# profiles and set background images
0 comments (0 inline, 0 general)