X-Git-Url: https://code.delx.au/mediapc-tools/blobdiff_plain/d36a7975982dae6c8e80d5e327e25a5b73237d0c..1c7fa10015a5f6970bc0e8de76fe02ced5edb430:/mediawrap diff --git a/mediawrap b/mediawrap index ac71287..312072a 100755 --- a/mediawrap +++ b/mediawrap @@ -1,29 +1,19 @@ #!/bin/bash -PULSESTATE="$HOME/.pulseaudio.state" -KEYPATH="/apps/gnome_settings_daemon/keybindings" +LOCKFILE="$HOME/.mediawrap.lock" -# Disable volume keys -gconftool --set --type string "$KEYPATH/volume_up" '' -gconftool --set --type string "$KEYPATH/volume_down" '' -gconftool --set --type string "$KEYPATH/volume_mute" '' - -# Unmute everything and turn volume to full -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 +( +if ! flock -w 10 -x 200; then + echo "Failed to get a lock!" + exit 1 +fi # Run the program -"$@" +"$@" &> /dev/null + -# Restore volume levels and mute status -cat "$PULSESTATE" | pacmd > /dev/null +) 200>"$LOCKFILE" -# Enable volume keys -gconftool --set --type string "$KEYPATH/volume_up" 'XF86AudioRaiseVolume' -gconftool --set --type string "$KEYPATH/volume_down" 'XF86AudioLowerVolume' -gconftool --set --type string "$KEYPATH/volume_mute" 'XF86AudioMute' +# Cleanup so other programs can start +rm -f "$LOCKFILE"