Launching scripts from GNOME shortcuts

September 24, 2022

As of at least 2022-09-24, launching small scripts that spawn a rofi interface via the GNOME shell shortcuts interface would fail for me with the following message:

app-gnome-\x7e\x2fcontrol.sh-3565.scope: No PIDs left to attach to the scope's control group, refusing.
app-gnome-\x7e\x2fcontrol.sh-3565.scope: Failed with result 'resources'.
Failed to start Application launched by gsd-media-keys.

My control script would be executable and located at ~/control.sh and launch something like rofi -dmenu -i <choices>. I had the association (e.g. for <Super>-i) entered through the GNOME settings keyboard shortcuts as command ~/control.sh and this used to work just fine for years.

Researching the error message, it now seems you are supposed to set your own “scope” (purportedly somehow related to cgroups) and use systemd-run.

The fix was to change the command ~/control.sh to an absolute path, prefixed by systemd-run:

systemd-run --scope --user /home/<user>/control.sh