brightess and volume control

This commit is contained in:
2026-03-26 13:15:54 -07:00
parent 80efc104ed
commit 5b8d82a934
20 changed files with 588 additions and 37 deletions

68
Services/Brightness.qml Normal file
View File

@@ -0,0 +1,68 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
import Quickshell.Hyprland
Singleton {
id: brightness
property var monitors: []
Process {
id: lsbacklight
running: true
command: ["find", "/sys/class/backlight", "-maxdepth", "1", "-mindepth", "1"]
stdout: StdioCollector {
onStreamFinished: brightness.monitors = this.text.split('\n')
.filter(mon => mon)
.map(mon => brightnessMonitorGen.createObject(brightness, {path: mon}))
}
}
Component {
id: brightnessMonitorGen
BrightnessMonitor {}
}
component BrightnessMonitor: QtObject {
id: monitor
property var path
property var value
property var max
property var get: Process {
running: true
command: ["brightnessctl", "i", "-m"]
stdout: StdioCollector {
onStreamFinished: [,,value,,max] = this.text.split(",")
}
}
property var setInterp: Process {
running: false
command: ["brillo", "-r", "-u", "300000", "-S", value]
}
property var setInstant: Process {
running: false
command: ["brightnessctl", "s", value]
}
function increase() {
value += value * 0.1 + max * 0.01
value = Math.min(max, value)
setInterp.startDetached()
}
function decrease() {
value -= value * 0.1 + max * 0.01
value = Math.max(0, value)
setInterp.startDetached()
}
function set(value) {
this.value = Math.max(Math.min(value, max), 0)
setInstant.startDetached()
}
}
GlobalShortcut {
name: "increase_brightness"
onPressed: monitors[0]?.increase()
}
GlobalShortcut {
name: "decrease_brightness"
onPressed: monitors[0]?.decrease()
}
}