fix: hide detailed text of MonitorItem immediatly after hovering and changing the value & specify device for brightnessctl

This commit is contained in:
2025-10-17 18:18:23 +02:00
parent 5378c43727
commit bf984237a7
6 changed files with 35 additions and 10 deletions

6
.scripts/set-brightness Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/sh
[ -z "$1" ] && exit 1
[ -z "$BRIGHTNESSCTL_DEVICE" ] && BRIGHTNESSCTL_DEVICE="auto"
brightnessctl -d "$BRIGHTNESSCTL_DEVICE" set "$1"

View File

@@ -23,8 +23,17 @@ for link in /dev/dri/by-path/*-card; do
esac
done
# AQ_DRM_DEVICES allow multiple entries separated by colon
# Set it according to preference order
# Specify device for brightnessctl
# Only tested on my laptop with Intel iGPU & Nvidia dGPU
BRIGHTNESSCTL_DEVICE="auto"
if [[ -n "$intel_path" ]]; then
BRIGHTNESSCTL_DEVICE="intel_backlight"
elif [[ -n "$nvidia_path" ]]; then
BRIGHTNESSCTL_DEVICE="nvidia_0"
fi
export BRIGHTNESSCTL_DEVICE
# AQ_DRM_DEVICES allows multiple entries separated by colon
devices=""
for who in "${prefer_order[@]}"; do
case "$who" in
@@ -48,13 +57,13 @@ done
# Update niri config
for file in "$HOME/.config/niri/config.kdl" "$HOME/.config/niri/config.kdl.template"; do
[[ -f "$file" ]] || return 0
[[ -f "$file" ]] || continue
if grep -qE '^\s*render-drm-device\s+"[^"]+"' "$file"; then
current="$(grep -E '^\s*render-drm-device\s+"[^"]+"' "$file" | sed -E 's/^\s*render-drm-device\s+"([^"]+)".*/\1/')"
[[ "$current" == "$primary_device" ]] && return 0
[[ "$current" == "$primary_device" ]] && continue
sed -i -E "s|^(\s*render-drm-device\s+)\"[^\"]+\"|\1\"$primary_device\"|" "$file"
else
printf '\ndebug {\nrender-drm-device "%s"\n}\n' "$primary_device" >> "$file"
fi
done
done

View File

@@ -322,8 +322,8 @@ binds {
XF86AudioPrev allow-when-locked=true { spawn-sh "playerctl previous"; }
// Brightness
XF86MonBrightnessUp allow-when-locked=true { spawn "brightnessctl" "--class=backlight" "set" "+10%"; }
XF86MonBrightnessDown allow-when-locked=true { spawn "brightnessctl" "--class=backlight" "set" "10%-"; }
XF86MonBrightnessUp allow-when-locked=true { spawn "set-brightness" "+10%"; }
XF86MonBrightnessDown allow-when-locked=true { spawn "set-brightness" "10%-"; }
// Window management
Mod+Tab repeat=false { toggle-overview; }

View File

@@ -322,8 +322,8 @@ binds {
XF86AudioPrev allow-when-locked=true { spawn-sh "playerctl previous"; }
// Brightness
XF86MonBrightnessUp allow-when-locked=true { spawn "brightnessctl" "--class=backlight" "set" "+10%"; }
XF86MonBrightnessDown allow-when-locked=true { spawn "brightnessctl" "--class=backlight" "set" "10%-"; }
XF86MonBrightnessUp allow-when-locked=true { spawn "set-brightness" "+10%"; }
XF86MonBrightnessDown allow-when-locked=true { spawn "set-brightness" "10%-"; }
// Window management
Mod+Tab repeat=false { toggle-overview; }

View File

@@ -18,6 +18,7 @@ Item {
property real hideTimeOut: 2000 // ms
property bool forceExpand: false
property bool _expand: forceExpand || mouseArea.containsMouse
property bool _isFirst: true
property bool disableHover: false
property bool critical: false
property color criticalColor: Colors.red
@@ -39,6 +40,15 @@ Item {
sourceComponent: Connections {
function onValueChanged() {
// No need to expand (again) if already hovering
if (mouseArea.containsMouse)
return ;
// Skip first change (which is most likely initialization)
if (root._isFirst) {
root._isFirst = false;
return ;
}
root.forceExpand = true;
hideTimer.restart();
}

View File

@@ -281,7 +281,7 @@ Singleton {
Quickshell.execDetached(["ddcutil", "-b", busNum, "setvcp", "10", rounded])
} else {
monitor.ignoreNextChange = true
Quickshell.execDetached(["brightnessctl", "s", rounded + "%"])
Quickshell.execDetached(["set-brightness", rounded + "%"])
}
if (isDdc) {