From 1630d00ec09211e0791e8053071a63638af875cc Mon Sep 17 00:00:00 2001 From: Dunestorm Date: Wed, 1 Jan 2025 01:29:40 +0000 Subject: [PATCH] HDR-Helper v1.1.0.0 WIP -Implemented experimental HDR brightness control. --- README.md | 8 +++++--- hdr-helper | 28 ++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 41b8b93..004f283 100644 --- a/README.md +++ b/README.md @@ -47,9 +47,11 @@ chmod +x ~/.local/usr/bin/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= # -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> +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 ``` `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. diff --git a/hdr-helper b/hdr-helper index 7265f4b..d0f9fcb 100755 --- a/hdr-helper +++ b/hdr-helper @@ -1,10 +1,9 @@ #!/bin/bash _VERSION=1.1.0.0 -CONFIG_FILE="$HOME/.config/hdr-helper/monitor.conf" -MONITOR= # MODIFY THESE VALUES INSIDE MONITOR.CONF # -NATIVE_RES= ########################################### -TEMP_RES= ########################################### +CONFIG_PATH="$HOME/.config/hdr-helper/" +CONFIG_FILE="$CONFIG_PATH/monitor.conf" +CONFIG_CURR_BRIGHTNESS="$CONFIG_PATH/current-brightness-level" show_hdr_status() { ICON="/usr/share/icons/breeze-dark/devices/64/monitor.svg" @@ -16,6 +15,25 @@ show_hdr_status() { fi } +set_brightness() { + if [ "$HDR_TARGET_BRIGHTNESS" -gt 0 ]; then + 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 + 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) + fi +} + refresh_display() { kscreen-doctor output.$MONITOR.mode.$TEMP_RES kscreen-doctor output.$MONITOR.mode.$NATIVE_RES @@ -25,11 +43,13 @@ refresh_display() { enable_hdr () { kscreen-doctor output.$MONITOR.hdr.enable refresh_display + set_brightness } disable_hdr() { kscreen-doctor output.$MONITOR.hdr.disable refresh_display + restore_brightness } auto_hdr() {