Skip to content

Instantly share code, notes, and snippets.

@Dregu
Last active June 14, 2026 01:54
Show Gist options
  • Select an option

  • Save Dregu/4c0dbb2582835e5d95e06c4bf7624e3b to your computer and use it in GitHub Desktop.

Select an option

Save Dregu/4c0dbb2582835e5d95e06c4bf7624e3b to your computer and use it in GitHub Desktop.
Scripts for automatic sunshine virtual display on sway or hyprland with custom resolution matching moonlight client
# make sure sunshine is using "wlr" capture mode to see headless displays
# create a new "Headless" app in sunshine for virtual display and set:
# do commands
sh -c "hyprctl keyword monitor HEADLESS-2,${SUNSHINE_CLIENT_WIDTH}x${SUNSHINE_CLIENT_HEIGHT}@${SUNSHINE_CLIENT_FPS},auto,1"
hyprctl keyword monitor eDP-1,disable
# matching undo commands
hyprctl keyword monitor HEADLESS-2,disable
hyprctl reload
# now you can connect to the real "Desktop" app or the "Headless" screen
# that automatically matches moonlight client res and disables real display
# configure your real monitor
monitor = eDP-1,preferred,auto,auto
# configure your virtual monitor, you probably want this to start disabled cause you can't see it
monitor = HEADLESS-2,disable
exec-once = hyprctl output create headless
# duh
exec-once = sunshine
# blah blah rest of your hyprland config
# make sure sunshine is using "wlr" capture mode to see headless displays
# create a new "Headless" app in sunshine for virtual display and set:
# do commands
sh -c "swaymsg output HEADLESS-1 enable; swaymsg output HEADLESS-1 mode ${SUNSHINE_CLIENT_WIDTH}x${SUNSHINE_CLIENT_HEIGHT}@${SUNSHINE_CLIENT_FPS}Hz"
swaymsg output eDP-1 disable
# matching undo commands
swaymsg output HEADLESS-1 disable
swaymsg output eDP-1 enable
# now you can connect to the real "Desktop" app or the "Headless" screen
# that automatically matches moonlight client res and disables real display
# configure your real monitor
output eDP-1 mode 1366x768
# configure your virtual monitor, you probably want this to start disabled cause you can't see it
output HEADLESS-1 mode 1920x1080 disable
exec swaymsg create_output HEADLESS-1
# duh
exec sunshine
# blah blah rest of your sway config
@Awesomeplayer165

Copy link
Copy Markdown

You are an absolute legend!!!

@Internetperson-dev

Copy link
Copy Markdown

I found this guide from this Reddit thread.

It may be worth checking your resolution if your device has a non-standard aspect ratio by using this tool in a full screen window.

Maybe someone could develop a solution to automate this for game streaming?

@Sabin-DC

Sabin-DC commented Apr 1, 2026

Copy link
Copy Markdown

I'm struggling to get this working, are you copy pasting these do commands as is? It's not disabling the monitor for me unless i put the disable command also inside the shell command. Also, even with that workaround, my sunshine is connecting to a black screen, i am using wlroots as well. Not sure what I could be doing wrong here

Disable commands also dont work as is and require me putting inside sh -c itself too

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