feat: declare inhibitor process as singleton to synchronize multi display bars
This commit is contained in:
parent
3e1d621e72
commit
d3717cae4b
2 changed files with 21 additions and 12 deletions
17
src/provider/Inhibitor.qml
Normal file
17
src/provider/Inhibitor.qml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
pragma Singleton
|
||||||
|
|
||||||
|
import Quickshell.Io
|
||||||
|
import Quickshell
|
||||||
|
|
||||||
|
Singleton {
|
||||||
|
id: inhibitor
|
||||||
|
property var toggle: () => {
|
||||||
|
active = !active;
|
||||||
|
}
|
||||||
|
property bool active: false
|
||||||
|
|
||||||
|
Process {
|
||||||
|
running: inhibitor.active
|
||||||
|
command: ["systemd-inhibit", "sleep", "infinity"]
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
import "root:base"
|
import "root:base"
|
||||||
|
import "root:provider"
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell.Io
|
|
||||||
import Quickshell.Widgets
|
import Quickshell.Widgets
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
|
||||||
BRectangle {
|
BRectangle {
|
||||||
id: caffeine
|
id: caffeine
|
||||||
property bool inhibiting: false
|
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -14,17 +14,9 @@ BRectangle {
|
||||||
IconImage {
|
IconImage {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: 4
|
anchors.margins: 4
|
||||||
source: caffeine.inhibiting ? "root:assets/eye-open.svg" : "root:assets/eye-closed.svg"
|
source: Inhibitor.active ? "root:assets/eye-open.svg" : "root:assets/eye-closed.svg"
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: () => {
|
onClicked: () => Inhibitor.toggle()
|
||||||
caffeine.inhibiting = !caffeine.inhibiting;
|
|
||||||
}
|
|
||||||
|
|
||||||
Process {
|
|
||||||
id: inhibitor
|
|
||||||
running: caffeine.inhibiting
|
|
||||||
command: ["systemd-inhibit", "sleep", "infinity"]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue