mirror of
https://github.com/end-4/dots-hyprland.git
synced 2026-06-05 14:59:27 -05:00
93 lines
1.9 KiB
QML
93 lines
1.9 KiB
QML
pragma Singleton
|
|
pragma ComponentBehavior: Bound
|
|
import Quickshell
|
|
import Quickshell.Io
|
|
import Quickshell.Hyprland
|
|
|
|
Singleton {
|
|
id: root
|
|
|
|
property bool ready: false
|
|
property real value
|
|
property int increment: 0
|
|
|
|
function refresh() {
|
|
getBrightness.running = true;
|
|
}
|
|
|
|
onIncrementChanged: () => {
|
|
if (increment > 0) {
|
|
increaseBrightness.running = true;
|
|
root.increment = 0;
|
|
} else if (increment < 0) {
|
|
decreaseBrightness.running = true;
|
|
root.increment = 0;
|
|
}
|
|
}
|
|
|
|
Process {
|
|
id: getBrightness
|
|
|
|
command: ["sh", "-c", "brightnessctl -m i | cut -d, -f4"]
|
|
running: true
|
|
onExited: {
|
|
if (!ready) ready = true
|
|
}
|
|
|
|
stdout: SplitParser {
|
|
onRead: (data) => {
|
|
root.value = parseFloat(data.replace("%", "")) / 100;
|
|
if (root.value < 0.01) {
|
|
preventPitchBlack.running = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
Process {
|
|
id: decreaseBrightness
|
|
|
|
command: ["brightnessctl", "set", "5%-", "-e"]
|
|
running: false
|
|
onExited: {
|
|
running = false;
|
|
getBrightness.running = true;
|
|
}
|
|
}
|
|
|
|
Process {
|
|
id: increaseBrightness
|
|
|
|
command: ["brightnessctl", "set", "5%+", "-e"]
|
|
running: false
|
|
onExited: {
|
|
running = false;
|
|
getBrightness.running = true;
|
|
}
|
|
}
|
|
|
|
Process {
|
|
id: preventPitchBlack
|
|
|
|
command: ["brightnessctl", "set", "1%+", "-e"]
|
|
running: false
|
|
onExited: {
|
|
running = false;
|
|
getBrightness.running = true;
|
|
}
|
|
}
|
|
|
|
IpcHandler {
|
|
target: "brightness"
|
|
|
|
function increment() {
|
|
root.increment = 1
|
|
}
|
|
|
|
function decrement() {
|
|
root.increment = -1
|
|
}
|
|
}
|
|
}
|