Skip to content

Instantly share code, notes, and snippets.

@frankIT
Last active January 25, 2022 22:01
Show Gist options
  • Save frankIT/4cff179db95d2d1636f363d907126367 to your computer and use it in GitHub Desktop.
Save frankIT/4cff179db95d2d1636f363d907126367 to your computer and use it in GitHub Desktop.
Play Counter Strike Global Offensive in a triple display setup on linux
#!/bin/bash
# Display names
# xrandr | grep connected
LEFT="DP-1"
MIDDLE="eDP-1"
RIGHT="HDMI-2"
# Middle display resolution (native)
MIDDLE_W=1600
MIDDLE_H=900
# Left/Right displays resolution (forced)
SIDES_W=1024
SIDES_H=900
SIDESMODE=$(cvt $SIDES_W $SIDES_H)
# Processes to kill via killall before running steam
PROCESSES=(chrome atom code Thunar spotify mousepad x11vnc screen cairo-dock)
# Services to stop via systemctl before running steam
SERVICES=(apache2 mysql docker)
GAMEID=730 # CSGO Steam ID
# Add a new 16:9 mode and force it to the 4:3 left/right displays
xrandr --newmode "${SIDES_W}x${SIDES_H}" ${SIDESMODE##*\"}
xrandr --addmode ${RIGHT} ${SIDES_W}x${SIDES_H}
xrandr --addmode ${LEFT} ${SIDES_W}x${SIDES_H}
# create the virtual display
xrandr --setmonitor 3wayspan auto ${LEFT},${MIDDLE},${RIGHT}
# set res and pos of each display emulating a single 3648x900 ultraiwide resolution
xrandr --output ${MIDDLE} --primary --mode ${MIDDLE_W}x${MIDDLE_H} --pos ${SIDES_W}x0 --rotate normal --output ${LEFT} --mode ${SIDES_W}x${SIDES_H} --pos 0x0 --rotate normal --output HDMI-1 --off --output ${RIGHT} --mode ${SIDES_W}x${SIDES_H} --pos $(expr ${SIDES_W} + ${MIDDLE_W})x0 --rotate normal
# stop heavy services and apps
docker stop $(docker ps -a -q)
systemctl stop "${SERVICES[@]}"
killall "${PROCESSES[@]}"
# launch CSGO being sure nvidia gpu will be used
__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia steam steam://rungameid/${GAMEID}
# theese should be set as boot options in steam: "-nojoy -novid -console -w 3648 -h 900". once in game console, set "triple_monitor_setup 1".
# AFTER STEAM EXITS: restart services, apps and kill display settings once the default preset has been reloaded
# remove virtual display
xrandr --delmonitor 3wayspan
# let xfce display settings choose the default preset
xfce4-display-settings --minimal&
# restart cairo-dock
nohup cairo-dock > /dev/null 2>&1 &
# restart services and halt prompting for password
systemctl start "${SERVICES[@]}"
# close display settings modal
killall xfce4-display-settings
@frankIT
Copy link
Author

frankIT commented Dec 19, 2021

20211219021419_1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment