EDIT: X is now lockable thru xscreensaver
hi! try this, I am having great results using it, mostly for games!
As it wont be managed by Unity, you may have great results too!
I have created this script that creates a new X session and runs a command or open a terminal so you can run it there.
openNewX.sh
#!/bin/bash
function FUNCisX1running {
ps -A -o command |grep -v "grep" |grep -q -x "X :1"
}
useJWM=true
useKbd=true
while [[ ${1:0:2} == "--" ]]; do
if [[ "$1" == "--no-wm" ]]; then #opt SKIP WINDOW MANAGER (run pure X alone)
useJWM=false
shift
elif [[ "$1" == "--no-kbd" ]]; then #opt SKIP Keyboard setup
useKbd=false
shift
elif [[ "$1" == "--isRunning" ]]; then #opt check if new X :1 is already running
if FUNCisX1running; then
exit 0
else
exit 1
fi
elif [[ "$1" == "--help" ]]; then #opt show help info
echo "usage: options runCommand"
# this sed only cleans lines that have extended options with "--" prefixed
sedCleanHelpLine='s"\(.*\"\)\(--.*\)\".*#opt" \2"' #helpskip
grep "#opt" $0 |grep -v "#helpskip" |sed "$sedCleanHelpLine"
exit 0
else
#echoc -p "invalid option $1"
echo "PROBLEM: invalid option $1"
$0 --help
exit 1
fi
done
#echo "going to execute: $@"
#runCmd="$1" #this command must be simple, if need complex put on a script file and call it!
runCmd="$@" #this command must be simple, if need complex put on a script file and call it!
#if ! echoc -q -t 2 "use JWM window manager@Dy"; then
# useJWM=false
#fi
# run in a thread, prevents I from ctrl+c here what breaks THIS X instace and locks keyb
if ! FUNCisX1running; then
xterm -e "\
echo \"INFO: hit CTRL+C to exit the other X session and close this window\";\
echo \"INFO: running in a thread (child proccess) to prevent ctrl+c from freezing this X session and the machine!\";\
echo \"INFO: hit ctrl+alt+f7 to get back to this X session (f7, f8 etc, may vary..)\";\
echo ;\
echo \"Going to execute on another X session: $runCmd\";\
sudo X :1"&
fi
#sudo chvt 8 # this line to force go to X :1 terminal
# wait for X to start
while ! FUNCisX1running; do
sleep 1
done
# run in a thread, prevents I from ctrl+c here what breaks THIS X instace and locks keyb
if $useJWM; then
if [[ ! -f "$HOME/.jwmrc" ]]; then
echo '<?xml version="1.0"?><JWM><Key mask="4" key="L">exec:xscreensaver-command --lock</Key></JWM>' \
>$HOME/.jwmrc
#if ! jwm -p; then
# rm $HOME/.jwmrc
# echo ".jwmrc is invalid"
#else
echo "see http://joewing.net/programs/jwm/config.shtml#keys"
echo "with Super+L you can lock the screen now"
#fi
fi
jwm -display :1&
fi
kbdSetup="echo \"SKIP: kbd setup\""
if $useKbd; then
kbdSetup="setxkbmap -layout us"
fi
sleep 2
xscreensaver -display :1&
# setxkbmap is good for games that have console access!; bash is to keep console open!
# nothing
#xterm -display :1&
# dead keys
#xterm -display :1 -e "setxkbmap -layout us -variant intl; bash"&
# good for games!
xterm -display :1 -e "$kbdSetup; bash -c \"$runCmd\"; bash"&
#xterm -display :1 -e "$kbdSetup; bash -c \"$@\"; bash"&
also, add this at: compiz config settings manager -> window rules -> non closeable
windows:
(class=XTerm) & (title=sudo X :1) & (name=xterm)
This will prevent you from closing that terminal (use ctrl+c to close the other X session and also the terminal), because if you close "the window" it will freeze your current X session!
It has the advantage that you dont have alt+enter full screen problems, also no Alt+TAB full screen problems; you can run with more stability any 3D game, from Urban Terror (linux native) to games run with Wine! Even some browsers that run 3D games like Firefox with Quake!
Obs.: you may want to install jwm package, not required but will make a difference if you need to do any window management there..
PS.: it can be improved of course, my plan is to add the keyboard setup to an option, but I do it very slowly ;), if someone improve/clean it up, post so I can update mine script :)