diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 0857c42..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore all .conf files from changing -*.conf diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..fdb0488 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,22 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "bashdb", + "request": "launch", + "name": "Bash-Debug (hardcoded script name)", + "cwd": "${workspaceFolder}", + "program": "${workspaceFolder}/hdr-helper", + "args": [] + }, + { + "type": "bashdb", + "request": "launch", + "name": "Bash-Debug (simplest configuration)", + "program": "${file}" + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 004f283..30d1a5c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# hdr-helper +# hdr-helper 💻 Linux script to control and automatically toggle HDR on KDE Plasma. ![image](https://github.com/user-attachments/assets/87bc05e1-9235-487c-a61f-c03f273b3e4a) @@ -7,6 +7,12 @@ I've personally tested this on Fedora 41 Plasma Edition on an RX 6800XT using th are built into the Linux Kernel. I only have one display, I've not accounted for multi-display scenarios so please take this into consideration :) +## Supported Features 📋 +- Automatically & manually toggling HDR on and off. +- Notifying you whether HDR has been successfully activated. +- Setting a target SDR brightness level whilst in HDR mode. + - Your original non-HDR brightness level will be preserved when switching back. + # The Problem At this moment in time, pretty much all games require HDR to be manually enabled for it to properly function. Normally this isn't a problem when using Gamescope as your native compositor. Most people however run a fully fledged desktop @@ -29,30 +35,20 @@ this script manually and force HDR to be on or off if you so desire. --- # Setup - -1. Copy the script to a location within your $PATH for ease of access, such as ~/.local/usr/bin. -2. Modify the monitor.conf file. -3. You should now be able to call `hdr-helper -v` from your terminal - --OR- - -You may also clone this repository and create a symbolic link to the file to receive any future updates: +To start with, clone this repository and create a symbolic link to the file: ```bash git clone https://github.com/dunestorm333/hdr-helper.git cd hdr-helper ln -s hdr-helper ~/.local/bin/ -chmod +x ~/.local/usr/bin/hdr-helper +chmod +x ~/.local/bin/hdr-helper + +# You will also need to copy monitor.conf into ~/.config/hdr-helper +mkdir ~/.config/hdr-helper +cp monitor.conf ~/.config/hdr-helper ``` -You will then need to create the following file `~/.config/hdr-helper/monitor.conf`. Copy the below template and adjust to your PC's -configuration: -```bash -MONITOR= # DP-1 | Enter your monitor ID from xrandr. -NATIVE_RES= # 3440x1440@165 | Enter your native monitor resolution followed by the refresh rate. -TEMP_RES= # 2560x1440@144 | Enter a different resolution or refresh rate from your native. -HDR_TARGET_BRIGHTNESS=0 # 100 | Enter a target brightness level for your display in HDR mode [0,10-100]. - # 0 | Default -``` +**Ensure to modify `monitor.conf` with your desired settings.** + `xrandr` will give you the following output; in the below example `DP-3` is the value we need to use to target the active monitor. ``` @@ -97,7 +93,7 @@ hdr-helper ; gamescope -W 3440 -H 1440 -r 165 -f --hdr-enabled -- %command% ; hd The commands you need to get this working with pretty much any app or game is very similar to the Steam method. Note that in both cases, Gamescope is required as HDR requires a valid HDR layer and compositor to properly function in addition to working drivers. ``` bash -hdr-helper; gamescope -W 3440 -w 1920 -H 1440 -h 1080 -r 165 -f --hdr-enabled ~/my-app-or-game; hdr-helper +hdr-helper; gamescope -W 3440 -H 1440 -r 165 -f --hdr-enabled ~/my-app-or-game; hdr-helper ``` ## Manual Approach If you'd like to manually bind HDR Helper to a shortcut key for example, this can easily by configured in most desktop environments. diff --git a/hdr-helper b/hdr-helper index d0f9fcb..c8a4c8f 100755 --- a/hdr-helper +++ b/hdr-helper @@ -16,21 +16,21 @@ show_hdr_status() { } set_brightness() { - if [ "$HDR_TARGET_BRIGHTNESS" -gt 0 ]; then + if [[ "$SDR_TARGET_BRIGHTNESS" -gt 0 ]]; then + # Store the current brightness level before attempting to update it. kscreen-doctor -o | \ grep Brightness | \ head -n 1 | \ - sed 's/.*set to \([0-9]\+\)%.*/\1/' \ - > $CONFIG_CURR_BRIGHTNESS - echo "DEBUG: TARGET BRIGHTNESS" $HDR_TARGET_BRIGHTNESS - kscreen-doctor output.$MONITOR.brightness.$HDR_TARGET_BRIGHTNESS + grep -oP "(?<=set to )[0-9]+" \ + > $CONFIG_CURR_BRIGHTNESS + kscreen-doctor output.$MONITOR.brightness.$SDR_TARGET_BRIGHTNESS fi } restore_brightness() { if [ -f $CONFIG_CURR_BRIGHTNESS ]; then - echo "Debug: CURRENT BRIGHTNESS" $(cat $CONFIG_CURR_BRIGHTNESS) kscreen-doctor output.$MONITOR.brightness.$(cat $CONFIG_CURR_BRIGHTNESS) + rm $CONFIG_CURR_BRIGHTNESS fi } diff --git a/monitor.conf b/monitor.conf new file mode 100644 index 0000000..82d2ae1 --- /dev/null +++ b/monitor.conf @@ -0,0 +1,9 @@ +# Copy this file into ~/.config/hdr-helper +# +# # Example Value | Description +# #---------------|--------------------------------------------------------------------------------# +MONITOR= # DP-1 | Enter your monitor ID from xrandr. +NATIVE_RES= # 3440x1440@165 | Enter your native monitor resolution followed by the refresh rate +TEMP_RES= # 2560x1440@144 | Enter a different resolution or refresh rate from your native. +SDR_TARGET_BRIGHTNESS=0 # 100 | Enter a target SDR brightness level for your display when in HDR mode [0,1-100]. + # 0 | Default \ No newline at end of file