Simple script and guide to make OBS Studio function like ShadowPlay for Linux.
(I didn't know anywhere else to upload this)
In order to make this function, you have to use OBS Studio (https://obsproject.com/). You should be able to install it from your package manager (apt, pacman, dnf) or Flathub.
This script is really simple, it makes a directory in your Videos folder in Home named after the current active window when activated. Then, it moves anything in a folder (such as your replay) to the newly created folder.
I don't fuckin' know if this is a issue with me or just OBS but some and I mean only some games run at 60hz when I use XSHM screen capture with OBS. Since I use a 144hz monitor, this is annoying. If this also occurs to you, you can fix it by making manual scenes for the games where OBS will capture them with Window Capture (Xcomposite). Of course, this wouldn't be real replay software if it didn't do that automagically. For this, use "Automatic Scene Switcher" in tools. I made a picture below to describe how I use it.
I've read that there are some issues concerning keybinds with Wayland, making it so that you couldn't save a replay with OBS Studio outside the app itself. If you have these issues, I do not know how to solve them as I use X11.
Though, if you really want this you could try using X11 with your machine. You should be able to choose between X11 and Wayland from the login screen. (If you use Garuda Linux or Linux Mint you should have X11 by default, and if you use Fedora it should be Wayland by default. I do not know about the other distros, so search up your distro and Wayland and browse around.)
If you're on Plasma, go to your notifcation settings and make sure Normal Notications appearing over fullscreen windows is checked, otherwise you won't get the notifcation a replay was saved in games.
Simply make this script executable (via chmod +x or checking Executable in the properties of the file using your file manager) and tell your desktop manager (Plasma, GNOME, Xfce, etc) to execute it when you press a keybind or certain keyboard combination. What keybind it uses is up to you. Then, you'll have to make a folder in your Videos directory named "temp_replays" (if you wish to change the name you will have to edit the script itself) and tell OBS Studio to save it's replays/videos there.
However, in order to get it's desired effects you'll have to assign the same shortcut that OBS Studio uses to save it's replays.
First, we want to enable Replay Buffer, if you already know how to do this just skip this step and make sure OBS save it's videos to ~/Videos/temp_replays.
Go to your Output settings in OBS and make sure Advanced mode is on.
After that, go to "Replay Buffer" and turn it on. You can choose how much seconds you want saved. Though, from my experience it shaves off 4 seconds from saved replays. So, simply add 4 to whatever you want just in case.
Afterwards, make sure your recording settings is set to a bitrate for whatever resoulution you want (i.e 15mbps-20mbps for 1080) and make sure the rate control is VBR.
Now, assign a keyboard shortcut to save replays (MAKE SURE THIS IS THE SAME KEYBIND YOU USE TO RUN THE SCRIPT) .
Last but not least, make sure all videos are saved in ~/Videos/temp_replays.
Of course, you want to do a Screen Capture scene for the replay, so it captures your monitor.
After that, you should be able to use the keybind you assigned to both OBS Studio and the script to save replays and have it placed in the folder of your active window. You know it works if you see this when pressing the keybind. Also, it will tell you where the video is saved.
Go to General settings and check these.
Then, make your system startup OBS Studio with the argument "--startreplaybuffer"
If you can't assign arguments to the startup process (for whatever reason) simply make your computer run "obs --startreplaybuffer" on startup. (Screenshots are for KDE Plasma)