From a28ed6023ebbb778752048d0180ec4c33ad1471a Mon Sep 17 00:00:00 2001 From: altrup <51763643+altrup@users.noreply.github.com> Date: Sun, 22 Mar 2026 17:44:30 -0400 Subject: [PATCH] Update quickslider to also decrease gamma when brightness is at 0 --- .../modules/ii/sidebarRight/QuickSliders.qml | 45 ++++++++++++++++--- .../quickshell/ii/services/Hyprsunset.qml | 37 ++++----------- 2 files changed, 47 insertions(+), 35 deletions(-) diff --git a/dots/.config/quickshell/ii/modules/ii/sidebarRight/QuickSliders.qml b/dots/.config/quickshell/ii/modules/ii/sidebarRight/QuickSliders.qml index 26925001e..7983e6098 100644 --- a/dots/.config/quickshell/ii/modules/ii/sidebarRight/QuickSliders.qml +++ b/dots/.config/quickshell/ii/modules/ii/sidebarRight/QuickSliders.qml @@ -40,10 +40,24 @@ Rectangle { visible: active active: Config.options.sidebar.quickSliders.showBrightness sourceComponent: QuickSlider { - materialSymbol: "brightness_6" - value: root.brightnessMonitor.brightness + materialSymbol: "light_mode" + secondaryMaterialSymbol: "wb_twilight" + value: Hyprsunset.gamma === 100? 0.3 + root.brightnessMonitor.brightness * 0.7 : Hyprsunset.gamma / 100 * 0.3 + tooltipContent: Hyprsunset.gamma === 100 ? `${Math.round(root.brightnessMonitor.brightness * 100)}%` : `${Hyprsunset.gamma}%` onMoved: { - root.brightnessMonitor.setBrightness(value) + if (value >= 0.3) { + // 0.3 - 1.0 brightness + root.brightnessMonitor.setBrightness((value - 0.3) / 0.7); + if (Hyprsunset.gamma !== 100) { + Hyprsunset.setGamma(100); + } + } else { + // 0 - 0.3 gamma + if (root.brightnessMonitor.brightness !== 0) { + root.brightnessMonitor.setBrightness(0); + } + Hyprsunset.setGamma(value * 100 / 0.3); + } } } } @@ -84,6 +98,7 @@ Rectangle { component QuickSlider: StyledSlider { id: quickSlider required property string materialSymbol + property string secondaryMaterialSymbol configuration: StyledSlider.Configuration.M stopIndicatorValues: [] @@ -91,9 +106,9 @@ Rectangle { id: icon property bool nearFull: quickSlider.value >= 0.9 anchors { - verticalCenter: parent.verticalCenter - right: nearFull ? quickSlider.handle.right : parent.right - rightMargin: quickSlider.nearFull ? 14 : 8 + verticalCenter: quickSlider.verticalCenter + right: nearFull ? quickSlider.handle.right : quickSlider.right + rightMargin: nearFull ? 14 : 8 } iconSize: 20 color: nearFull ? Appearance.colors.colOnPrimary : Appearance.colors.colOnSecondaryContainer @@ -105,7 +120,25 @@ Rectangle { Behavior on anchors.rightMargin { animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this) } + } + MaterialSymbol { + id: secondaryIcon + visible: secondaryMaterialSymbol.length > 0 + property real iconLocation: 0.3 + property bool nearIcon: iconLocation - quickSlider.value <= 0.1 && iconLocation - quickSlider.value > -0.03 + anchors { + verticalCenter: quickSlider.verticalCenter + right: nearIcon ? quickSlider.handle.right : quickSlider.right + rightMargin: nearIcon ? 14 : (1 - iconLocation) * quickSlider.width + } + iconSize: 20 + color: quickSlider.value >= iconLocation - 0.1 ? Appearance.colors.colOnPrimary : Appearance.colors.colOnSecondaryContainer + text: secondaryMaterialSymbol + + Behavior on color { + animation: Appearance.animation.elementMoveFast.colorAnimation.createObject(this) + } } } } diff --git a/dots/.config/quickshell/ii/services/Hyprsunset.qml b/dots/.config/quickshell/ii/services/Hyprsunset.qml index 6af2d6da5..5749ee251 100644 --- a/dots/.config/quickshell/ii/services/Hyprsunset.qml +++ b/dots/.config/quickshell/ii/services/Hyprsunset.qml @@ -80,28 +80,21 @@ Singleton { } } - function load() { } // Dummy to force init + function load() { + Quickshell.execDetached(["bash", "-c", `pidof hyprsunset || hyprsunset`]); + } function enableTemperature() { root.temperatureActive = true; // console.log("[Hyprsunset] Enabling"); - Quickshell.execDetached(["bash", "-c", ` - if pidof hyprsunset > /dev/null; then - hyprctl hyprsunset temperature ${root.colorTemperature}; - else - hyprsunset --temperature ${root.colorTemperature}; - fi - `]); + root.load(); + Quickshell.execDetached(["bash", "-c", `hyprctl hyprsunset temperature ${root.colorTemperature}`]); } function disableTemperature() { root.temperatureActive = false; // console.log("[Hyprsunset] Disabling"); - if (root.gamma === 100) { - Quickshell.execDetached(["bash", "-c", `pkill hyprsunset`]); - } else { - Quickshell.execDetached(["hyprctl", "hyprsunset", "identity"]); - } + Quickshell.execDetached(["hyprctl", "hyprsunset", "identity"]); } function setGamma(gamma) { @@ -109,22 +102,8 @@ Singleton { root.gammaChangeAttempt(); - if (root.gamma !== 100) { - // console.log("[Hyprsunset] Enabling"); - Quickshell.execDetached(["bash", "-c", ` - if pidof hyprsunset > /dev/null; then - hyprctl hyprsunset gamma ${root.gamma}; - else - hyprsunset --gamma ${root.gamma}; - fi - `]); - } else { - if (!root.temperatureActive) { - Quickshell.execDetached(["bash", "-c", `pkill hyprsunset`]); - } else { - Quickshell.execDetached(["hyprctl", "hyprsunset", "gamma", "100"]); - } - } + root.load(); + Quickshell.execDetached(["bash", "-c", `hyprctl hyprsunset gamma ${root.gamma}`]); } function fetchState() {