]> code.delx.au - mediapc-tools/commitdiff
mediawrap: wait for pidfile
authorJames Bunton <jamesbunton@fastmail.fm>
Sun, 2 Jan 2011 13:02:25 +0000 (00:02 +1100)
committerJames Bunton <jamesbunton@fastmail.fm>
Sun, 2 Jan 2011 13:02:25 +0000 (00:02 +1100)
mediawrap

index ac712873a6aef3feafcf1d771db2cf6e32a43bf9..7a19264bcb05222c5c7a9995d111fc61ede4dd0a 100755 (executable)
--- a/mediawrap
+++ b/mediawrap
@@ -1,8 +1,19 @@
 #!/bin/bash
 
+PIDFILE="$HOME/.mediawrap.pid"
 PULSESTATE="$HOME/.pulseaudio.state"
 KEYPATH="/apps/gnome_settings_daemon/keybindings"
 
+while true; do
+       if [ ! -r "$PIDFILE" ]; then
+               break
+       fi
+       if [ "$(ps -o cmd= -p "$(cat "$PIDFILE")" | wc -l)" -eq 0 ]; then
+               break
+       fi
+       sleep 0.5
+done
+
 # Disable volume keys
 gconftool --set --type string "$KEYPATH/volume_up" ''
 gconftool --set --type string "$KEYPATH/volume_down" ''
@@ -27,3 +38,5 @@ gconftool --set --type string "$KEYPATH/volume_up" 'XF86AudioRaiseVolume'
 gconftool --set --type string "$KEYPATH/volume_down" 'XF86AudioLowerVolume'
 gconftool --set --type string "$KEYPATH/volume_mute" 'XF86AudioMute'
 
+rm -f "$PIDFILE"
+