repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

quickshell/nugu/shell.qml

Raw
import QtQuick
import Quickshell
import Quickshell.Io
import "."

Scope {
    id: root

    // New surfaces start hidden so this config can run beside Ironbar/Mako until
    // the parity checklist says it is safe to retire the old companions.
    property bool diagnosticsVisible: false
    property bool barVisible: false
    property bool nativeNotificationsEnabled: false

    // One theme object is shared across all panels so dark/light changes are
    // instant and every widget uses the same Nugu semantic palette.
    Theme { id: nuguTheme }

    // One command boundary keeps process launching out of widgets and makes later
    // Hypr config simplification a search-and-replace instead of archaeology.
    Commands { id: commandBus }

    IpcHandler {
        target: "nugu"

        // Diagnostics IPC gives us a safe visual probe before replacing any live service.
        function showDiagnostics(): void { root.diagnosticsVisible = true }
        function hideDiagnostics(): void { root.diagnosticsVisible = false }
        function toggleDiagnostics(): void { root.diagnosticsVisible = !root.diagnosticsVisible }

        // Bar IPC lets Hypr binds and verification scripts exercise the Quickshell
        // bar while Ironbar remains the user's real production bar.
        function showBar(): void { root.barVisible = true }
        function hideBar(): void { root.barVisible = false }
        function toggleBar(): void { root.barVisible = !root.barVisible }

        function reloadTheme(): void { nuguTheme.reload() }
        function setThemeMode(mode: string): string {
            nuguTheme.setMode(mode)
            return nuguTheme.mode
        }
        function themeMode(): string { return nuguTheme.mode }

        // Native notifications are opt-in while Mako is still live. Tests must stop
        // Mako first, enable this daemon, then rollback by disabling and restarting Mako.
        function enableNativeNotifications(): string {
            root.nativeNotificationsEnabled = true
            return "enabled"
        }
        function disableNativeNotifications(): string {
            root.nativeNotificationsEnabled = false
            return "disabled"
        }
        function nativeNotificationCount(): int {
            return notificationLoader.item ? notificationLoader.item.count : 0
        }
        function dismissNativeNotifications(): void {
            if (notificationLoader.item) notificationLoader.item.dismissAll()
        }
        function restoreNativeNotification(): void {
            if (notificationLoader.item) notificationLoader.item.restoreLast()
        }
    }

    Loader {
        id: notificationLoader
        active: root.nativeNotificationsEnabled
        sourceComponent: Component {
            NotificationDaemon { theme: nuguTheme }
        }
    }

    // Create one bar per monitor, matching Ironbar's multi-output behavior.
    Variants {
        model: Quickshell.screens
        delegate: Component {
            Bar {
                required property var modelData

                screen: modelData
                theme: nuguTheme
                commands: commandBus
                shown: root.barVisible
            }
        }
    }

    Diagnostics {
        visible: root.diagnosticsVisible
        theme: nuguTheme
    }
}