diff --git a/modules/bar/scripts/Idle.sh b/modules/bar/scripts/Idle.sh index f62f726..06ecf05 100755 --- a/modules/bar/scripts/Idle.sh +++ b/modules/bar/scripts/Idle.sh @@ -1,5 +1,14 @@ -if pgrep -x "hypridle" >/dev/null ;then - killall hypridle +if [ "$1" = "--status" ]; then + if pgrep -x "hypridle" >/dev/null; then + echo 1 + else + echo 0 + fi + exit 0 +fi + +if pgrep -x "hypridle" >/dev/null; then + killall hypridle else - hypridle & + hypridle & fi \ No newline at end of file diff --git a/modules/bar/widgets/IdleButton.qml b/modules/bar/widgets/IdleButton.qml index f08554e..a2a7ae2 100644 --- a/modules/bar/widgets/IdleButton.qml +++ b/modules/bar/widgets/IdleButton.qml @@ -11,6 +11,10 @@ MouseArea { hoverEnabled: true cursorShape: Qt.PointingHandCursor + Component.onCompleted: { + idleStatusScript.running = true + } + property int idle: 0 Rectangle { @@ -46,10 +50,23 @@ MouseArea { Text { id: idleText anchors.centerIn: parent - text: idleButton.idle ? "" : "" + text: idleButton.idle ? "" : "" font.pixelSize: 26 font.family: "Nerd Font" - color: idleButton.containsMouse ? Colors.tertiary_fg : Colors.primary + color: idleButton.containsMouse ? Colors.tertiary_fg : idleText.text == "" ? Colors.primary : Colors.tertiary + } + } + + + Process { + id: idleStatusScript + command: ["sh", "-c", Quickshell.env("HOME") + "/.config/quickshell/modules/bar/scripts/Idle.sh" + " --status"] + stdout: StdioCollector { + onStreamFinished: { + this.text.trim() === "0" ? idle = 1 : idle = 0 + console.log("networkScript networkText:", this.text.trim()) + console.log("networkScript") + } } } } \ No newline at end of file