mirror of
https://github.com/end-4/dots-hyprland.git
synced 2026-06-05 14:59:27 -05:00
Update quickslider to also decrease gamma when brightness is at 0
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user