Skip to content

Instantly share code, notes, and snippets.

@stevebrun
Last active November 27, 2022 20:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevebrun/f4cb3e2f5ea8bf3b08e825af20bdfb67 to your computer and use it in GitHub Desktop.
Save stevebrun/f4cb3e2f5ea8bf3b08e825af20bdfb67 to your computer and use it in GitHub Desktop.
Launch Steam Desk's "Desktop Mode" from within "Gaming Mode"
#!/bin/bash
#
# Launch Steam Desk's "Desktop Mode" from within "Gaming Mode".
# https://www.reddit.com/r/SteamDeck/comments/wycp1r/comment/ilw1cov/
# https://www.reddit.com/user/FineWolf/
# Friday, August 26, 2022
#
# Commented by Steven Brunwasser
# Sunday, October 23, 2022
#
# Instructions
# ------------
#
# - Save this file to the bin folder in your Home directory: ~/bin
# - Mark the file as executable.
# - In Dolphin, right-click the file and open Properties.
# In the Permissions tab, enable the "Is executable" checkbox.
# - Or, in Konsole, use the following command:
# chmod +x ~/bin/desktopmode.sh
# - Add the script to Steam as a non-Steam game.
# - In the Games menu, select "Add a Non-Steam Game to My Library...".
# - Click "BROWSE..." and navigate to "/home/deck/bin".
# - Change the "File type" from "Applications (*.desktop)" to "All Files".
# - Select "desktopmode.sh", click "OPEN", then "ADD SELECTED PROGRAMS'.
# - Give the script a proper name in your Steam library.
# - Navigate to the "desktopmode.sh" page in your Steam library.
# - Click on the gear icon and select "Properties...".
# - Use the first textbox to change the name to "Desktop Mode".
#
# You can use BoilR to give the "Desktop Mode" page proper icons and images
# from SteamGridDB.
#
# - Download and install BoilR from Flathub:
# https://flathub.org/apps/details/io.github.philipk.boilr
# - Get an API key from SteamGridDB for BoilR.
# - Sign in to SteamGridDB with your Steam account.
# https://www.steamgriddb.com/login
# - Copy the SteamGridDB API key for your account.
# https://www.steamgriddb.com/profile/preferences/api
# - In BoilR, go to "Settings" and paste your SteamGridDB API key into
# the "Authentication key" field. Make sure to check "Download images".
# - Click the floppy disk icon at the bottom of the window to save.
# - Set the SteamGridDB ID for "Desktop Mode" to download Steam Deck icons.
# https://www.steamgriddb.com/game/5321601
# - In BoilR, go to "Images" and click on "Desktop Mode".
# - Click "Click here if the images are for a wrong game".
# - Change the "SteamGridDB ID" to 5321601.
# - Set the grid image, hero image, and icon.
# - In BoilR, go to "Images" and click on "Desktop Mode".
# - Click on "Grid", "Hero", "Icon", etc. to select images.
# - When you're done, click on "Import Games".
# - Click on the button at the bottom of the window with the picture of an
# arrow pointing from a game controller to the Steam icon to save your
# changes.
# - Restart Steam to see the new images on the "Desktop Mode" library page.
#
# Exit on any failure.
set -eo pipefail
# Check to make sure we have information about the screen.
if [ -z "${DISPLAY:-}" ]; then
echo 'No $DISPLAY attached to current session' >&2
exit 2
fi
# Check to make sure we're running in "Gaming Mode".
# We don't want to launch "Desktop Mode" when we're already in it.
if [ -z "${GAMESCOPE_WAYLAND_DISPLAY:-}" ]; then
zenity --error --text="This script can only be run in a gamescope session."
exit 1
fi
# Get information about the screen's resolution.
# We use this to make sure the desktop uses the full screen.
_DISPLAY_RESOLUTION="$(xdpyinfo | awk '/dimensions/ {print $2}')"
# Make sure all shared libraries are loaded in their default order.
unset LD_PRELOAD
# Launch the KDE Plasma desktop environment to enter "Desktop Mode".
exec startplasma-wayland \
--xwayland --x11-display "${DISPLAY}" \
--no-lockscreen \
--width "${_DISPLAY_RESOLUTION%x*}" \
--height "${_DISPLAY_RESOLUTION#*x}" \
-- plasma_session
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment