diff options
-rw-r--r-- | README.md | 17 | ||||
-rw-r--r-- | TODO | 37 | ||||
-rw-r--r-- | com.dec05eba.gpu_screen_recorder.appdata.xml | 821 | ||||
-rw-r--r-- | meson.build | 3 | ||||
-rw-r--r-- | project.conf | 4 | ||||
-rw-r--r-- | src/main.cpp | 322 |
6 files changed, 197 insertions, 1007 deletions
@@ -4,10 +4,17 @@ GTK frontend for [GPU Screen Recorder](https://git.dec05eba.com/gpu-screen-recorder/about/).\ There is a new alternative UI for GPU Screen Recorder in the style of ShadowPlay available here: [GPU Screen Recorder UI](https://git.dec05eba.com/gpu-screen-recorder-ui/). +## Notes +The program has to be launched from your application launcher or hotkeys may not work properly in your Wayland compositor (this is the case with GNOME). + +## Deprecation +This project is no longer being developed as it has been superseded by [GPU Screen Recorder UI](https://git.dec05eba.com/gpu-screen-recorder-ui/) which has more features. This project will remain available until GPU Screen Recorder UI can run as a regular window, just like GPU Screen Recorder GTK does.\ +The `com.dec05eba.gpu_screen_recorder.appdata.xml` file has been moved to the [AppData](https://git.dec05eba.com/gpu-screen-recorder-appdata/) repository. + # Installation If you are using an Arch Linux based distro then you can find gpu screen recorder gtk on aur under the name gpu-screen-recorder-gtk (`yay -S gpu-screen-recorder-gtk`).\ If you are running another distro then you can run `sudo ./install.sh`, but you need to manually install the dependencies, as described below.\ -You can also install gpu screen recorder from [flathub](https://flathub.org/apps/details/com.dec05eba.gpu_screen_recorder). This flatpak includes both this UI and gpu-screen-recorder so no need to install that first. +You can also install gpu screen recorder from [flathub](https://flathub.org/apps/details/com.dec05eba.gpu_screen_recorder) which includes this UI. # Dependencies GPU Screen Recorder GTK uses meson build system so you need to install `meson` to build GPU Screen Recorder GTK. @@ -25,10 +32,8 @@ There are also additional dependencies needed at runtime: * [GPU Screen Recorder](https://git.dec05eba.com/gpu-screen-recorder/) +# Reporting bugs, contributing patches, questions or donation +See [https://git.dec05eba.com/?p=about](https://git.dec05eba.com/?p=about). + # Screenshots  - -# Donations -If you want to donate you can donate via bitcoin or monero. -* Bitcoin: bc1qqvuqnwrdyppf707ge27fqz2n9y9gu7lf5ypyuf -* Monero: 4An9kp2qW1C9Gah7ewv4JzcNFQ5TAX7ineGCqXWK6vQnhsGGcRpNgcn8r9EC3tMcgY7vqCKs3nSRXhejMHBaGvFdN2egYet @@ -9,42 +9,16 @@ Add translation support (using gettext, which uses .mo files and _ macro). It sh But how? maybe have a page that links to the english translation files (or translation directory) in git and give instructions, telling them to copy the file content and then send me the file by email with the language name (then I can add it to the correct) file with correct locale. Or if they know how to use git they can use that directly. -Add option to start replay on system startup (use the gpu screen recorder systemd file?) and use the settings from the replay page. - Dont add this option if not running systemd, or disable the button then. - Fix screen capture breaking after suspend/monitor change on nvidia x11. - Add note about replaying can get bugged on suspend unless nvidia reg for suspend is added (because cuda breaks, nvidia driver bug). - Detect suspend before it happens and unload cuda/nvenc then and reload after suspend. This is a workaround to nvidia driver bug that breaks cuda on suspend. - Disable the gpu screen recorders aur/source package systemd service if enabled in the gui since these are two different services. Or make that service and gui service the same and work with the same (gui) config file. Remove the need to install gpu screen recorder flatpak as system. This can now be done because of kms-server-proxy. Implement profiles to quickly switch between settings. Use https://hosted.weblate.org/ for translation. -Detect game name by using x11 window class or title. Fallback to finding pressure vessel, find the binary is runs and get the directory name directly under the proton game list directory. Fallback to pure wine. x11 window class works in xwayland too. - Have separate options for each record option (stream, record and replay) or have option to use profiles. Remake the gui and have a proper overlay! on wlroots and kde use https://wayland.app/protocols/wlr-layer-shell-unstable-v1. -Add refresh button for audio devices. Put it beside the "add" button. In the new ui this should update automatically without a button. - -Gray out monitor capture on intel if plane is compressed. Show the user to desktop portal capture instead. - -Look at showmethekey https://github.com/AlynxZhou/showmethekey to see how to do global hotkeys without x11/wayland. The password prompt for this can be removed by using polkit rules, this is how SwayOSD does it. - doing this in the flatpak requires --device=input in the flatpak manifest if we are doing it without hack where we launch an external process, running outside the flatpak with root access. - A single flatpak can only be installed either system-wide or user, so there can be a check if it's installed system-wide or user and it will only match one. With this information we can guaranteed know the flatpak directory of the running gpu screen recorder instance. The command `flatpak info -l com.dec05eba.gpu_screen_recorder` can also be used and is available for all flatpak users. Re-renable hotkeys on hyprland after it's fixed in the hyprland desktop portal. Or use hyprland specific protocol to do it ourselves, and it also works better. -Replay on startup should be its own page with its own settings for everything and should not allow enabling the feature unless global hotkeys can be enable. - To make sure this works, create a separate program to handle global hotkeys with root access to make it work for every user and keys should be registered by requiring root access (every time its changed), with a confirm button. - Or have a predefined set of keys that can be changed. Also have a key to show the gui. - The replay on startup should be this gpu screen recorder gtk program but should launch a separate gui (in a different cpp file) - and should be a single page with start/stop button and whatever. It should also show a systray similar to the default one but with only - start/stop/save/exit button. The UI is needed for gnome users that dont have a systray! - Maybe create gnome extension so that gnome users can see recording status, or mention to the user that it's a gnome limitation. - The system startup program should work like the gpu screen recorder systemd daemon but start gpu screen recorder gtk with a special argument to launch it into this - replay mode. The replay mode program should loop and launch gpu screen recorder, restarting it if it crashes. If it crashes show an error dialog to the user - and if hotkeys cant be registered then also show an error. - Notifications are not shown on kde plasma while using desktop portal capture (system-wide). This is a design choice by kde, see https://invent.kde.org/plasma/xdg-desktop-portal-kde/-/blob/master/src/screencast.cpp?ref_type=heads#L41 . The DoNotDisturb.WhenScreenSharing config controls this. This can be bypassed by making the notification critical. Maybe notifications should be set as critical? but only on kde. Maybe we should create our own notification system with gtk layer shell (which is supported by every platform except gnome wayland). On gnome wayland maybe we can fallback to x11? we need to add back --socket=x11 and remove --socket=fallback-x11 from flatpak manifest. @@ -52,19 +26,8 @@ Notifications are not shown on kde plasma while using desktop portal capture (sy Maybe map the drm framebuffer to opengl with write permission and draw to that opengl texture with a framebuffer. That would allow us to draw on the screen anywhere on any wayland compositor (and x11 amd/intel). We can also do this after the video frame has been captured to not include it in the video. Maybe use drm overlay plane, if possible. -For replay on system startup add functionality to only record if an application is fullscreen (on the focused monitor, or any monitor if not possible). - This is easy to do with x11. For hyprland/sway we can maybe use hyprctl/swaymsg. On kde maybe we can do something similar to this: https://github.com/jinliu/kdotool. For gnome maybe do something like this: https://github.com/ActivityWatch/aw-watcher-window/pull/46/files - -When replay on system startup option is added also install gsr-nvidia.conf and tell the user to reboot and explain the issue. - Start recording after showing start recording notification has disappeared, not at the same time. -Use modprobe command. modprobe on system startup in modprobe.d directory is only available for udev, other systems need to add it to linux kernel boot parameters (is this also needed for nvidia open kernel module driver?). - -Save gpu screen recorder status in $XDG_RUNTIME_DIR. - -Add option to capture application audio. This should show a popup where you can use one of the available applications or a custom one and choose to record that application or all applications except that one. - Add profile option. Convert view to profile, add an option at the bottom that says "Edit profiles..." which should show a popup where you can create/remove profiles. New profiles should always be in advanced view. Move x11 hotkey code to its own file. diff --git a/com.dec05eba.gpu_screen_recorder.appdata.xml b/com.dec05eba.gpu_screen_recorder.appdata.xml deleted file mode 100644 index 0f54305..0000000 --- a/com.dec05eba.gpu_screen_recorder.appdata.xml +++ /dev/null @@ -1,821 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<component type="desktop-application"> - <id>com.dec05eba.gpu_screen_recorder</id> - <name>GPU Screen Recorder</name> - <summary>A shadowplay-like screen recorder for Linux. The fastest screen recorder for Linux</summary> - <developer_name>dec05eba</developer_name> - <metadata_license>CC0-1.0</metadata_license> - <project_license>GPL-3.0</project_license> - <url type="homepage">https://git.dec05eba.com/gpu-screen-recorder/about/</url> - <url type="bugtracker">https://github.com/dec05eba/gpu-screen-recorder-issues</url> - <url type="contribute">https://git.dec05eba.com/?p=about</url> - <url type="donation">https://git.dec05eba.com/?p=about</url> - - <supports> - <control>pointing</control> - <control>keyboard</control> - </supports> - - <description> - <p> - This is a screen recorder that has minimal impact on system performance by recording a monitor using the GPU only, similar to shadowplay on windows. This is the fastest screen recording tool for Linux. This screen recorder works on X11 and Wayland on AMD, Intel and NVIDIA. - </p> - <p> - This screen recorder can be used for recording your desktop offline, for live streaming and for nvidia-like instant replay, where only the last few minutes are saved. - </p> - <p>Supported video codecs:</p> - <ul> - <li>H264 (default)</li> - <li>HEVC (Optionally with HDR)</li> - <li>AV1 (Optionally with HDR. Not currently supported on NVIDIA if you use GPU Screen Recorder flatpak)</li> - <li>VP8</li> - <li>VP9</li> - </ul> - <p>Supported audio codecs:</p> - <ul> - <li>Opus (default)</li> - <li>AAC</li> - </ul> - <p> - At the moment the program comes with two different UIs. A gtk based one and a new experimental ShadowPlay-like fullscreen overlay UI. The gtk based UI will be removed in the future. - You can switch to the new UI by clicking on "Try out the new UI" and then after that is done press Left Alt+Z to open it. - </p> - <p>AV1 is currently not supported in the flatpak for Nvidia since GPU Screen Recorder uses an older ffmpeg version to support older Nvidia cards. Install GPU Screen Recorder from source or from AUR if you want to use AV1 on Nvidia.</p> - <p>For more information visit the GPU Screen Recorder homepage.</p> - <p>GPU Screen Recorder flatpak can install files in $HOME/.local/share/gpu-screen-recorder. If you want to uninstall GPU Screen Recorder then you will have to remove this directory manually.</p> - <p>If you tried out the new UI then a systemd service was added to ~/.local/share/systemd/user/gpu-screen-recorder-ui.service. If you want to uninstall GPU Screen Recorder then you will have to remove this file.</p> - </description> - - <launchable type="desktop-id">com.dec05eba.gpu_screen_recorder.desktop</launchable> - <screenshots> - <screenshot type="default"> - <caption>Front page</caption> - <image>https://raw.githubusercontent.com/dec05eba/com.dec05eba.gpu_screen_recorder/master/resources/front_page.jpg</image> - </screenshot> - <screenshot> - <caption>Settings page</caption> - <image>https://raw.githubusercontent.com/dec05eba/com.dec05eba.gpu_screen_recorder/master/resources/settings_page.jpg</image> - </screenshot> - <screenshot> - <caption>Simple view in the old UI</caption> - <image>https://raw.githubusercontent.com/dec05eba/com.dec05eba.gpu_screen_recorder/master/resources/screenshot1.png</image> - </screenshot> - <screenshot> - <caption>Advanced view in the old UI</caption> - <image>https://raw.githubusercontent.com/dec05eba/com.dec05eba.gpu_screen_recorder/master/resources/screenshot2.png</image> - </screenshot> - <screenshot> - <caption>Recording page in the old UI</caption> - <image>https://raw.githubusercontent.com/dec05eba/com.dec05eba.gpu_screen_recorder/master/resources/screenshot3.png</image> - </screenshot> - </screenshots> - - <releases> - <release version="5.1.4" date="2025-02-05"> - <description> - <ul> - <li>Fix virtual hotkey option not working with some keyboard remapping software such as kanata</li> - <li>Fix too long audio device name hiding the remove audio device button</li> - </ul> - </description> - </release> - <release version="5.1.3" date="2025-02-03"> - <description> - <ul> - <li>Fix unable to type keys (except hotkeys) when switching to new ui on steam deck (and possibly other devices)</li> - </ul> - </description> - </release> - <release version="5.1.2" date="2025-01-26"> - <description> - <ul> - <li>Fix hotkeys not working on some keyboards (usually laptops)</li> - </ul> - </description> - </release> - <release version="5.1.1" date="2025-01-25"> - <description> - <ul> - <li>Fix microphone volume being low when merging audio devices (don't normalize audio)</li> - </ul> - </description> - </release> - <release version="5.1.0" date="2025-01-24"> - <description> - <ul> - <li>Make hotkeys configurable, fix hotkey keyboard layout issues and add option to save replay with (ps4) controller</li> - <li>Make notification smoother on wayland and other wayland fixes</li> - <li>Improve startup time (fixes key getting grabbed for too long)</li> - </ul> - </description> - </release> - <release version="5.0.10" date="2025-01-18"> - <description> - <ul> - <li>Add a workaround for amd recording performance issue on wayland with a 10-bit monitor when recording a monitor instead of desktop portal. This is fixed in mesa version 25.0.0</li> - </ul> - </description> - </release> - <release version="5.0.9" date="2025-01-17"> - <description> - <ul> - <li>Workaround possibly incorrect opengl setup and buggy nvidia driver (uses glx instead of egl)</li> - <li>Workaround teamspeak bug causing teamspeak to crash when recording application audio</li> - <li>Fix possibility of monitor capture changing to another monitor on wayland when monitors are reconfigured</li> - <li>Fix overlay background not being transparent on sway (and other wlroots based wayland compositors) when opening the ui when a wayland window is focused</li> - </ul> - </description> - </release> - <release version="5.0.8" date="2025-01-08"> - <description> - <ul> - <li>Fix global hotkeys not working in the new UI on some older systems, such as Linux Mint 21.3. Requires restarting the new UI</li> - </ul> - </description> - </release> - <release version="5.0.7" date="2025-01-07"> - <description> - <ul> - <li>Fix UI opening on the wrong monitor on gnome and sometimes not being properly fullscreen</li> - <li>Support different keyboard layouts where Z is switched to another location on the keyboard</li> - </ul> - </description> - </release> - <release version="5.0.6" date="2025-01-05"> - <description> - <ul> - <li>Fix unable to open the UI on some kde plasma wayland systems when a wayland native application is focused</li> - <li>Only grab left alt for global hotkeys to allow AltGr+Z to be pressed to allow some characters to be typed on some keyboards, such as ż on a polish keyboard</li> - </ul> - </description> - </release> - <release version="5.0.5" date="2025-01-04"> - <description> - <ul> - <li>Fix some applications receiving mouse input when gpu screen recorder UI is open. Please report if this causes issues for you.</li> - <li>Make the old UIs popup menu text selectable to allow copying commands from it.</li> - </ul> - </description> - </release> - <release version="5.0.4" date="2025-01-01"> - <description> - <ul> - <li>Fix regression: incorrect window resulting in incorrect game name for video, and background for uncomposited x11</li> - </ul> - </description> - </release> - <release version="5.0.3" date="2024-12-31"> - <description> - <ul> - <li>Fix unable to properly add program to system startup on immutable distros</li> - </ul> - </description> - </release> - <release version="5.0.2" date="2024-12-31"> - <description> - <ul> - <li>Fix streaming not working in the new UI</li> - </ul> - </description> - </release> - <release version="5.0.1" date="2024-12-30"> - <description> - <ul> - <li>Open the running new UI when trying to launch it again instead of showing an error, to allow switching back to the old UI in case of errors</li> - </ul> - </description> - </release> - <release version="5.0.0" date="2024-12-29"> - <description> - <ul> - <li>Add a new experimental UI, a ShadowPlay-like fullscreen overlay UI with support for global hotkeys on any Wayland compositor</li> - <li>Better compatibility and performance on some older AMD GPUs</li> - <li>Better handle application audio nodes, fixing possible issue with application audio not working</li> - </ul> - </description> - </release> - <release version="4.3.3" date="2024-11-22"> - <description> - <ul> - <li>Fix application not starting on pulseaudio systems (for example linux mint 21.3)</li> - <li>Dont display monitor capture option when not available</li> - </ul> - </description> - </release> - <release version="4.3.2" date="2024-11-21"> - <description> - <ul> - <li>Allow recording from both audio devices and application audio at the same time</li> - <li>Workaround amd driver bug that causes garbage output on some gpus in some amd driver versions</li> - </ul> - </description> - </release> - <release version="4.3.1" date="2024-11-17"> - <description> - <ul> - <li>Improve window content sizing behavior (no more horizontal scroll)</li> - </ul> - </description> - </release> - <release version="4.3.0" date="2024-11-16"> - <description> - <ul> - <li>Add option to record audio from applications instead of audio devices (pipewire only)</li> - </ul> - </description> - </release> - <release version="4.2.6" date="2024-11-05"> - <description> - <ul> - <li>Add option to change video resolution</li> - <li>Change quality parameters, file size was too large by default</li> - </ul> - </description> - </release> - <release version="4.2.5" date="2024-11-04"> - <description> - <ul> - <li>Add option to change video resolution</li> - <li>Fix bitrate calculation being incorrect (it was too low)</li> - </ul> - </description> - </release> - <release version="4.2.4" date="2024-10-22"> - <description> - <ul> - <li>Fix capture not working if one of the audio inputs is a virtual audio device with forward slash in its name, for example if NoiseTorch is used</li> - </ul> - </description> - </release> - <release version="4.2.2" date="2024-10-15"> - <description> - <ul> - <li>Enable amd low latency mode (only available since mesa 24.1.4, released in july 17, 2024). This reduces stutter in video in some cases but increases power usage when idle</li> - </ul> - </description> - </release> - <release version="4.2.1" date="2024-10-12"> - <description> - <ul> - <li>Better frame timing when hardware is too slow to record at the desired framerate</li> - </ul> - </description> - </release> - <release version="4.2.0" date="2024-10-11"> - <description> - <ul> - <li>Better frame timing for smoother video, especially when recording a game that runs at the same fps as the recording or lower.</li> - <li>Add constant bitrate option, for better live streaming experience and for lower file size at the cost of quality.</li> - </ul> - </description> - </release> - <release version="4.1.11" date="2024-09-21"> - <description> - <ul> - <li>Fix recording not working on some amd systems</li> - </ul> - </description> - </release> - <release version="4.1.10" date="2024-09-21"> - <description> - <ul> - <li>Revert frame timing change as it badly affected slower devices</li> - </ul> - </description> - </release> - <release version="4.1.9" date="2024-09-20"> - <description> - <ul> - <li>Improve frame timing for smoother video</li> - <li>Improve screen recording performance on AMD when the system usage is very high</li> - <li>Fix recording not working on old nvidia gpus (that are stuck on nvidia driver version 470)</li> - </ul> - </description> - </release> - <release version="4.1.8" date="2024-09-17"> - <description> - <ul> - <li>Improve video capture sync, making the video smoother. The video is smoother on X11 than Wayland</li> - <li>Improve video recording performance on AMD when the system usage is 100%</li> - </ul> - </description> - </release> - <release version="4.1.7" date="2024-09-06"> - <description> - <ul> - <li>Fix tearing/stutter/cursor flicker on amd after recent amd driver update</li> - </ul> - </description> - </release> - <release version="4.1.6" date="2024-08-30"> - <description> - <ul> - <li>Workaround steam deck driver bug and enable steam deck support again</li> - <li>Improve startup time on certain systems</li> - </ul> - </description> - </release> - <release version="4.1.5" date="2024-08-20"> - <description> - <ul> - <li>Disable support for steam deck at the moment because steam deck drivers are broken</li> - <li>Improve quality again</li> - </ul> - </description> - </release> - <release version="4.1.4" date="2024-08-20"> - <description> - <ul> - <li>Reduce video file size</li> - </ul> - </description> - </release> - <release version="4.1.3" date="2024-08-18"> - <description> - <ul> - <li>Fix capture not working on wayland when recording a monitor instead of desktop portal</li> - </ul> - </description> - </release> - <release version="4.1.2" date="2024-08-17"> - <description> - <ul> - <li>Allow capturing external monitors on a laptop with a dedicated gpu on X11 (for example an intel laptop with a nvidia gpu), where the monitor is connected to the dedicated gpu</li> - <li>Fix capture not working if audio device id has space in it (happens with virtual audio sources)</li> - <li>Add 10 bit color depth options for hevc and av1 to reduce banding</li> - <li>Fix cursor not visible when using multiple monitors in some wayland compositors</li> - </ul> - </description> - </release> - <release version="4.1.1" date="2024-08-15"> - <description> - <ul> - <li>Fix error when starting application on wayland when portal capture option is available but laptop monitor is disabled</li> - </ul> - </description> - </release> - <release version="4.1.0" date="2024-08-08"> - <description> - <ul> - <li>Fix possible lag on monitor/desktop portal capture</li> - </ul> - </description> - </release> - <release version="4.0.1" date="2024-07-23"> - <description> - <ul> - <li>Fix capture broken on amd on wayland</li> - <li>Fix hdr capture causing crash when in replay mode</li> - </ul> - </description> - </release> - <release version="4.0.0" date="2024-07-22"> - <description> - <ul> - <li>Added desktop portal (pipewire) capture option. This fixes issue with glitched capture on certain Intel iGPUS (on Wayland)</li> - <li>Added global hotkeys on Wayland. KDE Plasma is the only Wayland environment that supports this properly at the moment</li> - <li>Add separate hotkeys for start and stop and option to show notification when starting/stopping recording</li> - <li>Fix HDR capture (HDR metadata is now correct). Note that HDR capture is only available on Wayland and when recording a monitor without the desktop portal option</li> - <li>Added VP8 and VP9 video codecs if supported by the hardware</li> - <li>Added software encoding option</li> - </ul> - </description> - </release> - <release version="3.8.2" date="2024-06-22"> - <description> - <ul> - <li>Default to h264 video codec because of amd driver issues (black bar) and for better compatibility with software</li> - </ul> - </description> - </release> - <release version="3.8.1" date="2024-06-16"> - <description> - <ul> - <li>Properly cutout cursor outside video area when dealing with AMD HEVC padding driver bug</li> - </ul> - </description> - </release> - <release version="3.8.0" date="2024-06-10"> - <description> - <ul> - <li>Add system tray icon</li> - <li>Fix screen recording on Intel ARC GPU</li> - <li>Workaround AMD driver bug with HEVC video codec that causes glitched graphics on the right/bottom side with certain video resolutions. It's now replaced with black color</li> - <li>Fix possible incorrect monitor rotation when using multiple monitors with one monitor rotated on GNOME Wayland</li> - <li>Add hls (m3u8) container option</li> - </ul> - </description> - </release> - <release version="3.7.7" date="2024-05-29"> - <description> - <ul> - <li>Fix recording freeze on nvidia when __GL_SYNC_TO_VBLANK environment variable is set to 1</li> - </ul> - </description> - </release> - <release version="3.7.6" date="2024-05-20"> - <description> - <ul> - <li>Do not force constant framerate for live streams</li> - </ul> - </description> - </release> - <release version="3.7.5" date="2024-05-19"> - <description> - <ul> - <li>Fix twitch/youtube streaming not working</li> - <li>Fix possible freeze on recording stop if stopping quickly after starting recording</li> - </ul> - </description> - </release> - <release version="3.7.4" date="2024-05-13"> - <description> - <p>Make audio sync even better. Audio sync is broken in all applications anyways so what can be done really</p> - </description> - </release> - <release version="3.7.3" date="2024-05-12"> - <description> - <ul> - <li>Re-enable opus audio codec</li> - <li>Remove flac audio codec option until it's fixed</li> - <li>Improve video quality when recording HDR</li> - <li>Fix flv issues</li> - <li>Add mpegts container and option to select codec for custom streaming service</li> - </ul> - </description> - </release> - <release version="3.7.2" date="2024-04-20"> - <description> - <ul> - <li>Improve nvidia video encoding performance a lot on certain GPUs</li> - <li>Improve audio/video sync</li> - <li>Increase audio bitrate</li> - <li>Hide notifications after a few seconds</li> - </ul> - </description> - </release> - <release version="3.7.1" date="2024-04-12"> - <description> - <p>Fix audio sync regression when using mixed audio</p> - </description> - </release> - <release version="3.7.0" date="2024-04-11"> - <description> - <p>Fix possible audio desync after some time for some users</p> - </description> - </release> - <release version="3.6.5" date="2024-04-10"> - <description> - <p>Fix nvidia x11 monitor capture breaking after suspend/monitor reconfiguration (even after applying nvidia preserve video memory on suspend)</p> - </description> - </release> - <release version="3.6.4" date="2024-04-06"> - <description> - <p>Fix recording breaking when updating flatpak on some systems (where $HOME is symlinked to another location), requires password prompt update</p> - </description> - </release> - <release version="3.6.3" date="2024-03-21"> - <description> - <ul> - <li>Fix nvidia window capture/wayland capture if the user has set __GL_THREADED_OPTIMIZATIONS to 1</li> - <li>Fix full color range capture in nvidia window capture</li> - <li>Properly clear cursor in window capture</li> - </ul> - </description> - </release> - <release version="3.6.2" date="2024-03-20"> - <description> - <ul> - <li>Fix incorrect overclocking offset on some nvidia gpus when enabling overclocking option</li> - <li>Ignore color standards for more accurate colors</li> - </ul> - </description> - </release> - <release version="3.6.1" date="2024-03-11"> - <description> - <p>Add the option to not record cursor</p> - </description> - </release> - <release version="3.6.0" date="2024-03-10"> - <description> - <ul> - <li>Support HDR capture and full color range on nvidia</li> - <li>Support cursor capture when recording a single window</li> - <li>Show the correct monitors when using prime-run</li> - </ul> - </description> - </release> - <release version="3.5.3" date="2024-02-16"> - <description> - <p>Fix minor permissions issue</p> - </description> - </release> - <release version="3.5.2" date="2024-02-14"> - <description> - <p>Better error message for missing h264/hevc, ignore user nvidia vaapi setting</p> - </description> - </release> - <release version="3.5.1" date="2024-02-11"> - <description> - <ul> - <li>Fix crash on x11 nvidia when recording monitor</li> - <li>Fix color issue when recording window on amd/intel</li> - </ul> - </description> - </release> - <release version="3.5.0" date="2024-02-11"> - <description> - <ul> - <li>Support monitor rotation</li> - <li>Support hdr capture on amd/intel wayland (currently missing hdr metadata because of driver bugs)</li> - <li>Default to variable framerate videos on nvidia x11 as well</li> - <li>Center capture window/follow focused and clear background</li> - <li>Remove 'remove password prompts' button. Only ask for password once and never again</li> - </ul> - </description> - </release> - <release version="3.4.2" date="2024-01-27"> - <description> - <ul> - <li>Support hardware cursor plane capture on nvidia wayland</li> - <li>Add record timer</li> - </ul> - </description> - </release> - <release version="3.4.1" date="2024-01-17"> - <description> - <ul> - <li>Improve audio drifting in some cases</li> - <li>Fix audio stuttering with pulseaudio + opus/flac + multiple audio sources merged</li> - <li>Add option to remove hotkey with backspace</li> - <li>Decide which audio device is default output/input when starting to record</li> - </ul> - </description> - </release> - <release version="3.4.0" date="2024-01-07"> - <description> - <p>Add option to pause recording</p> - </description> - </release> - <release version="3.3.2" date="2023-12-31"> - <description> - <p>Fix monitor capture on AMD/Intel or NVIDIA Wayland on some distros, such as OpenSUSE</p> - </description> - </release> - <release version="3.3.1" date="2023-12-02"> - <description> - <ul> - <li>Fix opus and flac</li> - <li>Fix crash when live streaming without an audio source</li> - <li>Fix missing streaming show/hide key symbol</li> - </ul> - </description> - </release> - <release version="3.3.0" date="2023-12-01"> - <description> - <ul> - <li>Add option to remove password prompts (if possible on the system)</li> - <li>Add experimental av1 support (if supported by the hardware). Currently only enabled for AMD/Intel in the flatpak.</li> - <li>Configure quality settings to reduce file size on amd/intel</li> - <li>Workaround amd/intel driver issue when using h264 (or fps > 60) and mkv (forcefully set video codec to hevc)</li> - </ul> - </description> - </release> - <release version="3.2.6" date="2023-11-27"> - <description> - <p>Fix possible crash when recording multiple audio sources (merged)</p> - </description> - </release> - <release version="3.2.5" date="2023-11-18"> - <description> - <p>Fix incorrect color on some nvidia wayland systems running kde plasma (support 10-bit color depth)</p> - </description> - </release> - <release version="3.2.4" date="2023-11-05"> - <description> - <p>Nvidia x11: disable screen direct record option, as there is an nvidia driver bug that causes some games to freeze/crash with this option</p> - </description> - </release> - <release version="3.2.3" date="2023-11-01"> - <description> - <p>Use opengl context instead of egl2, might fix program startup not working for some users</p> - </description> - </release> - <release version="3.2.2" date="2023-10-31"> - <description> - <p>Intel: attempt to fix glitched graphics on some intel gpus. I dont know, ask intel why they are weird</p> - </description> - </release> - <release version="3.2.1" date="2023-10-22"> - <description> - <p>AMD/Intel wayland: fix broken colors when system uses 10-bit</p> - </description> - </release> - <release version="3.2.0" date="2023-10-21"> - <description> - <ul> - <li>AMD/Intel: workaround driver bug that causes vram leak</li> - <li>Add frame rate mode option in advanced menu</li> - <li>Redesign audio input to make it clear that you have to add audio to use it</li> - </ul> - </description> - </release> - <release version="3.1.7" date="2023-08-15"> - <description> - <p>NVIDIA: Workaround new nvidia driver bug that causes recording of a small window to freeze recording.</p> - </description> - </release> - <release version="3.1.6" date="2023-08-13"> - <description> - <p>AMD/Intel: fix capture issue on some systems</p> - </description> - </release> - <release version="3.1.5" date="2023-07-25"> - <description> - <p>AMD/Intel: Fix too dark video in the flatpak version.</p> - </description> - </release> - <release version="3.1.4" date="2023-07-23"> - <description> - <p>AMD/Intel: Better color accuracy.</p> - </description> - </release> - <release version="3.1.3" date="2023-07-22"> - <description> - <p>Fix capture on wlroots based wayland compositors. Fix cursor offset in amd/intel capture.</p> - </description> - </release> - <release version="3.1.2" date="2023-07-22"> - <description> - <p>Support cursor capture on AMD/Intel on Wayland. Attempt to fix multi monitor offset capture in some cases.</p> - </description> - </release> - <release version="3.1.1" date="2023-07-21"> - <description> - <p>Support cursor capture on AMD/Intel on Wayland.</p> - </description> - </release> - <release version="3.1.0" date="2023-07-21"> - <description> - <ul> - <li>Support wlroots capture when possible (no kms root access required)</li> - <li>Make window capture a bit more robust</li> - <li>Fix possible lag on recording start on AMD/Intel</li> - <li>Make capture on AMD/Intel possible without Xwayland</li> - </ul> - </description> - </release> - <release version="3.0.0" date="2023-07-18"> - <description> - <p>Experimental wayland support on AMD/Intel/NVIDIA. Hotkeys not supported.</p> - </description> - </release> - <release version="2.2.0" date="2023-07-10"> - <description> - <p>Attempt to fix screen recording when multiple graphics cards are connected</p> - </description> - </release> - <release version="2.1.7" date="2023-07-07"> - <description> - <p>Show proper error when running on wayland. Preparing for wayland support.</p> - </description> - </release> - <release version="2.1.6" date="2023-06-10"> - <description> - <p>AMD/Intel: fix multi monitor capture coordinate being incorrect for some GPU driver versions.</p> - </description> - </release> - <release version="2.1.5" date="2023-05-22"> - <description> - <p>Attempt to fix a recent nvidia (cuda) driver bug on RTX cards that causes a freeze when stopping recording.</p> - </description> - </release> - <release version="2.1.4" date="2023-05-17"> - <description> - <p>Fix issue where the application freezes and keyboard freezes when selecting a new hotkey and another widget is clicked.</p> - </description> - </release> - <release version="2.1.3" date="2023-05-12"> - <description> - <p>Attempt to fix possible issue on some systems with amd/intel where capture region is incorrect when multiple monitors are connected.</p> - </description> - </release> - <release version="2.1.2" date="2023-04-27"> - <description> - <p>Attempt to fix possible audio/video sync on NVIDIA after recording for a long time. Temporary disable opus/flac because it breaks when recording multiple audio inputs.</p> - </description> - </release> - <release version="2.1.1" date="2023-04-22"> - <description> - <p>AMD/Intel: Add support for capturing cursor when recording a monitor. Fix some cases of capture being glitched when using multiple monitors.</p> - </description> - </release> - <release version="2.1.0" date="2023-04-18"> - <description> - <p>Enable AMD/Intel monitor capture. Requires the flatpak to be installed system-wide and it requires restricted root access. Record a single window if you dont like these restrictions. Videos created on AMD/Intel should be played with MPV otherwise it might have issues such as stuttering.</p> - </description> - </release> - <release version="2.0.0" date="2023-04-11"> - <description> - <p>Add experimental support for AMD/Intel. Quality might not be well tuned yet and the video is in variable framerate mode, which might cause issues with some out of date video editing software or video players. Recording on AMD/intel is currently limited to a window (monitor capture is not possible yet).</p> - </description> - </release> - <release version="1.3.5" date="2023-03-22"> - <description> - <p>Show error when using wayland (because wayland is not supported)</p> - </description> - </release> - <release version="1.3.4" date="2023-03-17"> - <description> - <p>Add option to workaround a NVIDIA driver "bug" that causes framerate to drop a bit when recording (overclock memory transfer rate back to normal)</p> - </description> - </release> - <release version="1.3.3" date="2023-03-11"> - <description> - <p>Make it clear when graphics card is not supported</p> - </description> - </release> - <release version="1.3.2" date="2023-03-04"> - <description> - <ul> - <li>Add VRR record option, only use with VRR as it might have driver issues!</li> - <li>Add opus/flac audio options. opus/flac is only supported by .mp4/.mkv. Automatically changes audio codec if not supported by the container</li> - </ul> - </description> - </release> - <release version="1.3.1" date="2023-02-22"> - <description> - <p>Fix broken replay when recording with audio (possibly broken in normal recording as well)</p> - </description> - </release> - <release version="1.3.0" date="2023-02-20"> - <description> - <ul> - <li>Switch to EGL (fixes possible window capture issues when using a compositor)</li> - <li>Add option to change hotkeys</li> - <li>Add option to merge audio tracks into one audio track</li> - <li>Add option to follow the focused window</li> - <li>Add option to force set h264/hevc (services such as discord can't play hevc videos directly in the application)</li> - <li>Show proper error when NVIDIA GPU is not in use</li> - </ul> - </description> - </release> - <release version="1.2.1" date="2022-11-24"> - <description> - <p>Allow choosing between mp4, flv and mkv for record/replay. mkv survives system crashes</p> - </description> - </release> - <release version="1.2.0" date="2022-10-27"> - <description> - <p>Re-enable screen-direct, disable h264 forced fallback and use p6 again</p> - </description> - </release> - <release version="1.1.8" date="2022-10-18"> - <description> - <p>Attempt to fix stuttering in video that can happen sometimes (especially when vsync is enabled)</p> - </description> - </release> - <release version="1.1.7" date="2022-10-16"> - <description> - <p>Properly fallback to h264 if hevc is not supported by the gpu</p> - </description> - </release> - <release version="1.1.6" date="2022-10-15"> - <description> - <p>Fix livestreaming: flv does not properly fallback to h264</p> - </description> - </release> - <release version="1.1.5" date="2022-10-11"> - <description> - <p>Use lower preset on older gpus (kepler) and switch to h264 if h265 is not supported</p> - </description> - </release> - <release version="1.1.4" date="2022-10-11"> - <description> - <p>Tune options to try and reduce file size</p> - </description> - </release> - <release version="1.1.3" date="2022-10-08"> - <description> - <p>Better tune quality options for different resolutions</p> - </description> - </release> - <release version="1.1.2" date="2022-10-07"> - <description> - <p>Fix crash caused by invalid memory write when recording audio</p> - </description> - </release> - <release version="1.1.1" date="2022-10-05"> - <description> - <p>Fix possible pulseaudio crash</p> - </description> - </release> - <release version="1.1.0" date="2022-10-05"> - <description> - <p>Fixes some streaming issues (mostly metadata missing)</p> - </description> - </release> - <release version="1.0.0" date="2022-09-30"/> - </releases> - <content_rating type="oars-1.1"/> -</component> diff --git a/meson.build b/meson.build index 32696d6..ee35e06 100644 --- a/meson.build +++ b/meson.build @@ -1,4 +1,4 @@ -project('gpu-screen-recorder-gtk', ['c', 'cpp'], version : '5.1.4', default_options : ['warning_level=2']) +project('gpu-screen-recorder-gtk', ['c', 'cpp'], version : '5.7.6', default_options : ['warning_level=2']) add_project_arguments('-Wshadow', language : ['c', 'cpp']) if get_option('buildtype') == 'debug' @@ -33,7 +33,6 @@ executable('gpu-screen-recorder-gtk', ) install_data(files('com.dec05eba.gpu_screen_recorder.desktop'), install_dir : join_paths(prefix, datadir, 'applications')) -install_data(files('com.dec05eba.gpu_screen_recorder.appdata.xml'), install_dir : join_paths(prefix, datadir, 'metainfo')) install_subdir('icons/hicolor', install_dir : icons_path) gnome = import('gnome') diff --git a/project.conf b/project.conf index aa0509c..ddf4c22 100644 --- a/project.conf +++ b/project.conf @@ -1,12 +1,12 @@ [package] name = "gpu-screen-recorder-gtk" type = "executable" -version = "5.1.4" +version = "5.7.6" platforms = ["posix"] [config] ignore_dirs = ["build"] -error_on_warning = "true" +error_on_warning = "false" [dependencies] gtk+-3.0 = "3" diff --git a/src/main.cpp b/src/main.cpp index 887e854..91f7c3d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -99,7 +99,7 @@ static GtkWidget *replay_start_stop_hotkey_button; static GtkWidget *replay_save_hotkey_button; static GtkWidget *streaming_start_stop_hotkey_button; static GtkWidget *record_app_audio_inverted_button; -static GtkWidget *merge_audio_tracks_button; +static GtkWidget *split_audio_button; static GtkFrame *notifications_frame; static GtkWidget *show_recording_started_notification_button; static GtkWidget *show_recording_stopped_notification_button; @@ -169,6 +169,7 @@ static AppIndicator *app_indicator; static gsr_global_shortcuts global_shortcuts; static bool global_shortcuts_initialized = false; +static bool global_shortcuts_received = false; struct AudioInput { std::string name; @@ -264,7 +265,8 @@ enum class GpuVendor { UNKNOWN, AMD, INTEL, - NVIDIA + NVIDIA, + BROADCOM }; struct GpuInfo { @@ -899,7 +901,7 @@ static void save_configs() { config.main_config.video_height = gtk_spin_button_get_value_as_int(video_height_entry); config.main_config.fps = gtk_spin_button_get_value_as_int(fps_entry); config.main_config.video_bitrate = gtk_spin_button_get_value_as_int(video_bitrate_entry); - config.main_config.merge_audio_tracks = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(merge_audio_tracks_button)); + config.main_config.merge_audio_tracks = !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(split_audio_button)); config.main_config.record_app_audio_inverted = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(record_app_audio_inverted_button)); config.main_config.change_video_resolution = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(change_video_resolution_button)); @@ -1399,6 +1401,9 @@ static bool is_monitor_capture_drm() { } static bool show_pkexec_flatpak_error_if_needed() { + if(!flatpak) + return false; + const std::string window_str = record_area_selection_menu_get_active_id(); if(is_monitor_capture_drm() && window_str != "window" && window_str != "focused" && window_str != "portal") { if(!is_pkexec_installed()) { @@ -1409,7 +1414,7 @@ static bool show_pkexec_flatpak_error_if_needed() { return true; } - if(flatpak && !flatpak_is_installed_as_system()) { + if(!flatpak_is_installed_as_system()) { if(gsr_info.system_info.display_server == DisplayServer::WAYLAND) { GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "GPU Screen Recorder needs to be installed system-wide to record your monitor on Wayland when not using the portal option. You can run this command to install GPU Screen recorder system-wide:\n" @@ -1456,11 +1461,80 @@ static void show_bugged_driver_warning() { } } +static void replace_meta_with_super(std::string &str) { + size_t index = str.find("meta"); + if(index != std::string::npos) + str.replace(index, 4, "Super"); + + index = str.find("Meta"); + if(index != std::string::npos) + str.replace(index, 4, "Super"); +} + +static void shortcut_changed_callback(gsr_shortcut shortcut, void *userdata) { + (void)userdata; + global_shortcuts_received = true; + std::string trigger = shortcut.trigger_description; + replace_meta_with_super(trigger); + for(int i = 0; i < num_hotkeys; ++i) { + if(strcmp(shortcut.id, hotkeys[i]->shortcut_id) == 0) { + gtk_entry_set_text(GTK_ENTRY(hotkeys[i]->hotkey_entry), trigger.c_str()); + } + } +} + +static gboolean on_register_hotkeys_button_clicked(GtkButton *button, gpointer userdata) { + (void)button; + (void)userdata; + + /* + Modifier key names are defined here: https://github.com/xkbcommon/libxkbcommon/blob/master/include/xkbcommon/xkbcommon-names.h. + Remove the XKB_MOD_NAME_ prefix from the name and use the remaining part. + Key names are defined here: https://github.com/xkbcommon/libxkbcommon/blob/master/include/xkbcommon/xkbcommon-keysyms.h. + Remove the XKB_KEY_ (or XKB_KEY_KP_) prefix from the name and user the remaining part. + */ + /* Unfortunately global shortcuts cant handle same key for different shortcuts, even though GPU Screen Recorder has page specific hotkeys */ + const gsr_bind_shortcut shortcuts[3] = { + { + "Start/stop recording/replay/streaming", + { SHORTCUT_ID_START_STOP_RECORDING, "ALT+1" } + }, + { + "Pause/unpause recording", + { SHORTCUT_ID_PAUSE_UNPAUSE_RECORDING, "ALT+2" } + }, + { + "Save replay", + { SHORTCUT_ID_SAVE_REPLAY, "ALT+3" } + } + }; + + if(global_shortcuts_initialized) { + if(!gsr_global_shortcuts_bind_shortcuts(&global_shortcuts, shortcuts, 3, shortcut_changed_callback, NULL)) { + fprintf(stderr, "gsr error: failed to bind shortcuts\n"); + } + } + + return true; +} + +static void register_global_shortcuts_once() { + static bool registered = false; + // On KDE plasma the shortcut menu popup will show up everytime this is used, so we dont want to call it everytime. + // On Hyprland the global shortcut desktop portal is broken on older versions and crashes the desktop portal. + // On GNOME this needs to be called everytime to register the shortcuts. The shortcut popup menu will show the first time only. + if(wayland_compositor == WaylandCompositor::UNKNOWN && !registered && !global_shortcuts_received) { + registered = true; + on_register_hotkeys_button_clicked(nullptr, nullptr); + } +} + static gboolean on_start_replay_click(GtkButton*, gpointer userdata) { if(show_pkexec_flatpak_error_if_needed()) return true; show_bugged_driver_warning(); + register_global_shortcuts_once(); PageNavigationUserdata *_page_navigation_userdata = (PageNavigationUserdata*)userdata; gtk_stack_set_visible_child(_page_navigation_userdata->stack, _page_navigation_userdata->replay_page); @@ -1477,6 +1551,7 @@ static gboolean on_start_recording_click(GtkButton*, gpointer userdata) { return true; show_bugged_driver_warning(); + register_global_shortcuts_once(); PageNavigationUserdata *_page_navigation_userdata = (PageNavigationUserdata*)userdata; gtk_stack_set_visible_child(_page_navigation_userdata->stack, _page_navigation_userdata->recording_page); @@ -1499,6 +1574,7 @@ static gboolean on_start_streaming_click(GtkButton*, gpointer userdata) { return true; show_bugged_driver_warning(); + register_global_shortcuts_once(); int num_audio_tracks = 0; gtk_container_foreach(GTK_CONTAINER(audio_devices_items_box), [](GtkWidget *widget, gpointer userdata) { @@ -1508,7 +1584,7 @@ static gboolean on_start_streaming_click(GtkButton*, gpointer userdata) { ++num_audio_tracks; }, &num_audio_tracks); - if(num_audio_tracks > 1 && !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(merge_audio_tracks_button))) { + if(num_audio_tracks > 1 && gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(split_audio_button))) { GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Streaming doesn't work with more than 1 audio track. Please remove all audio tracks or only use 1 audio track or select to merge audio tracks."); gtk_dialog_run(GTK_DIALOG(dialog)); @@ -1603,13 +1679,15 @@ static bool starts_with(const std::string &str, const char *substr) { struct AudioTracksUserdata { std::vector<std::string> &result; bool application_audio_invert; + int num_app_audio = 0; }; static std::vector<std::string> create_audio_tracks_real_names(std::string &merge_audio_tracks) { std::vector<std::string> result; AudioTracksUserdata audio_tracks_userdata { result, - (bool)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(record_app_audio_inverted_button)) + (bool)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(record_app_audio_inverted_button)), + 0 }; gtk_container_foreach(GTK_CONTAINER(audio_devices_items_box), [](GtkWidget *widget, gpointer userdata) { @@ -1627,6 +1705,7 @@ static std::vector<std::string> create_audio_tracks_real_names(std::string &merg std::string audio_input_name = audio_tracks_userdata.application_audio_invert ? "app-inverse:" : "app:"; audio_input_name += gtk_combo_box_get_active_id(GTK_COMBO_BOX(row_item_widget)); audio_tracks_userdata.result.push_back(std::move(audio_input_name)); + ++audio_tracks_userdata.num_app_audio; } else if(strcmp(audio_track_type, "app-custom") == 0) { if(!gsr_info.system_info.supports_app_audio) return; @@ -1634,9 +1713,13 @@ static std::vector<std::string> create_audio_tracks_real_names(std::string &merg std::string audio_input_name = audio_tracks_userdata.application_audio_invert ? "app-inverse:" : "app:"; audio_input_name += gtk_entry_get_text(GTK_ENTRY(row_item_widget)); audio_tracks_userdata.result.push_back(std::move(audio_input_name)); + ++audio_tracks_userdata.num_app_audio; } }, &audio_tracks_userdata); + if(audio_tracks_userdata.num_app_audio == 0 && audio_tracks_userdata.application_audio_invert) + audio_tracks_userdata.result.push_back("app-inverse:"); + merge_audio_tracks.clear(); for(size_t i = 0; i < result.size(); ++i) { if(i > 0) @@ -1648,7 +1731,7 @@ static std::vector<std::string> create_audio_tracks_real_names(std::string &merg } static void add_audio_command_line_args(std::vector<const char*> &args, const std::vector<std::string> &audio_tracks, const std::string &merge_audio_tracks) { - if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(merge_audio_tracks_button))) { + if(!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(split_audio_button))) { if(!merge_audio_tracks.empty()) args.insert(args.end(), { "-a", merge_audio_tracks.c_str() }); } else { @@ -1744,8 +1827,7 @@ static gboolean on_start_replay_button_click(GtkButton *button, gpointer userdat app_indicator_set_icon_full(app_indicator, get_tray_idle_icon_name(), "Idle"); if(exit_status == 10) { - show_notification(app, "GPU Screen Recorder", - "You need to have pkexec installed and a polkit agent running to record your monitor", G_NOTIFICATION_PRIORITY_URGENT); + show_notification(app, "GPU Screen Recorder", "You need to have pkexec installed and have a polkit agent running to record your monitor", G_NOTIFICATION_PRIORITY_URGENT); } else if(exit_status == 50) { show_notification(app, "GPU Screen Recorder", "Desktop portal capture failed. Either you canceled the desktop portal or your Wayland compositor doesn't support desktop portal capture or it's incorrectly setup on your system", G_NOTIFICATION_PRIORITY_URGENT); } else if(exit_status == 60) { @@ -1951,8 +2033,7 @@ static gboolean on_start_recording_button_click(GtkButton *button, gpointer user app_indicator_set_icon_full(app_indicator, get_tray_idle_icon_name(), "Idle"); if(exit_status == 10) { - show_notification(app, "GPU Screen Recorder", - "You need to have pkexec installed and a polkit agent running to record your monitor", G_NOTIFICATION_PRIORITY_URGENT); + show_notification(app, "GPU Screen Recorder", "You need to have pkexec installed and have a polkit agent running to record your monitor", G_NOTIFICATION_PRIORITY_URGENT); } else if(exit_status == 50) { show_notification(app, "GPU Screen Recorder", "Desktop portal capture failed. Either you canceled the desktop portal or your Wayland compositor doesn't support desktop portal capture or it's incorrectly setup on your system", G_NOTIFICATION_PRIORITY_URGENT); } else if(exit_status == 60) { @@ -2116,8 +2197,7 @@ static gboolean on_start_streaming_button_click(GtkButton *button, gpointer user app_indicator_set_icon_full(app_indicator, get_tray_idle_icon_name(), "Idle"); if(exit_status == 10) { - show_notification(app, "GPU Screen Recorder", - "You need to have pkexec installed and a polkit agent running to record your monitor", G_NOTIFICATION_PRIORITY_URGENT); + show_notification(app, "GPU Screen Recorder", "You need to have pkexec installed and have a polkit agent running to record your monitor", G_NOTIFICATION_PRIORITY_URGENT); } else if(exit_status == 50) { show_notification(app, "GPU Screen Recorder", "Desktop portal capture failed. Either you canceled the desktop portal or your Wayland compositor doesn't support desktop portal capture or it's incorrectly setup on your system", G_NOTIFICATION_PRIORITY_URGENT); } else if(exit_status == 60) { @@ -2326,6 +2406,7 @@ static void view_combo_box_change_callback(GtkComboBox *widget, gpointer userdat gtk_widget_set_visible(GTK_WIDGET(framerate_mode_grid), advanced_view); gtk_widget_set_visible(GTK_WIDGET(overclock_grid), advanced_view && gsr_info.gpu_info.vendor == GpuVendor::NVIDIA && gsr_info.system_info.display_server != DisplayServer::WAYLAND); gtk_widget_set_visible(GTK_WIDGET(notifications_frame), advanced_view); + gtk_widget_set_visible(GTK_WIDGET(split_audio_button), advanced_view); } static void quality_combo_box_change_callback(GtkComboBox *widget, gpointer userdata) { @@ -2586,6 +2667,8 @@ static void parse_gpu_info_line(GsrInfo *_gsr_info, const std::string &line) { _gsr_info->gpu_info.vendor = GpuVendor::INTEL; else if(attribute_value == "nvidia") _gsr_info->gpu_info.vendor = GpuVendor::NVIDIA; + else if(attribute_value == "broadcom") + _gsr_info->gpu_info.vendor = GpuVendor::BROADCOM; } } @@ -2631,7 +2714,7 @@ static void parse_capture_options_line(GsrInfo *_gsr_info, const std::string &li _gsr_info->supported_capture_options.focused = true; else if(line == "portal") _gsr_info->supported_capture_options.portal = true; - else + else if(line != "region") // We dont support region capture in the gtk application _gsr_info->supported_capture_options.monitors.push_back(capture_option_line_to_monitor(line)); } @@ -2738,8 +2821,8 @@ static void video_codec_set_sensitive(GtkCellLayout *cell_layout, GtkCellRendere g_free(id); } -static void launch_gsr_ui(bool show_ui) { - const char *args[] = { "gsr-ui", show_ui ? "launch-show" : "launch-hide", nullptr }; +static void launch_gsr_ui(bool launched_by_daemon) { + const char *args[] = { "gsr-ui", launched_by_daemon ? "launch-daemon" : "launch-show", nullptr }; execvp(args[0], (char* const*)args); // TODO: This is incorrect because window wont be defined here if this is called from startup. // This is fine for not because this is only called inside the flatpak where gsr-ui is always available. @@ -2813,10 +2896,14 @@ static gboolean on_click_switch_to_new_ui(GtkButton*, gpointer) { GtkWidget *dialog = gtk_message_dialog_new_with_markup(GTK_WINDOW(window), GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "You are about to try out the new UI, which is a ShadowPlay-like fullscreen UI. It runs in the background and you have to show/hide it by pressing Left Alt+Z.\n" - "This new UI is still experimental and you may experience issues depending on your system. You can switch back to the old UI at any time by opening the UI and clicking on the settings button and clicking on the \"Go back to the old UI\" button.\n" + "This new UI is still experimental and you may experience issues depending on your system, especially on Wayland since Wayland doesn't support this software properly.\n" + "You can switch back to the old UI at any time by opening the UI and clicking on the settings button and clicking on the \"Go back to the old UI\" button.\n" "\n" "This new UI comes with new features, such as being able to automatically launch it on system startup by enabling it in settings, and hotkey support on any Wayland compositor.\n" "\n" + "If you are using keyboard remapping software such as keyd then make sure it ignores \"gsr-ui virtual keyboard\" (dec0:5eba device id), or it will prevent you from using your keyboard.\n" + "You can go back to the old UI by pressing (left) ctrl+shift+alt+esc if this happens.\n" + "\n" "If you are using an NVIDIA GPU then you may experience issue with recording/replay if a suspend happens while recording/using replay. This is an NVIDIA driver issue and it also happens in the old UI.\n" "See this for a workaround: <a href=\"https://wiki.archlinux.org/title/NVIDIA/Tips_and_tricks#Preserve_video_memory_after_suspend\">Arch Wiki - Preserve video memory after suspend</a>.\n" "\n" @@ -2844,7 +2931,6 @@ static gboolean on_click_switch_to_new_ui(GtkButton*, gpointer) { "flatpak-spawn --host -- install -Dm644 /var/lib/flatpak/app/com.dec05eba.gpu_screen_recorder/current/active/files/share/gpu-screen-recorder/gpu-screen-recorder-ui.service \"$data_home/systemd/user/gpu-screen-recorder-ui.service\"") == 0); service_install_successful &= (system("flatpak-spawn --host -- systemctl --user daemon-reload") == 0); service_install_successful &= (system("flatpak-spawn --host -- systemctl enable --user gpu-screen-recorder-ui") == 0); - service_install_successful &= (system("flatpak-spawn --host -- systemctl start --user gpu-screen-recorder-ui") == 0); if(!service_install_successful) { GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, "Failed to add GPU Screen Recorder to system startup. If you want the new UI to start on system startup then you need to add this command to system startup:\n" @@ -2854,9 +2940,7 @@ static gboolean on_click_switch_to_new_ui(GtkButton*, gpointer) { gtk_widget_destroy(dialog); } - if(!service_install_successful) - launch_gsr_ui(true); - + launch_gsr_ui(false); g_application_quit(G_APPLICATION(select_window_userdata.app)); return true; } @@ -3143,10 +3227,10 @@ static GtkWidget* create_common_settings_page(GtkStack *stack, GtkApplication *a gtk_grid_attach(audio_devices_grid, GTK_WIDGET(audio_devices_items_box), 0, audio_devices_row++, 2, 1); } - merge_audio_tracks_button = gtk_check_button_new_with_label("Merge audio tracks"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(merge_audio_tracks_button), true); - gtk_widget_set_halign(merge_audio_tracks_button, GTK_ALIGN_START); - gtk_grid_attach(audio_grid, merge_audio_tracks_button, 0, audio_input_area_row++, 2, 1); + split_audio_button = gtk_check_button_new_with_label("Split each device/app audio into separate audio tracks"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(split_audio_button), false); + gtk_widget_set_halign(split_audio_button, GTK_ALIGN_START); + gtk_grid_attach(audio_grid, split_audio_button, 0, audio_input_area_row++, 2, 1); record_app_audio_inverted_button = gtk_check_button_new_with_label("Record audio from all applications except the selected ones"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(record_app_audio_inverted_button), false); @@ -3403,27 +3487,6 @@ static GtkWidget* create_common_settings_page(GtkStack *stack, GtkApplication *a return GTK_WIDGET(main_grid); } -static void replace_meta_with_super(std::string &str) { - size_t index = str.find("meta"); - if(index != std::string::npos) - str.replace(index, 4, "Super"); - - index = str.find("Meta"); - if(index != std::string::npos) - str.replace(index, 4, "Super"); -} - -static void shortcut_changed_callback(gsr_shortcut shortcut, void *userdata) { - (void)userdata; - std::string trigger = shortcut.trigger_description; - replace_meta_with_super(trigger); - for(int i = 0; i < num_hotkeys; ++i) { - if(strcmp(shortcut.id, hotkeys[i]->shortcut_id) == 0) { - gtk_entry_set_text(GTK_ENTRY(hotkeys[i]->hotkey_entry), trigger.c_str()); - } - } -} - static void deactivated_callback(const char *description, void *userdata) { (void)userdata; const GtkWidget *visible_page = gtk_stack_get_visible_child(page_navigation_userdata.stack); @@ -3436,54 +3499,23 @@ static void deactivated_callback(const char *description, void *userdata) { } } -static gboolean on_register_hotkeys_button_clicked(GtkButton *button, gpointer userdata) { - (void)button; - (void)userdata; - - /* - Modifier key names are defined here: https://github.com/xkbcommon/libxkbcommon/blob/master/include/xkbcommon/xkbcommon-names.h. - Remove the XKB_MOD_NAME_ prefix from the name and use the remaining part. - Key names are defined here: https://github.com/xkbcommon/libxkbcommon/blob/master/include/xkbcommon/xkbcommon-keysyms.h. - Remove the XKB_KEY_ (or XKB_KEY_KP_) prefix from the name and user the remaining part. - */ - /* Unfortunately global shortcuts cant handle same key for different shortcuts, even though GPU Screen Recorder has page specific hotkeys */ - const gsr_bind_shortcut shortcuts[3] = { - { - "Start/stop recording/replay/streaming", - { SHORTCUT_ID_START_STOP_RECORDING, "ALT+1" } - }, - { - "Pause/unpause recording", - { SHORTCUT_ID_PAUSE_UNPAUSE_RECORDING, "ALT+2" } - }, - { - "Save replay", - { SHORTCUT_ID_SAVE_REPLAY, "ALT+3" } - } - }; - - if(global_shortcuts_initialized) { - if(!gsr_global_shortcuts_bind_shortcuts(&global_shortcuts, shortcuts, 3, shortcut_changed_callback, NULL)) { - fprintf(stderr, "gsr error: failed to bind shortcuts\n"); - } - } - - return true; -} - static void add_wayland_global_hotkeys_ui(GtkGrid *grid, int &row, int width) { GtkGrid *aa_grid = GTK_GRID(gtk_grid_new()); gtk_widget_set_halign(GTK_WIDGET(aa_grid), GTK_ALIGN_CENTER); gtk_grid_attach(grid, GTK_WIDGET(aa_grid), 0, row++, width, 1); gtk_grid_set_column_spacing(aa_grid, 10); - gtk_grid_attach(aa_grid, gtk_label_new("On Wayland hotkeys are managed externally by the Wayland compositor, click here to change hotkeys:"), 0, 0, 1, 1); + if(wayland_compositor == WaylandCompositor::KDE) { + gtk_grid_attach(aa_grid, gtk_label_new("Hotkeys are managed externally on KDE Plasma Wayland. Click here to change hotkeys:"), 0, 0, 1, 1); - GtkButton *register_hotkeys_button = GTK_BUTTON(gtk_button_new_with_label("Change hotkeys")); - gtk_widget_set_hexpand(GTK_WIDGET(register_hotkeys_button), true); - //gtk_widget_set_halign(GTK_WIDGET(register_hotkeys_button), GTK_ALIGN_START); - g_signal_connect(register_hotkeys_button, "clicked", G_CALLBACK(on_register_hotkeys_button_clicked), nullptr); - gtk_grid_attach(aa_grid, GTK_WIDGET(register_hotkeys_button), 1, 0, 1, 1); + GtkButton *register_hotkeys_button = GTK_BUTTON(gtk_button_new_with_label("Change hotkeys")); + gtk_widget_set_hexpand(GTK_WIDGET(register_hotkeys_button), true); + //gtk_widget_set_halign(GTK_WIDGET(register_hotkeys_button), GTK_ALIGN_START); + g_signal_connect(register_hotkeys_button, "clicked", G_CALLBACK(on_register_hotkeys_button_clicked), nullptr); + gtk_grid_attach(aa_grid, GTK_WIDGET(register_hotkeys_button), 1, 0, 1, 1); + } else { + gtk_grid_attach(aa_grid, gtk_label_new("Hotkeys are managed externally on Wayland. Go into your system application/hotkey settings to change hotkeys."), 0, 0, 1, 1); + } row++; gtk_grid_attach(grid, gtk_separator_new(GTK_ORIENTATION_HORIZONTAL), 0, row, width, 1); @@ -4153,7 +4185,7 @@ static void load_config() { gtk_spin_button_set_value(video_height_entry, config.main_config.video_height); gtk_spin_button_set_value(fps_entry, config.main_config.fps); gtk_spin_button_set_value(video_bitrate_entry, config.main_config.video_bitrate); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(merge_audio_tracks_button), config.main_config.merge_audio_tracks); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(split_audio_button), !config.main_config.merge_audio_tracks); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(record_app_audio_inverted_button), config.main_config.record_app_audio_inverted); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(change_video_resolution_button), config.main_config.change_video_resolution); @@ -4246,7 +4278,8 @@ static void load_config() { "Unable to find a hardware video encoder on your system, using software video encoder instead (slow!). If you know that your system supports H264/HEVC hardware video encoding and " "you are using the flatpak version of GPU Screen Recorder then try installing mesa-extra freedesktop runtime by running this command:\n" "flatpak install --system org.freedesktop.Platform.GL.default//23.08-extra\n" - "and then restart GPU Screen Recorder. If that doesn't work then you may have to install another mesa package for your distro.\n" + "and then restart GPU Screen Recorder. If that doesn't work then you may have to install another mesa package for your distro if you are using AMD.\n" + "If you are using NVIDIA then you might need to run the \"nvidia-smi\" command first before starting GPU Screen Recorder if NVIDIA is incorrectly setup on your distro.\n" "If you are using a distro such as manjaro which disables hardware accelerated video encoding then you can also try the <a href=\"https://flathub.org/apps/com.dec05eba.gpu_screen_recorder\">flatpak version of GPU Screen Recorder</a> instead which doesn't have this issue."); set_dialog_selectable(dialog); gtk_dialog_run(GTK_DIALOG(dialog)); @@ -4297,19 +4330,16 @@ static void init_shortcuts_callback(bool success, void *userdata) { static const char* gpu_vendor_to_name(GpuVendor vendor) { switch(vendor) { - case GpuVendor::UNKNOWN: return "Unknown"; - case GpuVendor::AMD: return "AMD"; - case GpuVendor::INTEL: return "Intel"; - case GpuVendor::NVIDIA: return "NVIDIA"; + case GpuVendor::UNKNOWN: return "Unknown"; + case GpuVendor::AMD: return "AMD"; + case GpuVendor::INTEL: return "Intel"; + case GpuVendor::NVIDIA: return "NVIDIA"; + case GpuVendor::BROADCOM: return "Broadcom"; } return ""; } -static void activate(GtkApplication *app, gpointer) { - flatpak = is_inside_flatpak(); - nvfbc_installed = gsr_info.system_info.display_server != DisplayServer::WAYLAND && is_nv_fbc_installed(); - page_navigation_userdata.app = app; - +static bool gsr_startup_validation() { if(gsr_info_exit_status == GsrInfoExitStatus::FAILED_TO_RUN_COMMAND) { const char *cmd = flatpak ? "flatpak run --command=gpu-screen-recorder com.dec05eba.gpu_screen_recorder -w screen -f 60 -o video.mp4" : "gpu-screen-recorder -w screen -f 60 -o video.mp4"; GtkWidget *dialog = gtk_message_dialog_new_with_markup(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, @@ -4319,8 +4349,7 @@ static void activate(GtkApplication *app, gpointer) { set_dialog_selectable(dialog); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); - g_application_quit(G_APPLICATION(app)); - return; + return false; } if(gsr_info_exit_status == GsrInfoExitStatus::OPENGL_FAILED) { @@ -4331,8 +4360,7 @@ static void activate(GtkApplication *app, gpointer) { set_dialog_selectable(dialog); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); - g_application_quit(G_APPLICATION(app)); - return; + return false; } if(gsr_info_exit_status == GsrInfoExitStatus::NO_DRM_CARD) { @@ -4340,8 +4368,7 @@ static void activate(GtkApplication *app, gpointer) { "Failed to find a valid DRM card. If you are running GPU Screen Recorder with prime-run then try running without it."); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); - g_application_quit(G_APPLICATION(app)); - return; + return false; } if(gsr_info.system_info.display_server == DisplayServer::UNKNOWN) { @@ -4349,8 +4376,7 @@ static void activate(GtkApplication *app, gpointer) { "Neither X11 nor Wayland is running."); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); - g_application_quit(G_APPLICATION(app)); - return; + return false; } if(gsr_info.system_info.display_server == DisplayServer::X11 && !dpy) { @@ -4358,8 +4384,7 @@ static void activate(GtkApplication *app, gpointer) { "Failed to connect to the X11 server"); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); - g_application_quit(G_APPLICATION(app)); - return; + return false; } if(gsr_info.gpu_info.vendor == GpuVendor::NVIDIA) { @@ -4368,8 +4393,7 @@ static void activate(GtkApplication *app, gpointer) { "CUDA is not installed on your system. GPU Screen Recorder requires CUDA to be installed to work with a NVIDIA GPU."); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); - g_application_quit(G_APPLICATION(app)); - return; + return false; } if(!is_nvenc_installed()) { @@ -4377,12 +4401,22 @@ static void activate(GtkApplication *app, gpointer) { "NVENC is not installed on your system. GPU Screen Recorder requires NVENC to be installed to work with a NVIDIA GPU."); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); - g_application_quit(G_APPLICATION(app)); - return; + return false; } } - std::string window_title = "GPU Screen Recorder v" + std::string(GSR_VERSION) + " | Running on "; + return true; +} + +static void activate(GtkApplication *app, gpointer) { + if(!gsr_startup_validation()) { + g_application_quit(G_APPLICATION(app)); + return; + } + + page_navigation_userdata.app = app; + + std::string window_title = "GPU Screen Recorder | Running on "; window_title += gpu_vendor_to_name(gsr_info.gpu_info.vendor); window = gtk_application_window_new(app); @@ -4405,6 +4439,14 @@ static void activate(GtkApplication *app, gpointer) { gtk_window_set_default_icon_name(icon_name); gtk_window_set_icon_name(GTK_WINDOW(window), icon_name); + if(gsr_info.system_info.display_server == DisplayServer::WAYLAND) { + if(gdk_wayland_display_query_registry(gdk_display_get_default(), "hyprland_global_shortcuts_manager_v1")) { + wayland_compositor = WaylandCompositor::HYPRLAND; + } else if(gdk_wayland_display_query_registry(gdk_display_get_default(), "org_kde_plasma_shell")) { + wayland_compositor = WaylandCompositor::KDE; + } + } + select_window_userdata.app = app; audio_inputs = get_audio_devices(); application_audio = get_application_audio(); @@ -4454,12 +4496,6 @@ static void activate(GtkApplication *app, gpointer) { load_config(); if(gsr_info.system_info.display_server == DisplayServer::WAYLAND) { - if(gdk_wayland_display_query_registry(gdk_display_get_default(), "hyprland_global_shortcuts_manager_v1")) { - wayland_compositor = WaylandCompositor::HYPRLAND; - } else if(gdk_wayland_display_query_registry(gdk_display_get_default(), "org_kde_plasma_shell")) { - wayland_compositor = WaylandCompositor::KDE; - } - init_shortcuts_callback(false, nullptr); // TODO: // Disable global hotkeys on Hyprland for now. It crashes the hyprland desktop portal. @@ -4468,7 +4504,7 @@ static void activate(GtkApplication *app, gpointer) { // the desktop portal is restarted (when the computer is restarted for example). if(wayland_compositor == WaylandCompositor::HYPRLAND) { - const char *hotkeys_not_supported_text = "Global hotkeys have been disabled on your system because of a Hyprland bug.\nUse X11 or KDE Plasma on Wayland if you want to use hotkeys."; + const char *hotkeys_not_supported_text = "Hotkeys have been disabled on your system because of a Hyprland bug.\nUse X11 or KDE Plasma on Wayland if you want to use hotkeys."; gtk_label_set_text(GTK_LABEL(recording_hotkeys_not_supported_label), hotkeys_not_supported_text); gtk_label_set_text(GTK_LABEL(replay_hotkeys_not_supported_label), hotkeys_not_supported_text); gtk_label_set_text(GTK_LABEL(streaming_hotkeys_not_supported_label), hotkeys_not_supported_text); @@ -4481,13 +4517,8 @@ static void activate(GtkApplication *app, gpointer) { } static bool is_kms_server_proxy_installed() { - const char *user_homepath = getenv("HOME"); - if(!user_homepath) - user_homepath = "/tmp"; - - char path[PATH_MAX]; - snprintf(path, sizeof(path), "%s/.local/share/gpu-screen-recorder/kms-server-proxy-1", user_homepath); - return access(path, F_OK) == 0; + const int exit_code = system("flatpak-spawn --host -- /var/lib/flatpak/app/com.dec05eba.gpu_screen_recorder/current/active/files/bin/kms-server-proxy is-setup"); + return exit_code == 0; } static void gtk_activate_handler_run_and_quit(GtkApplication *app, gpointer userdata) { @@ -4526,6 +4557,11 @@ static void startup_new_ui(bool launched_by_daemon) { } } + start_gtk_run_handler([]() { + if(!gsr_startup_validation()) + exit(1); + }); + if(!flatpak_is_installed_as_system()) { start_gtk_run_handler([]() { GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, @@ -4535,7 +4571,7 @@ static void startup_new_ui(bool launched_by_daemon) { gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); }); - return; + exit(1); } if(config.main_config.installed_gsr_global_hotkeys_version != GSR_CURRENT_GLOBAL_HOTKEYS_CODE_VERSION) { @@ -4566,15 +4602,15 @@ static void startup_new_ui(bool launched_by_daemon) { if(dpy) XCloseDisplay(dpy); - launch_gsr_ui(!launched_by_daemon); + launch_gsr_ui(launched_by_daemon); exit(0); } int main(int argc, char **argv) { setlocale(LC_ALL, "C"); - const bool use_old_ui_opt = argc == 2 && strcmp(argv[1], "use-old-ui") == 0; - const bool launched_by_daemon_opt = argc == 2 && strcmp(argv[1], "gsr-ui") == 0; + const bool use_old_ui_opt = argc >= 2 && strcmp(argv[1], "use-old-ui") == 0; + const bool launched_by_daemon_opt = argc >= 2 && strcmp(argv[1], "gsr-ui") == 0; argc = 1; if(geteuid() == 0) { @@ -4587,17 +4623,12 @@ int main(int argc, char **argv) { config_empty = false; config = read_config(config_empty); - if(use_old_ui_opt) { - system("flatpak-spawn --host -- systemctl disable --now --user gpu-screen-recorder-ui"); - config.main_config.use_new_ui = false; - save_config(config); + if(!dpy && launched_by_daemon_opt && config.main_config.use_new_ui) { + fprintf(stderr, "Error: failed to connect to the X11 server, assuming no graphical session has started yet\n"); + exit(1); } - if(config.main_config.use_new_ui) - startup_new_ui(launched_by_daemon_opt); - gsr_info_exit_status = get_gpu_screen_recorder_info(&gsr_info); - if(gsr_info_exit_status == GsrInfoExitStatus::OK) { if(gsr_info.system_info.display_server == DisplayServer::WAYLAND) { setenv("GDK_BACKEND", "wayland", true); @@ -4606,6 +4637,19 @@ int main(int argc, char **argv) { } } + flatpak = is_inside_flatpak(); + nvfbc_installed = gsr_info.system_info.display_server != DisplayServer::WAYLAND && is_nv_fbc_installed(); + + if(use_old_ui_opt) { + system("flatpak-spawn --host -- systemctl disable --user gpu-screen-recorder-ui"); + system("flatpak-spawn --host -- systemctl stop --user gpu-screen-recorder-ui"); + config.main_config.use_new_ui = false; + save_config(config); + } + + if(config.main_config.use_new_ui) + startup_new_ui(launched_by_daemon_opt); + char app_id[] = "com.dec05eba.gpu_screen_recorder"; // Gtk sets wayland app id / x11 wm class from the binary name, so we override it here. // This is needed for the correct window icon on wayland (app id needs to match the desktop file name). |