forked from Shinonome/dots-hyprland
brightness osd: show only on focused screen
This commit is contained in:
@@ -12,6 +12,8 @@ import Quickshell.Wayland
|
||||
Scope {
|
||||
id: root
|
||||
property bool showOsdValues: false
|
||||
property var focusedScreen: Quickshell.screens.find(s => s.name === Hyprland.focusedMonitor?.name)
|
||||
property var brightnessMonitor: Brightness.getMonitorForScreen(focusedScreen)
|
||||
|
||||
function triggerOsd() {
|
||||
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 {
|
||||
target: brightnessMonitor
|
||||
target: root.brightnessMonitor
|
||||
enabled: !!root.brightnessMonitor
|
||||
function onBrightnessChanged() {
|
||||
if (!brightnessMonitor.ready) return
|
||||
if (!root.brightnessMonitor.ready) return
|
||||
root.triggerOsd()
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: osdLoader
|
||||
active: showOsdValues
|
||||
|
||||
PanelWindow {
|
||||
screen: modelData
|
||||
id: osdRoot
|
||||
|
||||
Connections {
|
||||
target: osdLoader
|
||||
function onFocusedScreenChanged() {
|
||||
osdRoot.screen = root.focusedScreen
|
||||
}
|
||||
}
|
||||
|
||||
exclusionMode: ExclusionMode.Normal
|
||||
WlrLayershell.namespace: "quickshell:onScreenDisplay"
|
||||
WlrLayershell.layer: WlrLayer.Overlay
|
||||
@@ -100,7 +106,7 @@ Scope {
|
||||
OsdValueIndicator {
|
||||
id: osdValues
|
||||
anchors.centerIn: parent
|
||||
value: brightnessMonitor.brightness
|
||||
value: root.brightnessMonitor.brightness
|
||||
icon: "light_mode"
|
||||
rotateIcon: true
|
||||
name: qsTr("Brightness")
|
||||
@@ -111,8 +117,6 @@ Scope {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
IpcHandler {
|
||||
target: "osdBrightness"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user