summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2015-07-10 05:44:34 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2015-07-10 05:44:34 +0200
commit0a625750329371fb4ee12c05c6a772452a2f906b (patch)
tree8a35b8e14cf84975fc27a219423a7713a0d88807 /bin
parentf91b64f847383c7aa1878d5d92e9ec63b7b2efb5 (diff)
downloaddzen2-config-master.tar.gz
dzen2-config-master.tar.xz
dzen2-config-master.zip
mixer-wrapper: Add script to restart a long runnning amixerHEADmaster
We want a long running amixer, becuase the volume of the left and right channel differ after multiple changes in short time. But on pulseaudio restart we also have to restart amixer or no volume change could be performed anymore.
Diffstat (limited to 'bin')
-rw-r--r--bin/dzen2_pgrp.sh5
-rwxr-xr-xbin/mixer-wrapper.py40
2 files changed, 43 insertions, 2 deletions
diff --git a/bin/dzen2_pgrp.sh b/bin/dzen2_pgrp.sh
index 277a197..61349b1 100644
--- a/bin/dzen2_pgrp.sh
+++ b/bin/dzen2_pgrp.sh
@@ -27,8 +27,9 @@ OFFSET=$((OFFSET - 17))
$DIR/bin/pulse-dbus-receive.py | \
$DZEN2 -xs "$SCREEN" -x "$OFFSET" -tw 17 -w 100 -fn "$FONT" -bg black -sa c -l 1 \
-e "entertitle=uncollapse,unhide;leavetitle=collapse;button2=exec:pavucontrol\
- ;button1=exec:$MIXER toggle;button3=exec:$MIXER 80%\
- ;button4=exec:$MIXER 2%+;button5=exec:$MIXER 2%-" &
+ ;button1=print:sset Master toggle;button3=print:sset Master 80%\
+ ;button4=print:sset Master 2%+;button5=print:sset Master 2%-" |
+ $DIR/bin/mixer-wrapper.py "amixer -s" &
# fill the rest of the screen with the information from xmonad
cat $* | $DZEN2 -xs "$SCREEN" -x 0 -w "$OFFSET" -ta l -fn "$FONT" -bg black -e 'button1=none' &
diff --git a/bin/mixer-wrapper.py b/bin/mixer-wrapper.py
new file mode 100755
index 0000000..1424f36
--- /dev/null
+++ b/bin/mixer-wrapper.py
@@ -0,0 +1,40 @@
+#!/usr/bin/python2
+
+import os
+import select
+import sys
+import subprocess
+import termios
+import pty
+from itertools import chain
+
+def main(cmd=None):
+ (pipe_in, pipe_out) = pty.openpty()
+ pipe = os.fdopen(pipe_in)
+
+ mixer = subprocess.Popen(sys.argv[1], stdin=subprocess.PIPE,
+ stdout=pipe_out, stderr=subprocess.STDOUT,
+ shell=True, bufsize=0, close_fds=True)
+
+ input = iter(sys.stdin.readline, '')
+ if cmd is not None:
+ input = chain([cmd], input)
+
+ for line in input:
+ mixer.stdin.write(b"%s\n" % line)
+ mixer.stdin.flush()
+
+ termios.tcflush(pipe_in, termios.TCIFLUSH)
+ fds = select.select([pipe_in], [], [], 0.2)[0]
+ if len(fds) <= 0:
+ mixer.stdin.close()
+ mixer.wait()
+ if cmd is None or line != cmd:
+ return line
+ return None
+
+
+if __name__ == '__main__':
+ cmd = None
+ while True:
+ cmd = main(cmd)