From 5b7e0db847c46affc207c327835d1efd3b2727de Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 25 Nov 2023 18:08:34 +0100 Subject: Misc updates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- xpybar/config/xmonad-monitor.gpp | 62 +++++++++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 7 deletions(-) (limited to 'xpybar/config/xmonad-monitor.gpp') diff --git a/xpybar/config/xmonad-monitor.gpp b/xpybar/config/xmonad-monitor.gpp index 337e661..4e9d0c4 100644 --- a/xpybar/config/xmonad-monitor.gpp +++ b/xpybar/config/xmonad-monitor.gpp @@ -36,6 +36,7 @@ from myalsa import MyALSA from mybacklight import MyBacklight from mybattery import MyBattery from mybrilliance import MyBrilliance +from mycg import MyCGNegative from myclock import MyClock from mycomputer import MyComputer from mycpu import MyCPU @@ -57,6 +58,9 @@ from myweather import MyWeather from myxmonad import MyXMonad +%%>hostname="$(hostname | tr '[[:upper:]]' '[[:lower:]]')" + + def mqueue_wait(): import posix_ipc qkey = '/.xpybar.' + os.environ['DISPLAY'].split('.')[0] @@ -79,8 +83,23 @@ def mqueue_wait(): myxmonad = MyXMonad(None) myscroll = MyScroll(None) myclock = MyClock (lambda f : Clocked(f, 1), format = '%Y-(%m)%b-%d %T, %a w%V, %Z', long_format = '%Y-%m-%d %T') -mixers = ['Master', 'PCM'] ## TODO -#mixers.append(('Headphone', 'Speaker')) +%%>if iswork; then +with open('/proc/cpuinfo', 'r') as f: + isvm = f.readlines() +isvm = [line.replace('\n', ' ').replace('\t', ' ').split(':') for line in isvm if line] +isvm = any('hypervisor' in ':'.join(line[1:]).split(' ') for line in isvm if line[0].strip().startswith('flags')) +card1 = 'Ensoniq AudioPCI' if isvm else 'HDA Intel PCH' +%%>else +card1 = 'HD-Audio Generic' +%%>fi +mixers1 = ['Master', 'PCM'] ## TODO +%%>if iswork; then +#mixers1.append(('Headphone', 'Speaker')) +if not isvm: + mixers1.extend(('Headphone', 'Speaker')) +%%>fi +card2 = 'Yeti Stereo Microphone' +mixers2 = ['Speaker', 'Mic'] #myii = ... #myirc = ... #from plugins.ii import II @@ -102,8 +121,8 @@ mybattery = MyBattery(None) %%>fi pingthese = [] -%%>if test -r ~/.dotfiles/.secrets/ping-"$(hostname | tr '[[:upper:]]' '[[:lower:]]')"; then -%%> for address in $(cat ~/.dotfiles/.secrets/ping-"$(hostname | tr '[[:upper:]]' '[[:lower:]]')"); do +%%>if test -r ~/.dotfiles/.secrets/ping-"$hostname"; then +%%> for address in $(cat ~/.dotfiles/.secrets/ping-"$hostname"); do pingthese.append(Ping(targets = Ping.get_nics('%%{address}'), interval = 30)) %%> done %%>fi @@ -120,10 +139,29 @@ except: metar_stations = [] metar_stations = [x[0].upper() + x[1:].lower() for x in metar_stations if x != ''] +netrenamemap = { + 'lo' : None, + 'veth42d1872' : None, + 'enxc84bd6ba1a73' : None, + 'enxc84bd6ba1a91' : None, + 'enx00249b1e3c30' : 'Ctrl', + 'ens33' : 'Nat', # VMWare + 'ens37' : 'Ctrl', # VMWare + 'enxc84d44213db2' : 'Home', # USB-C eth+usb dongle + 'enx0050b6cbd51b' : 'Home', # USB-C eth dongle + 'enxb44506e09918' : 'Eth', + 'wlp0s20f3' : 'WiFi' +} +netignorelist = [k for k, v in netrenamemap.items() if v is None] +netrenamemap = {k: v for k, v in netrenamemap.items() if v is not None} + functions = [ [ myxmonad , None , MyTimer (None, alarms = []) - , MyALSA (None, mixers = mixers, colours = {'Speaker' : '31'}) + , MyALSA (None, cards = card1, mixers = mixers1, colours = {'Speaker' : '31'}) +%%>if test "$hostname" = zenith; then + , MyALSA (None, cards = card2, mixers = mixers2, prefix = 'Y.') +%%>fi , MyComputer (lambda f : Clocked(f, 20)) , myscroll , None @@ -131,7 +169,7 @@ functions = [ [ myxmonad , MyCPU (lambda f : Clocked(f, 2)) , MyMemory (lambda f : Clocked(f, 2)) , None - , MyNetwork (lambda f : Clocked(f, 2), pings = pingthese) + , MyNetwork (lambda f : Clocked(f, 2), ignore = netignorelist, pings = pingthese, renamemap = netrenamemap) #, myirc %%>if test -x /usr/bin/featherweight; then , MyNews (None) @@ -141,7 +179,11 @@ functions = [ [ myxmonad ] , [ myxmonad , None +%%>if test "$hostname" = zenith; then , MyIPAddress (lambda f : Clocked(f, 20), public = False) +%%>else + , MyALSA (None, cards = card2, mixers = mixers2, prefix = 'Yeti.') +%%>fi , MyMOC (None) , myscroll , None @@ -151,8 +193,13 @@ functions = [ [ myxmonad #, myii , None , MyStat (lambda f : Clocked(f, 10)) +%%>if test ! "$hostname" = zenith; then + , MyCGNegative() +%%>fi , MyBrilliance(None) - #, MyBacklight (None) +%%>if test ! "$hostname" = zenith; then + , MyBacklight (None) +%%>fi #, MyIO (lambda f : Clocked(f, 10), fs_ignore = []) ] ] @@ -176,6 +223,7 @@ def update_per_clock(): G.semaphore.release() invalidate() + start_ = start def start(): start_() -- cgit v1.2.3-70-g09d2