brightness osd: show only on focused screen

This commit is contained in:
end-4
2025-05-18 00:20:33 +02:00
parent 4df645a025
commit e0b883cc3e
@@ -12,6 +12,8 @@ import Quickshell.Wayland
Scope { Scope {
id: root id: root
property bool showOsdValues: false property bool showOsdValues: false
property var focusedScreen: Quickshell.screens.find(s => s.name === Hyprland.focusedMonitor?.name)
property var brightnessMonitor: Brightness.getMonitorForScreen(focusedScreen)
function triggerOsd() { function triggerOsd() {
showOsdValues = true showOsdValues = true
@@ -36,25 +38,29 @@ Scope {
} }
} }
Variants {
model: Quickshell.screens
Loader {
id: osdLoader
property var modelData
active: showOsdValues
property var brightnessMonitor: Brightness.getMonitorForScreen(modelData)
Connections { Connections {
target: brightnessMonitor target: root.brightnessMonitor
enabled: !!root.brightnessMonitor
function onBrightnessChanged() { function onBrightnessChanged() {
if (!brightnessMonitor.ready) return if (!root.brightnessMonitor.ready) return
root.triggerOsd() root.triggerOsd()
} }
} }
Loader {
id: osdLoader
active: showOsdValues
PanelWindow { PanelWindow {
screen: modelData id: osdRoot
Connections {
target: osdLoader
function onFocusedScreenChanged() {
osdRoot.screen = root.focusedScreen
}
}
exclusionMode: ExclusionMode.Normal exclusionMode: ExclusionMode.Normal
WlrLayershell.namespace: "quickshell:onScreenDisplay" WlrLayershell.namespace: "quickshell:onScreenDisplay"
WlrLayershell.layer: WlrLayer.Overlay WlrLayershell.layer: WlrLayer.Overlay
@@ -100,7 +106,7 @@ Scope {
OsdValueIndicator { OsdValueIndicator {
id: osdValues id: osdValues
anchors.centerIn: parent anchors.centerIn: parent
value: brightnessMonitor.brightness value: root.brightnessMonitor.brightness
icon: "light_mode" icon: "light_mode"
rotateIcon: true rotateIcon: true
name: qsTr("Brightness") name: qsTr("Brightness")
@@ -111,8 +117,6 @@ Scope {
} }
} }
}
IpcHandler { IpcHandler {
target: "osdBrightness" target: "osdBrightness"