Skip to main content

sunshine-res

sunshine-res is a small command‑line utility that automatically adjusts your display resolution and HDR settings to match a target resolution that your game or application expects. It works on modern Linux desktop environments that expose a standard way to query and set display modes.

Installation

You can install sunshine-res system‑wide (or inside a virtualenv) with:

pipx install sunshine-res

The tool installs a console script called sunshine-res that can be invoked from anywhere.

Usage

The utility accepts three commands:

Command Description
do Set the monitor to the target resolution (as specified by the environment variables below).
undo Revert the monitor to the original mode that was active before the last do.
auto Toggle between the two states. If a previous do was performed, undo will be run; otherwise do will be executed. This is the default if no command is given.

Configuring Sunshine

After installing sunshine-res, you must configure Sunshine to use the utility.

  1. Open Sunshine and go to the Configuration tab (probably https://localhost:47990/config)
  2. In the Command Preparations section, click "+ Add" to add a new command
  3. Set the do and undo commands to sunshine-res do and sunshine-res undo respectively
  4. Save

Multiple outputs

Sunshine-res will only manage the resolution of a single display output. By default, it will use the first one present reported by the relevant control tool. This is probably fine for many users, but if you have multiple displays and require specifying a particular display, you can append --target-output/-o followed by the display name reported by the appropriate command line tool for your desktop environment.

Eg.

sunshine-res --target-output HDMI-2 auto

If you are unsure of what output name to use, look at the outputs listed by the appropriate tool for your desktop environement, in the Supported Desktop Environments table.

Supersampling

Rather than having the server match the client resolution exactly, a supersampling factor can be added to instruct the server to render higher resolution images than your client and allow the client to downscale them.

This can be done by adding the --supersample option to the sunshine-res command.

Eg.

sunshine-res --supersample 1.5 auto

This would attempt to render at 1.5× the target resolution, so if the target is 1920×1080, the server would render at the nearest resolution at or greater than 2880×1620 and the client would downscale to 1920×1080. Since the client may not support arbitrary resolutions, the server will choose the closest available mode that is at least as large as the supersampled resolution.

Example

# Set resolution to 1920×1080 @ 60 Hz, HDR disabled
SUNSHINE_CLIENT_WIDTH=1920 SUNSHINE_CLIENT_HEIGHT=1080 SUNSHINE_CLIENT_FPS=60 SUNSHINE_CLIENT_HDR=false sunshine-res do

# Revert to original resolution
sunshine-res undo

# Toggle
sunshine-res

Environment variables are optional and typically set by Sunshine; defaults are:

  • SUNSHINE_CLIENT_WIDTH – 1920
  • SUNSHINE_CLIENT_HEIGHT – 1080
  • SUNSHINE_CLIENT_FPS – 60
  • SUNSHINE_CLIENT_HDR – false

Supported Desktop Environments

Desktop Implementation
KDE Uses kscreen-doctor to query and set monitor modes.
COSMIC Uses cosmic-randr to query and set monitor modes.
Gnome Uses gnome-randr from gnome-randr-rust to query and set monitor modes.

The tool automatically detects the current desktop by inspecting the XDG_CURRENT_DESKTOP, XDG_SESSION_DESKTOP, or SESSION_DESKTOP environment variables. If no supported desktop is detected, the command will exit with an error.

How It Works

  1. Detect Desktop – The first step is to determine whether you are running KDE or Cosmic.
  2. Query Current Mode – The relevant command (eg. kscreen-doctor or cosmic-randr) returns a description of the current monitor configuration.
  3. Find Matching Mode – The tool searches the available modes for one that matches the target resolution and has the closest refresh rate that is not below the requested SUNSHINE_CLIENT_FPS.
  4. Apply Mode – The chosen mode is applied with the same HDR setting you requested.
  5. Persist State – The original monitor state is written to ~/.config/sunshine/last_mode.json so that undo can restore it later.

Common Errors & Troubleshooting

Error What it means How to fix
ERROR: Could not determine current desktop No desktop environment variable was found. Make sure you are running the command from an active session. On some shells you may need to export XDG_CURRENT_DESKTOP=KDE or COSMIC manually.
Could not find resolution manager for desktop <name> The desktop variable contains an unsupported value. Check the spelling of the desktop name. Supported values are KDE and COSMIC and GNOME.
Did not find mode matching <width>x<height> at <output> The monitor does not advertise the requested resolution. Verify that the resolution is supported by your monitor or try a different resolution.
Could not identify current mode The underlying command returned an unexpected format. Ensure cosmic-randr, gnome-randr, or kscreen-doctor is installed and working. Run the command manually (cosmic-randr list --kdl, gnome-randr, or kscreen-doctor --json) to confirm.
Permission denied The command was unable to write to ~/.config/sunshine/last_mode.json. Verify that you have write permissions to ~/.config/sunshine.

If you encounter an unhandled exception, try running the command with the -v flag (if implemented) or inspect the stack trace. The project is open source, so feel free to file an issue.

Metadata

Release files for sunshine-res 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sunshine-res 1.0.1
File Size Uploaded Provenance
sunshine_res-1.0.1.tar.gz 10.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sunshine-res 1.0.1
File Interpreter ABI Platform
sunshine_res-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 22.8 kB

Release files / sunshine_res-1.0.1.tar.gz

Download URL sunshine_res-1.0.1.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0ff3884fc7a8f6b5c20e09a9570ef41f8dee8f71a06f909697897c25fe4e7f37
BLAKE2b-256 checksum
How to use checksums
e94f1490d05ca50e254e7cbde1a377ff6fe8cd28b79d049ad7c4cf126068d366
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.14.2 Linux/5.15.0-173-generic

Release files / sunshine_res-1.0.1-py3-none-any.whl

Download URL sunshine_res-1.0.1-py3-none-any.whl
Size 12.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b022b4fb99c4531423a746225c471781cf8ec292bad2875a294e730b951957d3
BLAKE2b-256 checksum
How to use checksums
a3ee885683a491af7f9502b7b2135373450d85100d814b887d0348401a90c125
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.14.2 Linux/5.15.0-173-generic

Security for sunshine-res 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page