Skip to content

Instantly share code, notes, and snippets.

@YoranSys
Created October 3, 2017 09:50
Show Gist options
  • Save YoranSys/be04930ac5e28d27d55fb088caa70d39 to your computer and use it in GitHub Desktop.
Save YoranSys/be04930ac5e28d27d55fb088caa70d39 to your computer and use it in GitHub Desktop.
Duet IDisplay alternative for linux using X11vnc, for android best client is AndroidVNC
#!/bin/bash
x=1920 # X size of second display
y=1080 # Y size of second display
X_DISPLAY=eDP1 # Your screen, found it whith xrandr
POSITION=left #right
add_modeline() {
local modeline name
modeline="$(gtf "$2" "$3" "$4" | sed -n 's/.*Modeline "\([^" ]\+\)" \(.*\)/\1 \2/p')"
name="$(echo "${modeline}" | sed 's/\([^ ]\+\) .*/\1/')"
if [ -z "${modeline}" -o -z "${name}" ] ; then
echo "Error! modeline='${modeline}' name='${name}'"
exit 1
fi
xrandr --delmode "$1" "${name}"
xrandr --rmmode "${name}"
xrandr --newmode ${modeline}
xrandr --addmode "$1" "${name}"
}
if [ $1 == stop ]
then
xrandr --output VIRTUAL1 --off
killall x11vnc
sudo iptables -D INPUT -p tcp --dport 5900 -j ACCEPT
fi
if [ $1 == start ]
then
add_modeline VIRTUAL1 $x $y 60
sleep 5
add_modeline VIRTUAL1 1920 1080 60
sleep 5
xrandr --output VIRTUAL1 --mode ${x}x${y}_60.00 --${POSITION}-of eDP1
sleep 5
x11vnc -clip ${x}x${y}+0+0 -forever &> /dev/null &
# x11vnc -clip xinerama1 -forever > /dev/null &
sudo iptables -I INPUT 1 -p tcp --dport 5900 -j ACCEPT
ip a | grep inet | cut -d " " -f 6 | grep '192.\|10.'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment