nova-shell/modules/Backlight.qml
2026-04-10 10:49:48 +02:00

38 lines
873 B
QML

import QtQuick
import Quickshell.Io
import "." as M
Row {
id: root
spacing: 4
visible: percent > 0
property int percent: 0
FileView {
id: current
path: "/sys/class/backlight/intel_backlight/brightness"
watchChanges: true
onFileChanged: reload()
onLoaded: root._update()
}
FileView {
id: max
path: "/sys/class/backlight/intel_backlight/max_brightness"
onLoaded: root._update()
}
function _update() {
const c = parseInt(current.text());
const m = parseInt(max.text());
if (m > 0) root.percent = Math.round((c / m) * 100);
}
Text {
text: root.percent + "% "
color: M.Theme.base05
font.pixelSize: M.Theme.fontSize
font.family: M.Theme.fontFamily
anchors.verticalCenter: parent.verticalCenter
}
}