Update quickslider to also decrease gamma when brightness is at 0

This commit is contained in:
altrup
2026-03-22 17:44:30 -04:00
parent 973b83bc15
commit a28ed6023e
2 changed files with 47 additions and 35 deletions
@@ -40,10 +40,24 @@ Rectangle {
visible: active visible: active
active: Config.options.sidebar.quickSliders.showBrightness active: Config.options.sidebar.quickSliders.showBrightness
sourceComponent: QuickSlider { sourceComponent: QuickSlider {
materialSymbol: "brightness_6" materialSymbol: "light_mode"
value: root.brightnessMonitor.brightness 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: { 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 { component QuickSlider: StyledSlider {
id: quickSlider id: quickSlider
required property string materialSymbol required property string materialSymbol
property string secondaryMaterialSymbol
configuration: StyledSlider.Configuration.M configuration: StyledSlider.Configuration.M
stopIndicatorValues: [] stopIndicatorValues: []
@@ -91,9 +106,9 @@ Rectangle {
id: icon id: icon
property bool nearFull: quickSlider.value >= 0.9 property bool nearFull: quickSlider.value >= 0.9
anchors { anchors {
verticalCenter: parent.verticalCenter verticalCenter: quickSlider.verticalCenter
right: nearFull ? quickSlider.handle.right : parent.right right: nearFull ? quickSlider.handle.right : quickSlider.right
rightMargin: quickSlider.nearFull ? 14 : 8 rightMargin: nearFull ? 14 : 8
} }
iconSize: 20 iconSize: 20
color: nearFull ? Appearance.colors.colOnPrimary : Appearance.colors.colOnSecondaryContainer color: nearFull ? Appearance.colors.colOnPrimary : Appearance.colors.colOnSecondaryContainer
@@ -105,7 +120,25 @@ Rectangle {
Behavior on anchors.rightMargin { Behavior on anchors.rightMargin {
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this) 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)
}
} }
} }
} }
@@ -80,28 +80,21 @@ Singleton {
} }
} }
function load() { } // Dummy to force init function load() {
Quickshell.execDetached(["bash", "-c", `pidof hyprsunset || hyprsunset`]);
}
function enableTemperature() { function enableTemperature() {
root.temperatureActive = true; root.temperatureActive = true;
// console.log("[Hyprsunset] Enabling"); // console.log("[Hyprsunset] Enabling");
Quickshell.execDetached(["bash", "-c", ` root.load();
if pidof hyprsunset > /dev/null; then Quickshell.execDetached(["bash", "-c", `hyprctl hyprsunset temperature ${root.colorTemperature}`]);
hyprctl hyprsunset temperature ${root.colorTemperature};
else
hyprsunset --temperature ${root.colorTemperature};
fi
`]);
} }
function disableTemperature() { function disableTemperature() {
root.temperatureActive = false; root.temperatureActive = false;
// console.log("[Hyprsunset] Disabling"); // console.log("[Hyprsunset] Disabling");
if (root.gamma === 100) { Quickshell.execDetached(["hyprctl", "hyprsunset", "identity"]);
Quickshell.execDetached(["bash", "-c", `pkill hyprsunset`]);
} else {
Quickshell.execDetached(["hyprctl", "hyprsunset", "identity"]);
}
} }
function setGamma(gamma) { function setGamma(gamma) {
@@ -109,22 +102,8 @@ Singleton {
root.gammaChangeAttempt(); root.gammaChangeAttempt();
if (root.gamma !== 100) { root.load();
// console.log("[Hyprsunset] Enabling"); Quickshell.execDetached(["bash", "-c", `hyprctl hyprsunset gamma ${root.gamma}`]);
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"]);
}
}
} }
function fetchState() { function fetchState() {