Fixed that Idle indicator updates on multiple screens
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
pragma Singleton
|
||||||
|
import QtQuick
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
property int idle: 0
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
singleton IdleState 1.0 IdleState.qml
|
||||||
@@ -3,6 +3,7 @@ import Quickshell
|
|||||||
import Quickshell.Hyprland
|
import Quickshell.Hyprland
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import "../../../colors"
|
import "../../../colors"
|
||||||
|
import "../states" 1.0 as Global
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: idleButton
|
id: idleButton
|
||||||
@@ -14,8 +15,6 @@ MouseArea {
|
|||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
idleStatusScript.running = true
|
idleStatusScript.running = true
|
||||||
}
|
}
|
||||||
|
|
||||||
property int idle: 0
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@@ -31,7 +30,7 @@ MouseArea {
|
|||||||
id: idleScript
|
id: idleScript
|
||||||
command: ["sh", "-c", Quickshell.env("HOME") + "/.config/quickshell/modules/bar/scripts/Idle.sh"]
|
command: ["sh", "-c", Quickshell.env("HOME") + "/.config/quickshell/modules/bar/scripts/Idle.sh"]
|
||||||
stdout: StdioCollector {
|
stdout: StdioCollector {
|
||||||
onStreamFinished: idleButton.idle ? console.log(`Disabling Idle`) : console.log(`Enabling Idle`)
|
onStreamFinished: Global.IdleState.idle ? console.log(`Disabling Idle`) : console.log(`Enabling Idle`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +41,8 @@ MouseArea {
|
|||||||
onClicked: {
|
onClicked: {
|
||||||
console.log("Running Idle Script")
|
console.log("Running Idle Script")
|
||||||
idleScript.startDetached()
|
idleScript.startDetached()
|
||||||
idleButton.idle = !idleButton.idle
|
Global.IdleState.idle = !Global.IdleState.idle
|
||||||
|
console.log("Current Idle State: " + Global.IdleState.idle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ MouseArea {
|
|||||||
Text {
|
Text {
|
||||||
id: idleText
|
id: idleText
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: idleButton.idle ? "" : ""
|
text: Global.IdleState.idle ? "" : ""
|
||||||
font.pixelSize: 26
|
font.pixelSize: 26
|
||||||
font.family: "Nerd Font"
|
font.family: "Nerd Font"
|
||||||
color: idleButton.containsMouse ? Colors.tertiary_fg : idleText.text == "" ? Colors.primary : Colors.tertiary
|
color: idleButton.containsMouse ? Colors.tertiary_fg : idleText.text == "" ? Colors.primary : Colors.tertiary
|
||||||
@@ -63,9 +63,7 @@ MouseArea {
|
|||||||
command: ["sh", "-c", Quickshell.env("HOME") + "/.config/quickshell/modules/bar/scripts/Idle.sh" + " --status"]
|
command: ["sh", "-c", Quickshell.env("HOME") + "/.config/quickshell/modules/bar/scripts/Idle.sh" + " --status"]
|
||||||
stdout: StdioCollector {
|
stdout: StdioCollector {
|
||||||
onStreamFinished: {
|
onStreamFinished: {
|
||||||
this.text.trim() === "0" ? idle = 1 : idle = 0
|
Global.IdleState.idle = this.text.trim() === "0" ? 1 : 0
|
||||||
console.log("networkScript networkText:", this.text.trim())
|
|
||||||
console.log("networkScript")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Hyprland
|
import Quickshell.Hyprland
|
||||||
|
import Quickshell.Io
|
||||||
import "../../../colors"
|
import "../../../colors"
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
@@ -9,6 +10,10 @@ MouseArea {
|
|||||||
height: 28
|
height: 28
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
archButtonScript.running = true
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@@ -23,4 +28,16 @@ MouseArea {
|
|||||||
color: archButton.containsMouse ? Colors.tertiary_fg : Colors.primary
|
color: archButton.containsMouse ? Colors.tertiary_fg : Colors.primary
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: archButtonScript
|
||||||
|
command: ["sh", "-c", "wofi --show drun"]
|
||||||
|
running: false
|
||||||
|
|
||||||
|
stdout: StdioCollector {
|
||||||
|
onStreamFinished: {
|
||||||
|
console.log("Opening wofi")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user