Last active
April 15, 2019 16:52
-
-
Save xomachine/418c9c66aa351df90959d08a27c0c129 to your computer and use it in GitHub Desktop.
A little script for starting X server on GPU used for passthrough by default
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 | |
if [ x"$DISPLAY" != x ]; then | |
SUDO="lxsudo" | |
else | |
SUDO="sudo" | |
fi | |
if [ $UID = 0 ]; then | |
modprobe i2c-dev | |
# Switch monitor to HDMI input | |
ddccontrol -r 0x60 -w 17 dev:/dev/i2c-3 | |
rmmod vfio-pci | |
modprobe nvidia_drm | |
CONFIG=' | |
Section "ServerLayout" | |
Identifier "game" | |
Screen "gamescreen" | |
EndSection | |
Section "Monitor" | |
Identifier "DFP-1" | |
EndSection | |
Section "Screen" | |
Identifier "gamescreen" | |
Device "Nvidia Card" | |
GPUDevice "Nvidia Card" | |
Monitor "DFP-1" | |
Option "ConnectedMonitor" "DFP-1" | |
EndSection | |
' | |
echo "$CONFIG" > /etc/X11/xorg.conf.d/91-gamelayout.conf; | |
chmod 0666 /dev/tty8 | |
#chvt 8 | |
kill -10 $1 | |
while kill -0 $1; do | |
sleep 1 | |
done | |
#chvt 7 | |
modprobe -r nvidia_drm | |
modprobe -r nvidia_modeset | |
modprobe -r nvidia | |
modprobe vfio-pci | |
# Switch monitor back to DVI input | |
ddccontrol -r 0x60 -w 3 dev:/dev/i2c-3 | |
else | |
$SUDO sh $0 $$ & | |
prepare_input() { | |
sleep 1s && sh $HOME/.Soft/switch_input.sh | |
} | |
startme(){ | |
prepare_input & startx /usr/bin/awesome -- :1 -layout game vt7 -sharevts | |
sleep 1 | |
prepare_input | |
exit | |
} | |
trap startme 10 | |
wait %1 | |
fi |
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 | |
otherdisplay=":0" | |
if [ "$DISPLAY" = ":0" ]; then | |
otherdisplay=":1" | |
else | |
otherdisplay=":0" | |
fi | |
if (DISPLAY="$otherdisplay" xinput list &>/dev/null) && xinput list &> /dev/null; then | |
echo "Current display $DISPLAY, other display $otherdisplay" | |
for i in $(xinput list --id-only); do | |
DISPLAY="$otherdisplay" xinput enable $i | |
xinput disable $i | |
done | |
else | |
echo "You are running only one display" | |
for i in $(xinput list --id-only); do | |
xinput enable $i | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment