restartwm 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/sh
  2. #Exit from window manager will cause return to xwin, which reads
  3. #/tmp/wmexitmode.txt and will relaunch w.m.
  4. NEXTWM="$1"
  5. PREVIOUSWM="`cat /etc/windowmanager`"
  6. [ "$NEXTWM" = "" ] && NEXTWM="$PREVIOUSWM" #v1.0.7 precaution.
  7. echo -n "$NEXTWM" > /etc/windowmanager #this makes change permanent.
  8. #/sbin/pup_event_frontend_d will quit if this file exists...
  9. echo -n "$NEXTWM" > /tmp/wmexitmode.txt
  10. #v403 give time for /sbin/pup_event_frontend_d to quit.
  11. #w478 testing 2.6.18.1 kernel, pup_event_frontend_d did not exit when it
  12. #detected /tmp/wmeximode.txt, but became 'defunct'...
  13. KCNT=0
  14. PSPEFD="`ps -C pup_event_frontend_d | grep 'pup_event_front' | grep -v 'defunct'`"
  15. #while [ "`pidof pup_event_frontend_d`" != "" ];do
  16. while [ "$PSPEFD" != "" ];do
  17. sleep 0.5
  18. KCNT=`expr $KCNT + 1`
  19. [ $KCNT -gt 60 ] && break #30 secs.
  20. PSPEFD="`ps -C pup_event_frontend_d | grep 'pup_event_front' | grep -v 'defunct'`"
  21. done
  22. sleep 0.2
  23. sync
  24. if [ "`pidof xfce4-panel`" != "" ];then
  25. #killall xfce4-panel
  26. kill `pidof xfce4-panel`
  27. exit
  28. fi
  29. kill -9 `pidof $PREVIOUSWM` #w478
  30. #killall X #default is SIGTERM.
  31. #sleep 1 #v1.0.7
  32. #exec killall -9 X #v1.0.7 make sure X is killed.