diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2012-10-15 18:59:31 -0400 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2012-10-15 20:22:27 -0400 |
commit | b18a02654e2c8b4a91f7c97352b75464e24c6edb (patch) | |
tree | c25981c27e6c31b47406bb138c219491cac65a88 | |
parent | 198455ac623054f46b4da3fec040fb7cb0494ce1 (diff) |
wmii: redo the mount/unmount and quit code
-rw-r--r-- | .wmii/config.sh | 28 | ||||
-rw-r--r-- | .wmii/util.sh | 7 | ||||
-rwxr-xr-x | .wmii/wmiirc | 9 |
3 files changed, 27 insertions, 17 deletions
diff --git a/.wmii/config.sh b/.wmii/config.sh index 58217fa..4c2da38 100644 --- a/.wmii/config.sh +++ b/.wmii/config.sh @@ -28,9 +28,8 @@ Event() { ## Custom (non-WMII-generated) events WmiircStart) ## No args echo ' ==> Starting wmiirc' - 9umount "$WMII_DIR" &>/dev/null # just in case - mkdir -p "$WMII_DIR" - 9mount -i "unix!$WMII_NAMESPACE/wmii" "$WMII_DIR" + is_mounted $WMII_DIR && Event WmiircUnmount + Event WmiircMount # Configure wmii < "`conffile tagrules`" expand_variables >> $WMII_DIR/tagrules @@ -54,15 +53,24 @@ Event() { Action autostart 2>/dev/null & ;; WmiircQuit) ## No args - Event Quit;; - ## WMII-meta events - Quit) ## No args echo ' ==> Stopping wmiirc' - echo " -> unmounting WMII_DIR=$WMII_DIR..." - 9umount "$WMII_DIR" - echo " -> rmdir'ing WMII_DIR=$WMII_DIR..." - rmdir "$WMII_DIR" exit;; + WmiircMount) ## No args + echo " -> Creating mountpoint WMII_DIR=$WMII_DIR..." + mkdir -p "$WMII_DIR" + echo " -> Mounting WMII_DIR=$WMII_DIR..." + 9mount -i "unix!$WMII_NAMESPACE/wmii" "$WMII_DIR";; + WmiircUnmount) ## No args + echo " -> Unmounting WMII_DIR=$WMII_DIR..." + 9umount "$WMII_DIR" + echo " -> Removing mountpoint WMII_DIR=$WMII_DIR..." + rmdir "$WMII_DIR";; + ## WMII-meta events + Quit) ## No args + echo ' ==> wmii quit: unmounting' + trap - EXIT + Event WmiircUnmount + Event WmiircQuit;; Warning) ## $@=string notify-send "wmii warning: $*";; Key) ## $1=keystroke diff --git a/.wmii/util.sh b/.wmii/util.sh index 3234783..43d7d4a 100644 --- a/.wmii/util.sh +++ b/.wmii/util.sh @@ -31,6 +31,13 @@ expand_variables() { done } +is_mounted() { + dir="$(readlink -m $1)" + mntpnt="$(cut -d' ' -f2 /proc/mounts|grep -- "$dir")" + [[ $dir = "$mntpnt" ]] + return $? +} + ################################################################################ # PATH manipulation # ################################################################################ diff --git a/.wmii/wmiirc b/.wmii/wmiirc index c513cd1..1f1ea18 100755 --- a/.wmii/wmiirc +++ b/.wmii/wmiirc @@ -1,17 +1,12 @@ #!/bin/bash . "$HOME/.wmii/include.sh" -# Let any running instances of wmiirc know that we're starting -PIDFILE=$WMII_NAMESPACE/.wmii.pid -echo $$ > $PIDFILE +wmiir xwrite /event WmiircQuit # close any existing wmiirc's Event WmiircStart trap "Event Quit" EXIT -# use wmiir so it doesn't look like an open file wmiir read /event 2>/dev/null | while read event; do - [[ $$ = $(cat $PIDFILE) ]] && Event $event + Event $event done - -Event WmiircQuit |