diff options
| author | Mattias Andrée <maandree@kth.se> | 2024-02-18 13:22:42 +0100 | 
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2024-02-18 13:22:42 +0100 | 
| commit | c274475635d410c0e9f812e71d20183cb923cd6b (patch) | |
| tree | 70f59c3b28a36921ea46a93effc565d59e20f43b /xpybar | |
| parent | Add makeenv (diff) | |
| download | dotfiles-c274475635d410c0e9f812e71d20183cb923cd6b.tar.gz dotfiles-c274475635d410c0e9f812e71d20183cb923cd6b.tar.bz2 dotfiles-c274475635d410c0e9f812e71d20183cb923cd6b.tar.xz | |
misc updates
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
| -rw-r--r-- | xpybar/config/myalsa.py | 18 | ||||
| -rw-r--r-- | xpybar/config/xmonad-monitor.gpp | 5 | 
2 files changed, 20 insertions, 3 deletions
| diff --git a/xpybar/config/myalsa.py b/xpybar/config/myalsa.py index 552c459..ef246c0 100644 --- a/xpybar/config/myalsa.py +++ b/xpybar/config/myalsa.py @@ -4,6 +4,11 @@ import alsaaudio  from common import * +class MixerAction: +    def __init__(self, name, action): +        self.name = name +        self.action = action +  class MyALSA(Entry):      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 {} @@ -28,6 +33,7 @@ class MyALSA(Entry):          else:              cards = cards          self.alsa = [] +        self.actions = []          names = {}          for index in alsaaudio.card_indexes():              for name in alsaaudio.card_name(index): @@ -36,6 +42,11 @@ class MyALSA(Entry):              card = names.get(card, card)              for mixer in mixers: ## TODO support by name (and 'default')                  try: +                    if isinstance(mixer, MixerAction): +                        self.actions.append(mixer.action) +                        mixer = mixer.name +                    else: +                        self.actions.append(None)                      if isinstance(mixer, tuple) or isinstance(mixer, list):                          self.alsa.append([ALSA(card, m) for m in mixer])                      else: @@ -112,7 +123,8 @@ class MyALSA(Entry):                      channel = -1                      break                  col -= 1 -         + +        action = self.actions[mixer]          mixer = self.alsa[mixer]          if isinstance(mixer, list):              if button == LEFT_BUTTON: @@ -125,6 +137,10 @@ class MyALSA(Entry):              volume = mixer.get_volume()              volume = limited(sum(volume) / len(volume))              mixer.set_volume(volume, -1) +        elif button == MIDDLE_BUTTON: +            if action is not None: +                print('middle click: ' + str(action is not None)) +                action()          elif button in (SCROLL_UP, SCROLL_DOWN):              volume = mixer.get_volume()              adj = -5 if button == SCROLL_DOWN else 5 diff --git a/xpybar/config/xmonad-monitor.gpp b/xpybar/config/xmonad-monitor.gpp index 4e9d0c4..df42701 100644 --- a/xpybar/config/xmonad-monitor.gpp +++ b/xpybar/config/xmonad-monitor.gpp @@ -32,7 +32,7 @@ G.TERMINAL        = 'xterm'  G.OUTPUT, G.HEIGHT_PER_LINE, G.YPOS, G.TOP = 0, 12, 0, True  G.FONT = '-misc-fixed-medium-r-normal-*-10-*-*-*-c-*-iso10646-1' -from myalsa       import MyALSA +from myalsa       import MyALSA, MixerAction  from mybacklight  import MyBacklight  from mybattery    import MyBattery  from mybrilliance import MyBrilliance @@ -96,7 +96,8 @@ mixers1   = ['Master', 'PCM'] ## TODO  %%>if iswork; then  #mixers1.append(('Headphone', 'Speaker'))  if not isvm: -	mixers1.extend(('Headphone', 'Speaker')) +	mixers1.append(MixerAction('Headphone', lambda : spawn_read('headphones'))) +	mixers1.append(MixerAction('Speaker', lambda : spawn_read('speakers')))  %%>fi  card2 = 'Yeti Stereo Microphone'  mixers2 = ['Speaker', 'Mic'] | 
