| 1 | # If example.rc.lua is missing, make a default one. |
| 2 | rc_lua=$PWD/example.rc.lua |
| 3 | testscip-shell system . . test. -f $rc_lua || /bin/cpscip-shell filesystem . . `/bin/cp`. /etc/xdg/awesome/rc.luascip-shell filesystem . . `/etc/xdg/awesome/rc.lua`. $rc_lua |
| 4 | |
| 5 | # Just in case we're not running from /usr/bin |
| 6 | awesome=`whichscip-shell system . . which. awesome` |
| 7 | xephyr=`whichscip-shell system . . which. Xephyr` |
| 8 | pidof=`whichscip-shell system . . which. pidof` |
| 9 | |
| 10 | testscip-shell system . . test. -x $awesome || { echoscip-shell system . . echo. "Awesome executable not found. Please install Awesome"; exit 1; } |
| 11 | testscip-shell system . . test. -x $xephyr || { echoscip-shell system . . echo. "Xephyr executable not found. Please install Xephyr"; exit 1; } |
| 12 | |
| 13 | function usagescip-shell shell awesome-extra 2023010601 usage().() |
| 14 | { |
| 15 | catscip-shell system . . 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_pidscip-shell shell awesome-extra 2023010601 awesome_pid().() |
| 31 | { |
| 32 | $pidof awesome | cutscip-shell system . . cut. -d\ -f1 |
| 33 | } |
| 34 | |
| 35 | function xephyr_pidscip-shell shell awesome-extra 2023010601 xephyr_pid().() |
| 36 | |
| 37 | { |
| 38 | $pidof Xephyr | cutscip-shell system . . cut. -d\ -f1 |
| 39 | } |
| 40 | |
| 41 | [scip-shell system . . `[`. $# -lt 1 ] && usagescip-shell shell awesome-extra 2023010601 usage(). |
| 42 | |
| 43 | |
| 44 | case "$1" in |
| 45 | start) |
| 46 | $xephyr -ac -br -noreset -screen 800x600 :1 & |
| 47 | sleepscip-shell system . . sleep. 1 |
| 48 | DISPLAY=:1.0 $awesome -c $rc_lua & |
| 49 | sleepscip-shell system . . sleep. 1 |
| 50 | echoscip-shell system . . echo. "Awesome ready for tests. PID is $(awesome_pidscip-shell shell awesome-extra 2023010601 awesome_pid().)" |
| 51 | ;; |
| 52 | stop) |
| 53 | echoscip-shell system . . echo. -n "Stopping Nested Awesome... " |
| 54 | if [scip-shell system . . `[`. -z $(xephyr_pidscip-shell shell awesome-extra 2023010601 xephyr_pid().) ]; then |
| 55 | echoscip-shell system . . echo. "Not running: not stopped :)" |
| 56 | exit 0 |
| 57 | else |
| 58 | killscip-shell system . . kill. $(xephyr_pidscip-shell shell awesome-extra 2023010601 xephyr_pid().) |
| 59 | echoscip-shell system . . echo. "Done." |
| 60 | fi |
| 61 | ;; |
| 62 | restart) |
| 63 | echoscip-shell system . . echo. -n "Restarting Awesome... " |
| 64 | killscip-shell system . . kill. -s SIGHUP $(awesome_pidscip-shell shell awesome-extra 2023010601 awesome_pid().) |
| 65 | ;; |
| 66 | run) |
| 67 | shift |
| 68 | DISPLAY=:1.0 "$@" & |
| 69 | ;; |
| 70 | *) |
| 71 | usagescip-shell shell awesome-extra 2023010601 usage(). |
| 72 | ;; |
| 73 | esac |