How to connect to a remote X Windows just like sitting in front of it.

Posted On // Leave a Comment
I have used as Zenity to create a GUI application for Xephyr. Xephyr is a much better implementation than Xnest. Those who dont know what is Xephyr or Xnest, please search google. Also remember not to use my procedure of using Xephyr connecting to a system using internet as there is no encryption of any kind are used here. It has serious security implication. This procedure is better suited for intranet use.

First of all I am not gonna tell you how to do, this and that. You need to be good in linux and a seasoned linux enthusiast like me. Here I will just share a bash script which is actually an attempt to create a GUI interface for Xephyr.

So first ensure X-windows is running in the system that you want to connect to. Lets call it server. Also ensure that you can actually login directly to your server's graphical session. Now enable XDMCP in it.

Now save the following code in a file /usr/bin/xephyr-gui






#!/bin/bash

reschoice=(FALSE "640x480" FALSE "800x600" FALSE "1024x768" FALSE "1152x864" FALSE "1280x960" FALSE "1400x1050" TRUE "1600x960")
resolution=$(zenity  --title "Resolution" --height 300 --list  --text "Select a resolution from the list below" --radiolist  --column "Pick" --column "Resolution" ${reschoice[@]})

return_value=$?
case $return_value in

1)

echo -e '\E[31m'"Canceled"
exit ;;

0)

display=$(zenity --title="Gtk-Xephyr" --scale --text "Pick a Display Number\n[0 is default and used]" --min-value=1 --max-value=100 --value=1 --step 2)

return_value=$?
case $return_value in

1)

echo -e '\E[31m'"Canceled"
exit ;;

0)

connectto=$(zenity --title="Gtk-Xephyr" --entry --text "Please enter IP/hostname X server is running to connect." --entry-text "localhost")

return_value=$?
case $return_value in

1)

echo -e '\E[31m'"Canceled"
exit ;;

0)

gksudo lsof | tee >(zenity --title "Please wait" --text "Connecting..." --progress --pulsate --no-cancel --auto-close) > /dev/null
/usr/bin/Xephyr -ac -br -reset -terminate -screen $resolution -title $connectto -query $connectto 2> /dev/null :$display &

exit ;;

esac
esac
esac

exit 0


Save the file and exit. Now make it executable.

chmod +x /usr/bin/xephyr-gui


Now you have a GUI to work with Xephyr. Enjoy.