Last active
May 5, 2023 21:32
-
-
Save hpsaturn/7b6d15f149eb5bb9bdb19b94b1b34c42 to your computer and use it in GitHub Desktop.
Virtual Screen handler for expand your desktop to old laptops or Tablets. More info: https://hpsaturn.com/old-laptop-like-second-monitor/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Secondary display resolution | |
W=1920 # Virtual display width | |
H=1080 # Virtual display height | |
# Primary display config | |
P="HDMI-A-0" #is the main screen, it can be calle eDP-1 or eDP1 depending on the driver | |
O="DisplayPort-0" #can be a virtual (recommended if possible) or real output accepted by the xog driver. | |
#more info: https://wiki.archlinux.org/title/Extreme_Multihead#VNC | |
############# END SETUP ############################################################## | |
PW=`xrandr --current | egrep '\*' | awk '{print $1;}' | cut -d x -f 1 | head -n 1` | |
# Create the virtual display | |
gtf $W $H 120 | sed '3q;d' | sed 's/Modeline//g' | xargs xrandr --newmode | |
gtf $W $H 120 | sed '3q;d' | sed 's/Modeline//g' | awk '{print $1;}' | sed 's/^.\(.*\).$/\1/' | xargs xrandr --addmode $O | |
gtf $W $H 120 | sed '3q;d' | sed 's/Modeline//g' | awk '{print $1;}' | sed 's/^.\(.*\).$/\1/' | xargs xrandr --output $O --right-of $P --mode | |
sleep 1 | |
# Android device init | |
# Forward the VNC port to your device and start a VNC session | |
# adb reverse tcp:5900 tcp:5900 # uncomment for Android secondary display | |
echo "Starting VNC server" | |
x11vnc -display :0 -clip ${W}x${H}+${PW}+0 -repeat -forever -nonap -multiptr -noxfixes | |
# When cancel this script, turn off the virtual display | |
xrandr --output ${O} --off | |
# On the old laptop please run: | |
# vncviewer -shared -ViewOnly -Fullscreen <host ip> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's a variant of the Android Display Script script from @8bitbuddhist
This script is workaround to NVIDIA issue with "virtual setup" on X Org for old laptops (the original script was for Android). And also fix some issues in the detection of primary device resolution.