diff options
-rw-r--r-- | base/Makefile | 2 | ||||
-rw-r--r-- | base/faces/.gitignore | 4 | ||||
-rw-r--r-- | git/Makefile | 2 | ||||
-rw-r--r-- | git/bash-aliases | 9 | ||||
-rw-r--r-- | xmonad/xmonad-session-rc | 14 | ||||
-rw-r--r-- | xmonad/xmonad.hs.gpp | 10 | ||||
-rw-r--r-- | xmonad/xmonad.mk | 3 | ||||
-rw-r--r-- | xorg-xrandr/setres/get.py | 4 | ||||
-rw-r--r-- | xpybar/config/Makefile | 3 | ||||
-rw-r--r-- | xpybar/config/myalsa.py | 16 | ||||
-rw-r--r-- | xpybar/config/mycg.py | 51 | ||||
-rw-r--r-- | xpybar/config/mynetwork.py | 19 | ||||
-rw-r--r-- | xpybar/config/xmonad-monitor.gpp | 62 |
13 files changed, 172 insertions, 27 deletions
diff --git a/base/Makefile b/base/Makefile index d94dd0c..91e64ba 100644 --- a/base/Makefile +++ b/base/Makefile @@ -1,6 +1,6 @@ .POSIX: -FACE = penguin.png +FACE != (cat ../.private/base/face-"$$(hostname)" || cat ../.work/base/face || echo penguin.png) 2>/dev/null XINITRC_ORDER = 90 diff --git a/base/faces/.gitignore b/base/faces/.gitignore new file mode 100644 index 0000000..c747958 --- /dev/null +++ b/base/faces/.gitignore @@ -0,0 +1,4 @@ +* +!/.gitignore +!/gnu-wink.svg +!/penguin.png diff --git a/git/Makefile b/git/Makefile index 4d67fe2..8e57722 100644 --- a/git/Makefile +++ b/git/Makefile @@ -4,7 +4,7 @@ install: mkdir -p -- ~/.config/git test ! -e ~/.config/git/config || test -L ~/.config/git/config test ! -e ~/.config/git/config || test -f ~/.config/git/config - cat config ../.secrets/git/config >> .config + cat config ../.secrets/git/config > .config ln -sf -- ~/.dotfiles/git/.config ~/.config/git/config mkdir -p -- ~/.config/bash/aliases.d test ! -d ~/.config/bash/aliases.d/git diff --git a/git/bash-aliases b/git/bash-aliases index 3552668..3b19a26 100644 --- a/git/bash-aliases +++ b/git/bash-aliases @@ -7,15 +7,6 @@ gitcomm () { git commit --signoff -S"$GPG_KEY" -m "$*" } -ge () { - if [ -z "$EDITOR" ]; then - printf '\e[1;31m%s\e[0m\n' 'No default editor is set, please configure the environment variable EDITOR' - else - $EDITOR -- "$@" - git add -- "$@" - fi -} - gitpush () { git push -u origin `___git_branch_` } diff --git a/xmonad/xmonad-session-rc b/xmonad/xmonad-session-rc new file mode 100644 index 0000000..f61a512 --- /dev/null +++ b/xmonad/xmonad-session-rc @@ -0,0 +1,14 @@ +# -*- shell-script -*- + +if test -z "${default_session}"; then # Guard from inclusion from xinit + + SESSION=xmonad + export DESKTOP_SESSION="$SESSION" + + # Apply package specific settings and run package specific programs + for f in ~/.config/X11/xinit/xinitrc.d/*; do + if test -r "$f"; then + . -- "$f" + fi + done +fi diff --git a/xmonad/xmonad.hs.gpp b/xmonad/xmonad.hs.gpp index 6a9358e..7a6f960 100644 --- a/xmonad/xmonad.hs.gpp +++ b/xmonad/xmonad.hs.gpp @@ -54,12 +54,16 @@ import qualified Data.Map as M $$< + hostname="$(hostname | tr '[[:upper:]]' '[[:lower:]]')" + workspace_1=main - if test "$(hostname | tr '[[:upper:]]' '[[:lower:]]')" = zenith; then + if test "$hostname" = zenith; then workspace_7=chat workspace_8=mail + workspace_9=media + else + workspace_9=off fi - workspace_9=media modmask=mod4Mask # Super_L focus_on_hover=True @@ -163,6 +167,8 @@ $$>fi {-- TODO , (( $${modmask} .|. shiftMask , xK_m), sendMessage RestoreNextMinimizedWin) --} ] +{-- TODO preselect workspace 9 on secondary monitor --} + ---- ==== Layout settings ==== ---- ratios = [ toRational (2/(1 + sqrt 5 :: Double)) -- golden ratio diff --git a/xmonad/xmonad.mk b/xmonad/xmonad.mk index 65acabf..29d52bb 100644 --- a/xmonad/xmonad.mk +++ b/xmonad/xmonad.mk @@ -1,3 +1,6 @@ xmonad.hs: xmonad.hs.gpp xmonad.mk + @touch -- ~/.xmonad/xmonad.hs + @chmod -- +w ~/.xmonad/xmonad.hs gpp -s '$$$$' < xmonad.hs.gpp > ~/.xmonad/xmonad.hs xmonad --recompile + @chmod -- a-w ~/.xmonad/xmonad.hs diff --git a/xorg-xrandr/setres/get.py b/xorg-xrandr/setres/get.py index 47a6428..6f5682b 100644 --- a/xorg-xrandr/setres/get.py +++ b/xorg-xrandr/setres/get.py @@ -31,6 +31,8 @@ class XScreen: class XConnector: def __init__(self, line): line = line.split(' ') + self.want_mode = None + self.want_rate = None self.name = line[0] self.connected = line[1] == 'connected' self.primary = False @@ -197,7 +199,7 @@ def get_setup(): for line in xrandr_output: if on_edid and line.startswith('\t\t') and ':' not in line: - connector.edid += line.replace(' ', '') + connector.edid += line.replace(' ', '').replace('\t', '') on_edid = None elif transx is not None: transx.append(line.strip()) diff --git a/xpybar/config/Makefile b/xpybar/config/Makefile index dc444aa..b5ce07a 100644 --- a/xpybar/config/Makefile +++ b/xpybar/config/Makefile @@ -3,6 +3,9 @@ all: xmonad-monitor xmonad-monitor: xmonad-monitor.gpp + @touch -- $@ + @chmod -- +w $@ gpp -s '%%' < $@.gpp > $@ + @chmod -- a-w $@ .PHONY: all diff --git a/xpybar/config/myalsa.py b/xpybar/config/myalsa.py index 14b8a7b..552c459 100644 --- a/xpybar/config/myalsa.py +++ b/xpybar/config/myalsa.py @@ -1,10 +1,11 @@ # -*- python -*- from plugins.alsa import ALSA +import alsaaudio from common import * class MyALSA(Entry): - def __init__(self, *args, timeout = None, sleep = None, cards = -1, mixers = None, colours = {}, **kwargs): ## TODO support multiple cards and all mixers + def __init__(self, *args, timeout = None, sleep = None, cards = -1, mixers = None, colours = {}, prefix = '', **kwargs): ## TODO support multiple cards and all mixers self.colours = colours if colours is not None else {} if timeout is not None: self.timeout = timeout @@ -27,7 +28,12 @@ class MyALSA(Entry): else: cards = cards self.alsa = [] + names = {} + for index in alsaaudio.card_indexes(): + for name in alsaaudio.card_name(index): + names[name] = index for card in cards: + card = names.get(card, card) for mixer in mixers: ## TODO support by name (and 'default') try: if isinstance(mixer, tuple) or isinstance(mixer, list): @@ -62,6 +68,7 @@ class MyALSA(Entry): break except: pass + self.prefix = prefix self.sep_width = Bar.coloured_length(SEPARATOR) self.get_volume() self.broadcast_update = None @@ -71,6 +78,9 @@ class MyALSA(Entry): xasync((self.refresh_bus, self.refresh_posix_ipc, self.refresh_cmdipc, self.refresh_wait)[method], name = 'alsa') def action(self, col, button, x, y): + if not self.alsa: + return + mixer = 0 mixer_text = self.text.split(SEPARATOR) while mixer < len(mixer_text): ## the limit is just a precaution @@ -173,8 +183,10 @@ class MyALSA(Entry): def get_volume(self): text_v = lambda v : '--%' if v is None else ('%2i%%' % v)[:3] - read_m = lambda m : '%s: %s' % (m.mixername, ' '.join(text_v(v) for v in m.get_volume())) + read_m = lambda m : '%s%s: %s' % (self.prefix, m.mixername, ' '.join(text_v(v) for v in m.get_volume())) text = SEPARATOR.join((self.get_exclusive(m) if isinstance(m, list) else read_m(m)) for m in self.alsa) + if not text: + text = '%s%s' % (self.prefix, 'disconnected') self.text = text def refresh_bus(self): diff --git a/xpybar/config/mycg.py b/xpybar/config/mycg.py new file mode 100644 index 0000000..5b5edee --- /dev/null +++ b/xpybar/config/mycg.py @@ -0,0 +1,51 @@ +# -*- python -*- +from common import * + +class MyCG(Entry): + def __init__(self, title, command, cg_class, *args, priority = None, **kwargs): + self.title = title + self.cg_class = cg_class + rule = '::'.join(cg_class.split('::')[2:]) + self.start_command = [command, '-R', rule] + if priority is not None: + self.start_command.extend(['-p', str(priority)]) + self.stop_command = [command, '-R', rule, '-x'] + Entry.__init__(self, *args, **kwargs) + + def action(self, col, button, x, y): + proc = subprocess.Popen(['cg-query', '-c', '?'], stdout = subprocess.PIPE) + output = [] + while True: + chunk = proc.stdout.read(128) + if not chunk: + break + output.append(chunk) + proc.stdout.close() + proc.wait() + output = b''.join(output).decode('utf-8', 'replace') + crtcs = output.split('\n') + output = [] + for crtc in crtcs: + if not crtc: + continue + proc = subprocess.Popen(['cg-query', '-c', crtc], stdout = subprocess.PIPE) + while True: + chunk = proc.stdout.read(128) + if not chunk: + break + output.append(chunk) + proc.stdout.close() + proc.wait() + output = b''.join(output).decode('utf-8', 'replace') + active = ('\n Class: %s\n' % self.cg_class) in output + del output + print(active) + print(repr(self.stop_command if active else self.start_command)) + subprocess.Popen(self.stop_command if active else self.start_command).wait() + + def function(self): + return self.title + +class MyCGNegative(MyCG): + def __init__(self, *args, title = 'Negative', rule = 'xpybar', priority = None, **kwargs): + MyCG.__init__(self, title, 'cg-negative', 'cg-tools::cg-negative::' + rule, *args, priority = priority, **kwargs) diff --git a/xpybar/config/mynetwork.py b/xpybar/config/mynetwork.py index 79cd271..ca4e18b 100644 --- a/xpybar/config/mynetwork.py +++ b/xpybar/config/mynetwork.py @@ -5,7 +5,7 @@ from plugins.ping import Ping from common import * class MyNetwork(Entry): - def __init__(self, *args, limits = None, ignore = None, pings = None, **kwargs): + def __init__(self, *args, limits = None, ignore = None, pings = None, renamemap = None, **kwargs): self.limits = { 'rx_bytes' : None # Download speed in bytes (not bits) , 'tx_bytes' : None # Upload speed in bytes (not bits) , 'rx_total' : None # Download cap in bytes @@ -25,7 +25,8 @@ class MyNetwork(Entry): self.pings[nic] = ping[nic] else: self.pings[nic] += ping[nic] - self.ignore = ['lo'] if ignore is None else ignore + self.ignore = ['lo'] if ignore is None else list(ignore) + self.renamemap = renamemap self.net_time = time.monotonic() self.net_last = {} self.show_all = True @@ -36,6 +37,15 @@ class MyNetwork(Entry): 'carrier', 'compressed', 'multicast'] self.in_bytes = False # in bits if showing total Entry.__init__(self, *args, **kwargs) + + def networkOK(self, name): + if name.startswith("docker"): + return False + if name.startswith("zcctun"): + return False + if name.startswith("veth"): + return False + return True; def action(self, col, button, x, y): if button == LEFT_BUTTON: @@ -144,6 +154,7 @@ class MyNetwork(Entry): net_now = time.monotonic() net_tdiff, self.net_time = net_now - self.net_time, net_now network = Network(*self.ignore).devices + network = {self.renamemap.get(dev, dev): stat for dev, stat in network.items() if self.networkOK(dev)} label = self.labels[self.show_value] show_total = label == 'total' show_bytes = label == 'bytes' @@ -184,9 +195,9 @@ class MyNetwork(Entry): return ret if self.show_all: if self.show_name: - net = [create(dev, dev) for dev in network] + net = [create(dev, dev) for dev in network if dev] else: - net = [create(None, dev) for dev in network] + net = [create(None, dev) for dev in network if dev] net = (SEPARATOR if self.show_name else ' ').join(net) else: devsum = {} 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_() |