Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

pi/agent/skills/optional/quickshell/examples/06-ipc-control/shell.qml

Raw
// 06-ipc-control/shell.qml
// IpcHandler: expose show/hide/toggle/text functions callable from outside the shell.
// Run with: qs -p examples/06-ipc-control/shell.qml
// Try:
//   qs -c ... ipc call mybar show
//   qs -c ... ipc call mybar hide
//   qs -c ... ipc call mybar toggle
//   qs -c ... ipc call mybar setText "hello from outside"

import QtQuick
import Quickshell
import Quickshell.Io

Scope {
    id: root
    property string label: "idle"

    IpcHandler {
        target: "mybar"   // IPC namespace for qs ipc call

        function show(): void { bar.visible = true }
        function hide(): void { bar.visible = false }
        function toggle(): void { bar.visible = !bar.visible }
        function setText(s: string): void { root.label = s }
    }

    PanelWindow {
        id: bar
        visible: false
        anchors { top: true; left: true; right: true }
        implicitHeight: 40
        color: "#cc1e1e2e"

        Text {
            anchors.centerIn: parent
            text: root.label
            color: "white"
        }
    }
}