Debian Codegraph @

tyrannical/utils/xephyr.sh

raw symbols SCIP
1 # If example.rc.lua is missing, make a default one.
2 rc_lua=$PWD/example.rc.lua
3 test -f $rc_lua || /bin/cp /etc/xdg/awesome/rc.lua $rc_lua
4
5 # Just in case we're not running from /usr/bin
6 awesome=`which awesome`
7 xephyr=`which Xephyr`
8 pidof=`which pidof`
9
10 test -x $awesome || { echo "Awesome executable not found. Please install Awesome"; exit 1; }
11 test -x $xephyr || { echo "Xephyr executable not found. Please install Xephyr"; exit 1; }
12
13 function usage()
14 {
15 cat <<USAGE
16 awesome_test start|stop|restart|run
17
18 start Start nested Awesome in Xephyr
19 stop Stop Xephyr
20 restart Reload nested Awesome configuration
21 run Run command in nested Awesome
22
23 USAGE
24 exit 0
25 }
26
27 # WARNING: the following two functions expect that you only run one instance
28 # of Xephyr and the last launched Awesome runs in it
29
30 function awesome_pid()
31 {
32 $pidof awesome | cut -d\ -f1
33 }
34
35 function xephyr_pid()
36
37 {
38 $pidof Xephyr | cut -d\ -f1
39 }
40
41 [ $# -lt 1 ] && usage
42
43
44 case "$1" in
45 start)
46 $xephyr -ac -br -noreset -screen 800x600 :1 &
47 sleep 1
48 DISPLAY=:1.0 $awesome -c $rc_lua &
49 sleep 1
50 echo "Awesome ready for tests. PID is $(awesome_pid)"
51 ;;
52 stop)
53 echo -n "Stopping Nested Awesome... "
54 if [ -z $(xephyr_pid) ]; then
55 echo "Not running: not stopped :)"
56 exit 0
57 else
58 kill $(xephyr_pid)
59 echo "Done."
60 fi
61 ;;
62 restart)
63 echo -n "Restarting Awesome... "
64 kill -s SIGHUP $(awesome_pid)
65 ;;
66 run)
67 shift
68 DISPLAY=:1.0 "$@" &
69 ;;
70 *)
71 usage
72 ;;
73 esac