Skip to content

Instantly share code, notes, and snippets.

@alexlnkp
Last active January 26, 2025 02:25
Show Gist options
  • Save alexlnkp/9b6f83deff5e3f90458c804d5884cf46 to your computer and use it in GitHub Desktop.
Save alexlnkp/9b6f83deff5e3f90458c804d5884cf46 to your computer and use it in GitHub Desktop.
gpu-screen-recorder on Hyprland
This is an unofficial guide I wrote myself to let more people learn about this wonderful thing.
The instructions will be mostly listed for Arch Linux, however sources provided also
include step by step tutorial for any other distribution.
Most importantly, this is not a 100% complete guide,
moreso just an overview of a setup you can have.
If you're having issues - consult with the README in the git tree.
https://git.dec05eba.com/gpu-screen-recorder/about/
STEP BY STEP GUIDE ON GPU-SCREEN-RECORDER ON LINUX
INSTALLATION
First of all, install gpu-screen-recorder[0], obviously.
If you're on arch - you can use an AUR maintained by the author of the program itself!
Just search for `gpu-screen-recorder` on AUR and go from there[1],
or just use an AUR helper like yay (`yay -S gpu-screen-recorder`).
FRONTEND
gpu-screen-recorder comes with no GUI! That is for experienced wizards,
and there's nothing to be ashamed of if you're not one of those just yet!
You can install a nice GUI frontend for gpu-screen-recorder made by...
the author of gpu-screen-recorder[2]!
I personally use `gpu-screen-recorder-gtk` from AUR[3], but if you want a more seamless
transition from NVIDIA ShadowPlay, then you should check out `gpu-screen-recorder-ui`[4]!
SETUP
If you're on any usual window-manager or desktop environment, then You shouldn't have any issues
with setting up the `gpu-screen-recorder` and its frontends to read hotkeys globally.
If you're on Hyprland, however, You WILL have issues with global hotkeys.
How to workaround those is described more in-depth in [SETUP : HYPRLAND]
SETUP : HYPRLAND
As You might've noticed, the hotkeys don't work! The reason is that wayland protocol
doesn't like having those global. For a more in-depth explanation check out this
blogpost: https://dec05eba.com/2024/03/29/wayland-global-hotkeys-shortcut-is-mostly-useless/
How do we work around this issue, though? Well, it won't be pretty.
You see, when `gpu-screen-recorder` is recording, user can send signals to it.
You might already guess where this is going. `gpu-screen-recorder` handles every signal manually,
since we're recording a video, continuously, just killing the process on-demand would
corrupt our video! Instead what `gpu-screen-recorder` does upon receiving SIGINT is
finalize the video and save it to disk. This effectively works the same way as just stopping recording.
So, we then open our ~/.config/hypr/hyprland.conf and add a few new lines to it:
```
# You can grab `code:<num>` for any key on your keyboard by using `wev` and looking for the `key` value in these lines:
# [14: wl_keyboard] key: serial: 130782; time: 84775266; key: 75; state: 1 (pressed)
# sym: F9 (65478), utf8: ''
#
# Here we can see that upon pressing F9 we get `key: 75`, which we place in `code:75` and thus achieve a key in format
# Hyprland can understand from the config files.
# For saving a replay clip. code:76 corresponds to F10 key.
bind = , code:76, exec, killall -SIGUSR1 gpu-screen-recorder
# For saving a recording that is running. code:75 corresponds to F9 key.
bind = , code:75, exec, killall -SIGINT gpu-screen-recorder
# For pausing/unpausing recording that is running. code:95 corresponds to F11 key.
bind = , code:95, exec, killall -SIGUSR2 gpu-screen-recorder
```
You can only keep lines which you'll need. Make sure to modify it to fit your preferences!
After all that, we can test out the recording capabilites by first starting the recording
using any way you want. I personally prefer using the `-gtk` frontend for this.
Then, clicking the keys you bound you can see that they work!
(small note: `killall -SIGUSR1 gpu-screen-recorder` will only affect replay mode recording,
`killall -SIGINT gpu-screen-recorder` will affect recording, streaming and replay mode,
`killall -SIGUSR2 gpu-screen-recorder` will only affect recording mode)
For a cheatsheet of what signal does what - check the about section of the repo! [0]
SOURCES YOU SHOULD CHECK OUT IN-DEPTH
[0]: https://git.dec05eba.com/gpu-screen-recorder/about/
[1]: https://aur.archlinux.org/packages?K=gpu-screen-recorder
[2]: https://git.dec05eba.com/gpu-screen-recorder-gtk/about/
[3]: https://aur.archlinux.org/packages/gpu-screen-recorder-gtk
[4]: https://git.dec05eba.com/gpu-screen-recorder-ui/about/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment