Last active
October 6, 2025 01:07
-
-
Save NaviVani-dev/9a8a704a31313fd5ed5fa68babf7bc3a to your computer and use it in GitHub Desktop.
DualScope: Run two steam instances with gamescope with different user accounts (split screen on any game!)
This file contains hidden or 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 | |
| # a little script i made to open two gamescope sessions of steam | |
| # i SUCK at making bash script, so expect a lot of bugs or issues :< | |
| # made for arch linux in mind | |
| # you need another account on your device to use this | |
| # if u use pipewire and your audio is not working, take a look at this: | |
| # https://wiki.archlinux.org/title/PipeWire#Multi-user_audio_sharing | |
| # The gamescope params for both of the processes | |
| GAMESCOPE_PARAMS="-e -b -w 960 -h 360 -W 1440 -H 540" | |
| # Params for both steams | |
| STEAM_PARAMS="-gamepadui" | |
| # The secondary account you will use | |
| RUNAS_ACC="YOUR SECONDARY ACCOUNT" | |
| GAMESCOPE_BIN="/usr/bin/gamescope" | |
| RUNAS_BIN="/usr/bin/run-as" | |
| STEAM_BIN="/usr/bin/steam" | |
| CHANGED_DEVICES=() | |
| GAMESCOPE_PRIMARY_PID="" | |
| GAMESCOPE_SECONDARYPID="" | |
| # hiding kde panels using this: | |
| # https://github.com/luisbocanegra/plasma-panel-colorizer | |
| toggle_panels() { | |
| local state="$1" | |
| local value="false" | |
| if [ "$state" = "true" ]; then | |
| value="true" | |
| fi | |
| local status="string:stockPanelSettings.visible {\"enabled\": true, \"value\": $value}" | |
| dbus-send --session --type=signal /preset "luisbocanegra.panel.colorizer.all.property" "$status" | |
| } | |
| startup() { | |
| echo "Hiding the KDE panels!" | |
| toggle_panels "false" | |
| } | |
| cleanup() { | |
| echo "Showing the KDE panels again" | |
| toggle_panels "true" | |
| echo "Returning ownership to every device" | |
| return_devices_ownership | |
| if [[ -n "$GAMESCOPE_PRIMARY_PID" ]]; then | |
| echo "Killing primary gamescope..." | |
| kill -TERM "$GAMESCOPE_PRIMARY_PID" 2>/dev/null || true | |
| fi | |
| if [[ -n "$GAMESCOPE_SECONDARY_PID" ]]; then | |
| echo "Killing secondary gamescope..." | |
| kill -TERM "$GAMESCOPE_SECONDARY_PID" 2>/dev/null || true | |
| fi | |
| } | |
| show_devices_list() { | |
| local devices="" | |
| local name="" | |
| while IFS= read -r line; do | |
| if [[ $line == N:\ Name=* ]]; then | |
| name=$(echo "$line" | sed 's/N: Name=//' | tr -d '"') | |
| fi | |
| if [[ $line == *Handlers=* ]]; then | |
| local event_dev=$(echo "$line" | grep -o 'event[0-9]*' | sed 's/event//') | |
| if [[ -n $name && -n $event_dev ]]; then | |
| # aditional info 4 controllers | |
| local device_info="" | |
| if [[ $name == *"Xbox"* || $name == *"Controller"* || $name == *"Gamepad"* || $name == *"Joystick"* ]]; then | |
| device_info=" " | |
| elif [[ $name == *"Keyboard"* || $name == *"keyboard"* ]]; then | |
| device_info=" ⌨️" | |
| elif [[ $name == *"Mouse"* || $name == *"mouse"* ]]; then | |
| device_info=" " | |
| fi | |
| devices+="$event_dev - $name$device_info"$'\n' | |
| name="" | |
| fi | |
| fi | |
| done < /proc/bus/input/devices | |
| echo -e "$devices" | |
| } | |
| change_device_ownership() { | |
| local profile="$1" | |
| local device="$2" | |
| local device_path="/dev/input/event$device" | |
| sudo chown "$profile" "$device_path" | |
| sudo chmod 600 "$device_path" | |
| } | |
| get_devices_to_change() { | |
| local profile="$1" | |
| echo "Select the devices to transfer for the $profile profile:" | |
| show_devices_list | |
| echo "Please, input your device list divided by a comma (1,2,3,4,etc):" | |
| read input_string | |
| IFS=',' read -r -a NEW_DEVICES <<< "$input_string" | |
| CHANGED_DEVICES+=("${NEW_DEVICES[@]}") | |
| for device in "${NEW_DEVICES[@]}"; do | |
| change_device_ownership "$profile" "$device" | |
| done | |
| } | |
| return_devices_ownership() { | |
| for device in "${CHANGED_DEVICES[@]}"; do | |
| local device_path="/dev/input/event$device" | |
| sudo chown root:input "$device_path" "$device_path" | |
| sudo chmod 660 "$device_path" "$device_path" | |
| done | |
| } | |
| primary_gamescope() { | |
| eval "$GAMESCOPE_BIN $GAMESCOPE_PARAMS -- $STEAM_BIN $STEAM_PARAMS" | |
| GAMESCOPE_PRIMARY_PID=$! | |
| } | |
| secondary_gamescope() { | |
| eval "sudo $RUNAS_BIN -X $RUNAS_ACC -- env PULSE_SERVER=tcp:127.0.0.1:4713 $GAMESCOPE_BIN $GAMESCOPE_PARAMS -- $STEAM_BIN $STEAM_PARAMS" | |
| GAMESCOPE_SECONDARY_PID=$! | |
| } | |
| trap cleanup EXIT INT TERM | |
| main() { | |
| echo "DualScope by NaviVani " | |
| if [[ $EUID -eq 0 ]]; then | |
| echo "Running as sudo, exiting..." | |
| exit 1 | |
| fi | |
| for bin in "$GAMESCOPE_BIN" "$STEAM_BIN" "$RUNAS_BIN"; do | |
| if [[ ! -x "$bin" ]]; then | |
| echo "The $bin executable was not found, exiting..." | |
| exit 1 | |
| fi | |
| done | |
| get_devices_to_change "$(whoami)" | |
| get_devices_to_change "$RUNAS_ACC" | |
| echo "Killing steam before starting..." | |
| pkill steam | |
| while pgrep steam > /dev/null; do | |
| sleep 1 | |
| done | |
| startup | |
| echo "Opening gamescope sessions!" | |
| secondary_gamescope & | |
| primary_gamescope | |
| } | |
| main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this script, I'm having one small issue though. I'm on Nobara Linux (copied over the run-as.py and enable_graphical_services.sh) and everything seems to work fine. But I can't lock input to specific users. As in, the controller controls both instances and the keyboard+Mouse control both instances as well. Any help would be appreciated.
I've been using AI to try to help me but it sends me down pointless rabbithole after pointless rabbithole, chasing my tail on things that didn't need fixing in the first place.