X-Git-Url: https://code.delx.au/mediapc-tools/blobdiff_plain/51e8b17f9f6f1f6f4fde0b943290186efd9db7f9..1c7fa10015a5f6970bc0e8de76fe02ced5edb430:/mediawrap diff --git a/mediawrap b/mediawrap index 7377c69..312072a 100755 --- a/mediawrap +++ b/mediawrap @@ -1,53 +1,17 @@ #!/bin/bash LOCKFILE="$HOME/.mediawrap.lock" -PULSESTATE="$HOME/.pulseaudio.state" ( if ! flock -w 10 -x 200; then echo "Failed to get a lock!" exit 1 fi -echo "got lock" - -# Unmute everything and turn volume to full -if [ "$1" = "--max-volume" ]; then - echo "max volume" - max_volume=1 - shift - pacmd 'dump' | grep 'set-sink' > "$PULSESTATE" - cat "$PULSESTATE" | grep 'set-sink-mute' | awk '{print $2;}' | \ - while read device; do - pacmd "set-sink-volume $device 0x10000" > /dev/null - pacmd "set-sink-mute $device no" > /dev/null - done -fi - -# Switch volume keys to F9/F10 with xmodmap -if [ "$1" = "--switch-volume-keys" ]; then - echo "switch volume" - switch_volume=1 - shift - xmodmap -e 'keycode 122 = F9' - xmodmap -e 'keycode 123 = F10' -fi - # Run the program "$@" &> /dev/null -# Restore volume levels and mute status -if [ -n "$max_volume" ]; then - cat "$PULSESTATE" | pacmd > /dev/null -fi - -# Restore volume keys -if [ -n "$switch_volume" ]; then - xmodmap -e 'keycode 122 = XF86AudioLowerVolume' - xmodmap -e 'keycode 123 = XF86AudioRaiseVolume' -fi - ) 200>"$LOCKFILE" # Cleanup so other programs can start