-
-
Save 8bitbuddhist/7ab180286d6eb7fdc68d374063814175 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# Make sure your Android device is plugged in and accessible over adb. | |
#### Remember to enable virtual displays in xorg by adding the following to your configuration (e.g. /usr/share/X11/xorg.conf.d/20-virtual.conf) | |
# Section "Device" | |
# Identifier "intelgpu0" | |
# Driver "intel" | |
# Option "VirtualHeads" "1" | |
#EndSection | |
#### If you use AMD or Nvidia, change the Identifier and Driver options to match your GPU. | |
W=1920 # Virtual display width | |
H=1080 # Virtual display height | |
O=VIRTUAL1 # The name of the virtual display (check using xrandr) | |
P=eDP1 # The name of your physical display (check using xrandr) | |
PW='$(xrandr --current | grep \* | awk '{print $1;}' | cut -d x -f 1)' | |
# Create the virtual display | |
gtf $W $H 60 | sed '3q;d' | sed 's/Modeline//g' | xargs xrandr --newmode | |
gtf $W $H 60 | sed '3q;d' | sed 's/Modeline//g' | awk '{print $1;}' | sed 's/^.\(.*\).$/\1/' | xargs xrandr --addmode $O | |
gtf $W $H 60 | sed '3q;d' | sed 's/Modeline//g' | awk '{print $1;}' | sed 's/^.\(.*\).$/\1/' | xargs xrandr --output $O --right-of $P --mode | |
# Forward the VNC port to your device and start a VNC session | |
adb reverse tcp:5900 tcp:5900 | |
x11vnc -localhost -clip ${W}x${H}+${PW}+0 | |
# When the session ends, turn off the virtual display | |
xrandr --output $O --off |
Has anyone found a nvidia graphics alternative for this?
Would be great to find and nvidia alternative
+1 to find a way to do this for nvidia drivers
+1 for nvidia
+1 for nvidia
+1 for nvidia, wen?
NVidia driver doesn't support virtual screens. And, mentioned "intel" driver is legacy one, current intel's "modesetting" driver doesn't support virtual screens too. Please, read the following materials for possible solutions:
StackExchange: Unable to add a VIRTUAL display to Xorg
ArchLinux Wiki: Extreme Multihead
Hi,
I use this modified version of the script (nvidia1070):
#!/bin/bash
# Make sure your Android device is plugged in and accessible over adb.
W=800 # Virtual display width
H=1280 # Virtual display height
O=DVI-I-1-1 # The name of the virtual display (check using xrandr)
P=DP-0 # The name of your physical display (check using xrandr)
PW=`xrandr --current | grep \* | awk '{print $1;}' | cut -d x -f 1`
sudo modprobe evdi initial_device_count=2
xrandr --setprovideroutputsource 1 0 --setprovideroutputsource 2 0
# Create the virtual display
# gtf $W $H 60 | sed '3q;d' | sed 's/Modeline//g' | xargs xrandr --newmode
xrandr --newmode `gtf $W $H 60 | grep -v '#' | sed 's/Modeline//g' | xargs`
# gtf $W $H 60 | sed '3q;d' | sed 's/Modeline//g' | awk '{print $1;}' | sed 's/^.\(.*\).$/\1/' | xargs xrandr --addmode $O
xrandr --addmode ${O} ${W}x${H}_60.00
# gtf $W $H 60 | sed '3q;d' | sed 's/Modeline//g' | awk '{print $1;}' | sed 's/^.\(.*\).$/\1/' | xargs xrandr --output $O --right-of $P --mode
xrandr --output $O --right-of $P --mode ${W}x${H}_60.00
# Forward the VNC port to your device and start a VNC session
adb reverse tcp:5900 tcp:5900
x11vnc -clip ${W}x${H}+${PW}+0
# When the session ends, turn off the virtual display
xrandr --output $O --off
sudo rmmod evdi
It use evdi (# apt install evdi-dkms) to create virtual display instead of intel features. No X server required, but mouse cursor is blinking. Any suggestions how to fix this?
Thanks to @cb1986ster, your script works for me. But not perfectly…
- I'm on Intel (recent XPS13), so I put the O and the P back to the values from the original script, things are mostly working, so I presume I did that right.
- I am connecting to a Samsung Tab S7 FE, it is a 2560x1600 display, and using them 1-to-1 it too small to be practical, so I changed those values to:
W=1920 # Virtual display width
H=1200 # Virtual display height
This I think I did wrong. When I maximize a window on the new it gets set too big. What is the correct way to scale my display?
My second problem is that rmmod
is failing, it says evdi is in use
. I think my MATE graphic UI environment is noticing and grabbing. The new virtual monitor shows up in Control Center->Displays, and it stays there once the Android display has gone away (as best as I know how to make it go away).
Update: The presence of /usr/share/X11/xorg.conf.d/20-virtual.conf
seems a problem on Debian MATE. Even after a fresh boot, without running the script, without touching the Displays control panel, I had funny video freeze ups.
I moved it aside and rebooted. Using my computer again, and things seem rock-solid again.
The Displays control panel is a nice little beast for managing multiple screens. It would be nice to have my tablet-as-monitor integrate with it…
Hi all, it's been a while since I've tested this since I haven't had a need for a portable monitor. I'll give @cb1986ster's script a try and see about finally updating the Gist
NVidia driver doesn't support virtual screens. And, mentioned "intel" driver is legacy one, current intel's "modesetting" driver doesn't support virtual screens too. Please, read the following materials for possible solutions: StackExchange: Unable to add a VIRTUAL display to Xorg ArchLinux Wiki: Extreme Multihead
Thanks, this documentation is clear. My driver is amdgpu
for this reason I used the modeline alternative. I did a simple a script for old laptops (secondary display). Also I fixed some issues on the resolution detection on the current script:
https://gist.github.com/hpsaturn/7b6d15f149eb5bb9bdb19b94b1b34c42
Also it should be works with Android.
Hi. "VirtualHeads" option is Intel driver specific and it can't be used with other drivers like amdgpu or nvidia. Meaning this will work only on computers that are running Intel graphics.