#!/bin/sh # # testx supports the following parameters: # # "testx" checks whether XFree86 is running or not. # "testx help" displays help. # # "testx fullscreen" starts XDarwin.app in fullscreen mode (if so configured). # "testx rootless" starts OroborOSX (XDarwin.app in rootless mode). # "testx applex11" starts Apple's own XFree86 implementation # "testx shutdown" shuts down a running XFree86 via "kill -3" ("kill -9" after trying). # # The parameters above can be abbreviated as "h", "fs", "rl", "ax", and "sd". # # "testx element " sets NSUIElement for to 1 (true) or 0 (false). # can be "xdarwin", "orborosx", or "apple". # "testx manager " sets XDarwin's window manager or desktop environment to . # # It's also possible to start testx with two parameters, which can be useful to restart X11. # "testx shutdown rootless" will restart X11 in rootless mode. # # testx is (c) Andrew J. Brehm and released under the GNU GPL (http://www.gnu.org/licenses/gpl.txt) # This is version 1.0b. # alias a=alias xrunning() { ps axc | grep xinit | grep -v grep > /dev/null && return 0 ps axc | grep Xquartz | grep -v grep > /dev/null && return 0 return 1 } xisrunning() { echo testx: X is running. exit 0 } xisnotrunning() { echo testx: X is not running or has been killed. exit 1 } oroborosxrunning() { ps axc | grep OroborOSX | grep -v grep > /dev/null && return 0 return 1 } applex11running() { ps axc | grep Xquartz | grep -v grep > /dev/null && return 0 return 1 } if test -z $1 2> /dev/null then xrunning && xisrunning || xisnotrunning fi if (test $1 = help || test $1 = h) 2> /dev/null then grep "#" $0 | grep -v grep | grep -v "#!/bin/sh" | sed s/#//g fi if (test $1 = mode || test $1 = m) 2> /dev/null then $0 oroborosxrunning && echo testx: OroborOSX seems to be running. applex11running && echo testx: Apple X11 seems to be running. fi if (test $1 = status || test $1 = st) 2> /dev/null then $0 mode echo testx: XDarwin window manager: \"`more ~/.xinitrc | grep exec | sed s/"exec "//g`\" fi if (test $1 = fullscreen || test $1 = fs) 2> /dev/null then echo testx: Trying to start X11 in fullscreen mode. echo testx: Checking window manager... grep quartz-wm ~/.xinitrc > /dev/null && echo testx: You cannot use quartz-wm with XDarwin. && echo testx: Use another window manager. && exit open /Applications/XDarwin.app && sleep 5 && $0 || echo "testx: XDarwin.app not in /Applications?" fi if (test $1 = rootless || test $1 = rl) 2> /dev/null then echo testx: Trying to start X11 in rootless mode. open /Applications/OroborOSX/OroborOSX*.app && sleep 5 && $0 || echo "testx: OroborOSX folder not in /Applications?" fi if (test $1 = applex11 || test $1 = ax) 2> /dev/null then echo testx: Trying to start Apple X11. $0 manager quartz-wm open /Applications/X11.app && sleep 5 && $0 || echo "testx: X11.app not in /Applications?" fi a xdarwinpid="ps axc | grep XDarwin | grep -v grep | cut -c1-5" a xquartzpid="ps axc | grep Xquartz | grep -v grep | cut -c1-5" if (test $1 = shutdown || test $1 = sd) 2> /dev/null then $0 echo testx: Trying to kill X. kill -3 `xdarwinpid` 2> /dev/null && sleep 1 kill -9 `xdarwinpid` 2> /dev/null && sleep 1 kill -3 `xquartzpid` 2> /dev/null && sleep 1 kill -9 `xquartzpid` 2> /dev/null && sleep 1 $0 fi if test $1 = element 2> /dev/null then if test $2 = install 2> /dev/null then echo testx: Preparing XDarwin and OroborOSX to be configurable for TestXPane and testx. echo testx: You might be asked for your password. You might have to be an administrator to make this work. $0 element xdarwin install $0 element oroborosx install $0 element apple install echo testx: Task finished. fi if test $2 = xdarwin 2> /dev/null then if test $3 = true 2> /dev/null then echo testx: Attempting to make XDarwin an UI element. cd /Applications/XDarwin.app/Contents more Info.plist | sed s/"0<\/string>"/"1<\/string>"/g |grep -v :: | grep -v Info.plist > Info.tmp cp Info.tmp Info.plist || echo testx: "Info.plist or directory not writable?" more Info.plist | grep "NSUIElement" > /dev/null && echo testx: From Info.plist: more Info.plist | grep -A 1 "NSUIElement" || echo testx: error: There is no NSUIElement entry in Info.plist. more Info.plist | grep "NSUIElement" > /dev/null || echo testx: remedy: Run \"testx element install\" in the terminal. echo testx: Finished. fi if test $3 = false 2> /dev/null then echo testx: Attempting to make XDarwin stand-alone. cd /Applications/XDarwin.app/Contents more Info.plist | sed s/"1<\/string>"/"0<\/string>"/g |grep -v :: | grep -v Info.plist > Info.tmp cp Info.tmp Info.plist || echo testx: "Info.plist or directory not writable?" more Info.plist | grep -A 1 "NSUIElement" > /dev/null && echo testx: From Info.plist: more Info.plist | grep -A 1 "NSUIElement" || echo testx: error: There is no NSUIElement entry in Info.plist. more Info.plist | grep -A 1 "NSUIElement" > /dev/null || echo testx: remedy: Run \"testx element install\" in the terminal. echo testx: Finished. fi if test $3 = install 2> /dev/null then echo testx: Attempting to make XDarwin configurable for TestXPane and testx. cd /Applications/XDarwin.app/Contents sudo chmod g+w . sudo chmod g+w Info.plist more Info.plist | grep "NSUIElement" > /dev/null && echo testx: XDarwin is already configured correctly. Exiting... && exit sudo tail -rn 999 Info.plist > Info.tmp2 sudo more +3 Info.tmp2 > Info.tmp1 sudo tail -rn 999 Info.tmp1 > Info.tmp echo " NSUIElement" >> Info.tmp echo " 1" >> Info.tmp echo "" >> Info.tmp echo "" >> Info.tmp sudo cp Info.tmp Info.plist sudo rm Info.tmp* echo testx: Attempt succeeded. fi fi if test $2 = oroborosx 2> /dev/null then if test $3 = true 2> /dev/null then echo testx: Attempting to make OroborOSX an UI element. cd /Applications/OroborOSX/OroborOSX*.app/Contents more Info.plist | sed s/"0<\/string>"/"1<\/string>"/g |grep -v :: | grep -v Info.plist > Info.tmp cp Info.tmp Info.plist || echo testx: "Info.plist or directory not writable?" more Info.plist | grep -A 1 "NSUIElement" > /dev/null && echo testx: From Info.plist: more Info.plist | grep -A 1 "NSUIElement" || echo testx: error: There is no NSUIElement entry in Info.plist. more Info.plist | grep -A 1 "NSUIElement" > /dev/null || echo testx: remedy: Run \"testx element install\" in the terminal. echo testx: Finished. fi if test $3 = false 2> /dev/null then echo testx: Attempting to make OroborOSX a stand-alone. cd /Applications/OroborOSX/OroborOSX*.app/Contents more Info.plist | sed s/"1<\/string>"/"0<\/string>"/g |grep -v :: | grep -v Info.plist > Info.tmp cp Info.tmp Info.plist || echo testx: "Info.plist or directory not writable?" more Info.plist | grep -A 1 "NSUIElement" > /dev/null && echo testx: From Info.plist: more Info.plist | grep -A 1 "NSUIElement" || echo testx: error: There is no NSUIElement entry in Info.plist. more Info.plist | grep -A 1 "NSUIElement" > /dev/null || echo testx: remedy: Run \"testx element install\" in the terminal. echo testx: Finished. fi if test $3 = install 2> /dev/null then echo testx: Attempting to make OroborOSX configurable for TestXPane and testx. cd /Applications/OroborOSX/OroborOSX*.app/Contents sudo chmod g+w . sudo chmod g+w Info.plist more Info.plist | grep "NSUIElement" > /dev/null && echo testx: OroborOSX is already configured correctly. Exiting... && exit sudo tail -rn 999 Info.plist > Info.tmp2 sudo more +3 Info.tmp2 > Info.tmp1 sudo tail -rn 999 Info.tmp1 > Info.tmp echo " NSUIElement" >> Info.tmp echo " 1" >> Info.tmp echo "" >> Info.tmp echo "" >> Info.tmp sudo cp Info.tmp Info.plist sudo rm Info.tmp* echo testx: Attempt succeeded. fi fi if test $2 = apple 2> /dev/null then if test $3 = true 2> /dev/null then echo testx: Attempting to make Apple X11 an UI element. cd /Applications/X11.app/Contents more Info.plist | sed s/"0<\/string>"/"1<\/string>"/g |grep -v :: | grep -v Info.plist > Info.tmp cp Info.tmp Info.plist || echo testx: "Info.plist or directory not writable?" more Info.plist | grep -A 1 "NSUIElement" > /dev/null && echo testx: From Info.plist: more Info.plist | grep -A 1 "NSUIElement" || echo testx: error: There is no NSUIElement entry in Info.plist. more Info.plist | grep -A 1 "NSUIElement" > /dev/null || echo testx: remedy: Run \"testx element install\" in the terminal. echo testx: Finished. fi if test $3 = false 2> /dev/null then echo testx: Attempting to make Apple X11 a stand-alone. cd /Applications/X11.app/Contents more Info.plist | sed s/"1<\/string>"/"0<\/string>"/g |grep -v :: | grep -v Info.plist > Info.tmp cp Info.tmp Info.plist || echo testx: "Info.plist or directory not writable?" more Info.plist | grep -A 1 "NSUIElement" > /dev/null && echo testx: From Info.plist: more Info.plist | grep -A 1 "NSUIElement" || echo testx: error: There is no NSUIElement entry in Info.plist. more Info.plist | grep -A 1 "NSUIElement" > /dev/null || echo testx: remedy: Run \"testx element install\" in the terminal. echo testx: Finished. fi if test $3 = install 2> /dev/null then echo testx: Attempting to make Apple X11 configurable for TestXPane and testx. cd /Applications/X11.app/Contents sudo chmod g+w . sudo chmod g+w Info.plist more Info.plist | grep "NSUIElement" > /dev/null && echo testx: Apple X11 is already configured correctly. Exiting... && exit sudo tail -rn 999 Info.plist > Info.tmp2 sudo more +3 Info.tmp2 > Info.tmp1 sudo tail -rn 999 Info.tmp1 > Info.tmp echo " NSUIElement" >> Info.tmp echo " 1" >> Info.tmp echo "" >> Info.tmp echo "" >> Info.tmp sudo cp Info.tmp Info.plist sudo rm Info.tmp* echo testx: Attempt succeeded. fi fi fi if test $1 = manager 2> /dev/null then if test -z $2 2> /dev/null then echo testx: Which fullscreen window manager do you want to use\? echo testx: Current setting: \"`more ~/.xinitrc | grep exec | sed s/"exec "//g`\" fi if test $2 2> /dev/null then echo testx: Setting window manager to $2. echo exec $2 > ~/.xinitrc fi fi if test $2 2> /dev/null then $0 $2 fi