From 77c78135fcc4be18b90649381f3135faef3f09d7 Mon Sep 17 00:00:00 2001 From: Dunestorm Date: Wed, 1 Jan 2025 18:54:48 +0000 Subject: [PATCH] HDR-Helper v1.2.0.0 - WCG (Wide Color Gamut) is now toggled accordingly when switching. - SDR to HDR conversion brightness level can now also be adjusted in nits. - Migrated temporary brightness level value to /tmp as it's more appropriate than in ~/.config. --- hdr-helper | 40 ++++++++++++++++++++++++++++------------ monitor.conf | 15 ++++++++------- 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/hdr-helper b/hdr-helper index c8a4c8f..f5108fd 100755 --- a/hdr-helper +++ b/hdr-helper @@ -1,9 +1,10 @@ #!/bin/bash -_VERSION=1.1.0.0 +_VERSION=1.2.0.0 CONFIG_PATH="$HOME/.config/hdr-helper/" CONFIG_FILE="$CONFIG_PATH/monitor.conf" -CONFIG_CURR_BRIGHTNESS="$CONFIG_PATH/current-brightness-level" +CURR_BRIGHT_LVL_PATH="/tmp/hdr-helper/" +CURR_BRIGHT_LVL_FILE="$CURR_BRIGHT_LVL_PATH/current-brightness-level" show_hdr_status() { ICON="/usr/share/icons/breeze-dark/devices/64/monitor.svg" @@ -16,21 +17,30 @@ show_hdr_status() { } set_brightness() { - 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 | \ - grep -oP "(?<=set to )[0-9]+" \ - > $CONFIG_CURR_BRIGHTNESS + if [ ! -f $CURR_BRIGHT_LVL_PATH ]; then + mkdir $CURR_BRIGHT_LVL_PATH + fi + + kscreen-doctor -o | \ + grep Brightness | \ + head -n 1 | \ + grep -oP "(?<=set to )[0-9]+" \ + > $CURR_BRIGHT_LVL_FILE + + if [ -v SDR_TARGET_BRIGHTNESS ]; then kscreen-doctor output.$MONITOR.brightness.$SDR_TARGET_BRIGHTNESS fi + + if [ -v SDR_TARGET_BRIGHTNESS_NITS ]; then + kscreen-doctor output.$MONITOR.sdr-brightness.$SDR_TARGET_BRIGHTNESS_NITS + fi } restore_brightness() { - if [ -f $CONFIG_CURR_BRIGHTNESS ]; then - kscreen-doctor output.$MONITOR.brightness.$(cat $CONFIG_CURR_BRIGHTNESS) - rm $CONFIG_CURR_BRIGHTNESS + if [ -f $CURR_BRIGHT_LVL_FILE ]; then + kscreen-doctor output.$MONITOR.brightness.$(cat $CURR_BRIGHT_LVL_FILE) + rm $CURR_BRIGHT_LVL_FILE fi } @@ -42,12 +52,14 @@ refresh_display() { enable_hdr () { kscreen-doctor output.$MONITOR.hdr.enable + kscreen-doctor output.$MONITOR.wcg.enable refresh_display set_brightness } disable_hdr() { kscreen-doctor output.$MONITOR.hdr.disable + kscreen-doctor output.$MONITOR.wcg.disable refresh_display restore_brightness } @@ -78,7 +90,11 @@ show_help () { echo "is present on your system for HDR Helper to function." echo "" echo "--- Config ---" - echo "Please modify the MONITOR, NATIVE_RES and TEMP_RES values in monitor.conf." + echo "Copy monitor.conf to ~/.config/hdr-helper and ensure to modify this file with your" + echo "desired settings." + echo "" + echo "Please refer to README.md or https://github.com/dunestorm333/hdr-helper for further" + echo "setup instructions." } # Check Dependencies diff --git a/monitor.conf b/monitor.conf index 82d2ae1..47fb1eb 100644 --- a/monitor.conf +++ b/monitor.conf @@ -1,9 +1,10 @@ # 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 +# # 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]. +#SDR_TARGET_BRIGHTNESS_NITS= # 450 | Enter a target SDR brightness level in nits when in HDR mode. Please refer to you + # | display's specs for this information. \ No newline at end of file