tezcku (text, doesn't expire)
###
Separate Arch Linux TTY for spanned monitor gaming.
###
	https://www.mikechambers.com/blog/post/2020-11-02-installing-openbox-on-arch-linux/

	# To start with, we need a minimal window management server
	sudo pacman -S openbox
	# We'll need gamescope
	sudo pacman -S gamescope
	# We'll need some automation tools.
	sudo pacman -S xdotool wmctrl

###
Install and Configure Openbox
###
We're gonna setup some of Openbox first before setting up an autologin TTY. That'll be at the end.

	# Copy over config files to the /home directory. 
	mkdir -p ~/.config/openbox
	cp -a /etc/xdg/openbox/ ~/.config/
	
	# Make sure you set the proper home directory for Openbox. It's fussy about what's right. 
	export XDG_CONFIG_HOME=$HOME/.config/
	
Now, by default, when you log in, you login into blank screens with just a cursor. Right Clck where there no window brings up a launch menu that may reference programs you don't actually have. Alt lets you drag windows when you click it and click hold any window.

In the Openbox menu, navigate to terminals, open one of them. In my case, I have konsole, but I don't have any of he file managers referenced by default. I do have dolphin. That's okay. In konsole, I can just type dolphin and kate to launch them respectively if I don't want to do any console based text editing or file management.

First we'll setup our autostart. You don't have to copy this exactly, these are just things I want on my openbox session start to make transitioning into gaming straightforward.

__/.config/openbox/autostart
	#!/bin/bash
	# Set monitor arrangement
	xrandr --output DisplayPort-0 --primary --mode 1920x1080 --pos 1920x1080 \
	--output DisplayPort-1 --mode 1920x1080 --pos 3840x1080 \
	--output HDMI-A-0 --mode 1920x1080 --pos 0x1080 \
	--output HDMI-A-1 --mode 1920x1080 --pos 5760x1080 \
	--output DisplayPort-1-3 --mode 1920x1080 --pos 1920x0

	# Wait for monitors to initialize
	sleep 2

	# Application Autostart Block
	~/.config/openbox/gamescope-positioner.sh &
	konsole &
	steam &

	wait

Openbox has no GUI program to set your monitor arrangements and it actually doesn't save them. On login, you have to set your monitor arrangement by hand. What I recommend is going to a fuller desktop environment that has has a GUI monitor arranger, and use the command:
	xrandr --listmonitors

Then use those positions to build a line of xrandr --ouput commands. I use 5 monitors, but a simpler line of 3 monitors would look like:
	xrandr --output DisplayPort-0 --primary --mode 1920x1080 --pos 1920x0 \
	--output DisplayPort-1 --mode 1920x1080 --pos 3840x0 \
	--output HDMI-A-0 --mode 1920x1080 --pos 0x0 \

	# Wait for monitors to initialize
	sleep 2

Make sure that or something smiliar is at the start of your autstart.

Menu.xml,tba
RC.xml, tba

###
Steam
###
I'll assume you already have Steam installed and configured on your other Desktop Envrionment. Instead, we'll skip to launching games and assuring that the game window appears in a spanned resolution.
Note that if you use Big Picture to launch games, you need to go into Menu > Settings > Display, and tick use Windowed Mode for Big Picture. By default, Big Picture if a fullscreen app on your primary monitor, which sits over gamescope windows. If you want to keep the fullscreen big picture environment, that's fine, but what you'll have to do on each game launch is Alt+Tab back to Steam Big Picture, press Alt+Space, and press N.

In any game in your library, go to launch options. Add this to the launch options:
	gamescope -w 5760 -h 1080 -W 5760 -H 1080 -b --display-index 2 --force-grab-cursor -- %command%

    # -w -h, game content width and height. Upscaling this would let you make a pseudo AMD Virtual Super Resolution
    # -W -H, game window width and height.
    # -b, borderless fullscreen
    # --display-index 2, 2 in my case as explained above. You want this to be your left-most monitor.
    # --force-grab-cursor, this keeps the mouse from wigging out when you're managing other applications.

Now wait, we're not done.

__/.config/openbox/gamescope-positioner.sh
	#!/bin/bash
	# Gamescope window positioner for Openbox

	echo "Starting gamescope window positioner..."

	while true; do
		# Find ALL gamescope windows and move them
		xdotool search --class "gamescope" 2>/dev/null | while read WINDOW_ID; do
			if [ ! -z "$WINDOW_ID" ]; then
				# Get current window position
				CURRENT_POS=$(xdotool getwindowgeometry "$WINDOW_ID" | grep Position | awk '{print $2}')
				DESIRED_POS="0, 0"

				# Only move if not already in position
				if [ "$CURRENT_POS" != "$DESIRED_POS" ]; then
					echo "Moving gamescope window $WINDOW_ID to 0,1080"
					xdotool windowmove "$WINDOW_ID" 0 0
					# xdotool windowsize "$WINDOW_ID" 5760 1080
				fi

				# FORCE it to be above everything else, including Steam
				# echo "Forcing gamescope window $WINDOW_ID to top layer"
				# wmctrl -i -r "$WINDOW_ID" -b add,above
				# xdotool windowraise "$WINDOW_ID"
			fi
		done
		sleep 2
	done

chmod +x /.config/openbox/gamescope-positioner.sh

As insurance, this script catches, sizes, and forcibly moves gamescope windows to 0,0, which is where (in most cases) the top-left corner of the monitor span will be. This script is launched as part of the Login autostart.

###
Autologin TTY
###
tba