diff options
| author | Leander Scherer <leander@schererleander.de> | 2026-05-18 21:48:24 +0200 |
|---|---|---|
| committer | Leander Scherer <leander@schererleander.de> | 2026-05-28 22:42:07 +0200 |
| commit | 9a7cf1242d296dbdb9c03df48ab09054960295aa (patch) | |
| tree | f1a2d5c77ef6bdb049c995afcc4c663c1ffd1373 /modules/system/quickshell/BrightnessService.qml | |
| parent | 3ef8b4973bcae26445f99467d50ad75730d204b5 (diff) | |
feat(quickshell): basic bar, tray, notification
Diffstat (limited to 'modules/system/quickshell/BrightnessService.qml')
| -rw-r--r-- | modules/system/quickshell/BrightnessService.qml | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/modules/system/quickshell/BrightnessService.qml b/modules/system/quickshell/BrightnessService.qml new file mode 100644 index 0000000..991a6ec --- /dev/null +++ b/modules/system/quickshell/BrightnessService.qml @@ -0,0 +1,36 @@ +import QtQuick +import Quickshell +import Quickshell.Io + +// Simplified brightness service using brightnessctl. +QtObject { + id: root + property real brightness: 0 + property int maxBrightness: 1 + + function update() { + updateProc.running = true + } + + function setBrightness(value) { + const raw = Math.round(value * maxBrightness) + Quickshell.execDetached(["brightnessctl", "s", raw.toString()]) + brightness = value + } + + readonly property Process updateProc: Process { + command: ["sh", "-c", "brightnessctl g && brightnessctl m"] + stdout: SplitParser { + onRead: data => { + const lines = data.trim().split("\n") + if (lines.length >= 2) { + const current = parseInt(lines[0]) + root.maxBrightness = parseInt(lines[1]) + root.brightness = current / root.maxBrightness + } + } + } + } + + Component.onCompleted: update() +} |
