[updated May 23rd, 2009
- Added information related to 'Refresh Screen' script changes
- Changed the tcz-uninstall command line
- Added Turn ON and Off Remote Desktop menu Button description]
It's Friday and time to wrap up another week working with Tinycore. I thought it might be useful to sum up my experience getting a remote desktop working that is the same as the local one. The same meaning the flwm background, wbar and menu are in sync. Applications can be installed at either the local or remote end and will be seen at the other end. I tried using both realvnc and tightvnc as the remote desktop server and ended up using tightvnc with the tightvncviewer on a windows machine. I use a secure vpn to my router for remote access to my home network so I don't need a ssl connection to the Xvnc server.
I should point out that my primary application for Tinycore is a webserver so I keep all applications that are not needed for the webserver in the tce/optional directory. I use only tcz applications since I am very limited in memory and install them only when needed. I created the following script to install/start, stop/uninstall and restart the remote desktop. I'm not a script writter so I don't claim that this script is flawless.
Anyway the start function replaces wbar.sh, flwm_restart and 'Refresh Screen' with changed versions, per some excellent advice from Robert and curaga, to accommodate a two display environment. The two displays being local (display=:0.0) and remote (display=:1.0). Without changes to these three files wbar updates and menu updates fall out of sync. Also the updates shutdown the local or remote wbar or flwm processes depending on circumstances. It gets quite confusing.
Next the start function installs the tightvnc application and then activates the Xvnc server. The Xvnc server needs the screen size and color depth set in the command line.
Once the Xvnc server is running the remote display needs to be configured. The conf function sets the background color and activates a wbar and flwm instantiation for the remote display (display=:1.0).
The stop function kills the Xvnc server process and transfers control to the tcz uninstall script. My intent here was to perform the uninstall of tightvnc but the tcz-uninstall script doesn't support this yet. [update- I changed the uninstall command to make use of Jason's latest tcz-uninstall.tcz version.]
#!/bin/sh
stop()
{
echo "Stopping tvnc..."
sudo killall Xvnc 2>&1 > /dev/null &
tcz-uninstall tightvnc 2>&1 > /dev/null &
}
start()
{
echo "Starting tvnc..."
sudo cp -f /mnt/sdc1/wbar.sh /usr/bin 2>&1 > /dev/null &
sudo cp -f /mnt/sdc1/flwm_restart /usr/bin 2>&1 > /dev/null &
sudo cp -f /mnt/sdc1/'Refresh Menu' /home/tc/.wmx 2>&1 > /dev/null &
tce-load /mnt/sdc1/tce/optional/tightvnc.tcz &
sleep 2
Xvnc -geometry 1024x768 -depth 16 :1 2>&1 > /dev/null &
sleep 3
DISPLAY=:1.0 config
}
restart()
{
echo "Restarting tvnc.."
stop
sleep 3
start
}
config()
{
xsetroot -solid "#4f5f82"
/usr/bin/wbar -bpress -config /usr/local/tce.wbar 2>&1 > /dev/null &
/usr/bin/flwm 2>&1 > /dev/null &
}
case "$1" in
start) start;;
stop) stop;;
restart) restart;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
Here is the changed version of the wbar.sh script. It starts wbar from within the DISPLAY command for both the local and remote display. The remote display wbar is only started if /tmp/.X11-unix/X1 (X11 display 1)is present.
#!/bin/sh
cd "$HOME"
if [ $(awk '/icons:/{print $2}' "$HOME"/.desktop) == wbar ]; then
WBARPID=$(pidof wbar)
[ -n "$WBARPID" ] && killall wbar
DISPLAY=:0.0 wbar -bpress -config /usr/local/tce.wbar > /dev/null &
[ -e /tmp/.X11-unix/X1 ] && DISPLAY=:1.0 wbar -bpress -config /usr/local/tce.wbar > /dev/null &
fi
Here is what I changed in the flwm_restart script. It starts flwm from within the DISPLAY command for both the local and remote display. The remote display flwm is only started if /tmp/.X11-unix/X1 (X11 display 1)is present.
#!/bin/sh
restart() {
killall flwm
DISPLAY=:0.0 flwm &
[ -e /tmp/.X11-unix/X1 ] && DISPLAY=:1.0 flwm &
}
WBARPID=$(pidof flwm)
[ -n "$WBARPID" ] && restart
Here is what I changed in the 'Refresh Screen' tool script. It starts flwm from within the DISPLAY command for both the local and remote display. The remote display flwm is only started if /tmp/.X11-unix/X1 (X11 display 1)is present.
#!/bin/sh
pkill flwm
DISPLAY=:0.0 flwm &
[ -e /tmp/.X11-unix/X1 ] && DISPLAY=:1.0 flwm &
Although I have attempted to have all command output sent to the null device the Xvnc server still sends information to the console as shown below. Other messages appear as well.
tc@box:/mnt/sdc1$ ./tvnc start
Starting tvnc...
/mnt/sdc1/tce/optional/tightvnc.tcz
22/05/09 15:13:00 Xvnc version TightVNC-1.3.9
22/05/09 15:13:00 Copyright (C) 2000-2007 TightVNC Group
22/05/09 15:13:00 Copyright (C) 1999 AT&T Laboratories Cambridge
22/05/09 15:13:00 All Rights Reserved.
22/05/09 15:13:00 See http://www.tightvnc.com/ for information on TightVNC
22/05/09 15:13:00 Desktop name 'x11' (box:1)
22/05/09 15:13:00 Protocol versions supported: 3.3, 3.7, 3.8, 3.7t, 3.8t
22/05/09 15:13:00 Listening for VNC connections on TCP port 5901
Font directory '/usr/lib/X11/fonts/Speedo/' not found - ignoring
Font directory '/usr/lib/X11/fonts/Type1/' not found - ignoring
Font directory '/usr/lib/X11/fonts/100dpi/' not found - ignoring
tc@box:/mnt/sdc1$ Xlib: extension "Generic Event Extension" missing on display ":1.0".
tc@box:/mnt/sdc1$
22/05/09 15:13:16 Got connection from client 192.168.0.114
22/05/09 15:13:16 Using protocol version 3.8
22/05/09 15:13:16 Enabling TightVNC protocol extensions
22/05/09 15:13:16 Pixel format for client 192.168.0.114:
22/05/09 15:13:16 16 bpp, depth 16, little endian
22/05/09 15:13:16 true colour: max r 31 g 63 b 31, shift r 11 g 5 b 0
22/05/09 15:13:16 no translation needed
22/05/09 15:13:16 Using hextile encoding for client 192.168.0.114
22/05/09 15:13:16 rfbProcessClientNormalMessage: ignoring unknown encoding 8
22/05/09 15:13:16 Enabling X-style cursor updates for client 192.168.0.114
22/05/09 15:13:16 Enabling cursor position updates for client 192.168.0.114
22/05/09 15:13:16 Using image quality level 9 for client 192.168.0.114
22/05/09 15:13:16 Enabling LastRect protocol extension for client 192.168.0.114
22/05/09 15:13:16 rfbProcessClientNormalMessage: ignoring unknown encoding -223
I will do more testing but so far the local and remote desktops seem to be cooperating.
I created a turn On and Off remote desktop toggle menu button as a convenience. I created a file in the /home/tc/.wmx/Tools folder with the content shown below. Note the file name is changed by the script as a way to toggle the name in the menu.
#!/bin/sh
start(){
/mnt/sdc1/tvnc start 2>&1 > /dev/null &
sleep 4
mv /home/tc/.wmx/Tools/'TurnOn RemoteDeskTop' /home/tc/.wmx/Tools/'TurnOff RemoteDeskTop' 2>&1 > /dev/null &
/usr/bin/flwm_restart 2>&1 > /dev/null &
}
stop(){
/mnt/sdc1/tvnc stop 2>&1 > /dev/null &
sleep 4
mv /home/tc/.wmx/Tools/'TurnOff RemoteDeskTop' /home/tc/.wmx/Tools/'TurnOn RemoteDeskTop' 2>&1 > /dev/null &
/usr/bin/flwm_restart 2>&1 > /dev/null &
}
PID=$(pidof Xvnc)
[ -n "$PID" ] && stop || start