diff --git a/.scripts/set-brightness b/.scripts/set-brightness new file mode 100755 index 0000000..f6834f3 --- /dev/null +++ b/.scripts/set-brightness @@ -0,0 +1,6 @@ +#!/bin/sh + +[ -z "$1" ] && exit 1 +[ -z "$BRIGHTNESSCTL_DEVICE" ] && BRIGHTNESSCTL_DEVICE="auto" + +brightnessctl -d "$BRIGHTNESSCTL_DEVICE" set "$1" \ No newline at end of file diff --git a/.utils/set_display b/.utils/set_display index a6cc0da..c6382fd 100644 --- a/.utils/set_display +++ b/.utils/set_display @@ -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 \ No newline at end of file +done diff --git a/niri/config.kdl b/niri/config.kdl index 9742483..9b020c1 100644 --- a/niri/config.kdl +++ b/niri/config.kdl @@ -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; } diff --git a/niri/config.kdl.template b/niri/config.kdl.template index ad655c3..9f5ae13 100644 --- a/niri/config.kdl.template +++ b/niri/config.kdl.template @@ -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; } diff --git a/quickshell/Modules/Bar/Misc/MonitorItem.qml b/quickshell/Modules/Bar/Misc/MonitorItem.qml index 6e4bf09..b4e51da 100644 --- a/quickshell/Modules/Bar/Misc/MonitorItem.qml +++ b/quickshell/Modules/Bar/Misc/MonitorItem.qml @@ -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(); } diff --git a/quickshell/Services/BrightnessService.qml b/quickshell/Services/BrightnessService.qml index 1bb59da..2ad976f 100644 --- a/quickshell/Services/BrightnessService.qml +++ b/quickshell/Services/BrightnessService.qml @@ -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) {