diff options
Diffstat (limited to 'services')
| -rw-r--r-- | services/Audio.qml | 4 | ||||
| -rw-r--r-- | services/Hypr.qml | 6 | ||||
| -rw-r--r-- | services/Notifs.qml | 2 | ||||
| -rw-r--r-- | services/Players.qml | 2 | ||||
| -rw-r--r-- | services/VPN.qml | 179 |
5 files changed, 7 insertions, 186 deletions
diff --git a/services/Audio.qml b/services/Audio.qml index 14d0a4e..3bbd9c6 100644 --- a/services/Audio.qml +++ b/services/Audio.qml @@ -101,7 +101,7 @@ Singleton { const newSinkName = sink.description || sink.name || qsTr("Unknown Device"); - if (previousSinkName && previousSinkName !== newSinkName && Config.utilities.toasts.audioOutputChanged) + if (previousSinkName && previousSinkName !== newSinkName && Config.toasts.audioOutputChanged) Toaster.toast(qsTr("Audio output changed"), qsTr("Now using: %1").arg(newSinkName), "volume_up"); previousSinkName = newSinkName; @@ -113,7 +113,7 @@ Singleton { const newSourceName = source.description || source.name || qsTr("Unknown Device"); - if (previousSourceName && previousSourceName !== newSourceName && Config.utilities.toasts.audioInputChanged) + if (previousSourceName && previousSourceName !== newSourceName && Config.toasts.audioInputChanged) Toaster.toast(qsTr("Audio input changed"), qsTr("Now using: %1").arg(newSourceName), "mic"); previousSourceName = newSourceName; diff --git a/services/Hypr.qml b/services/Hypr.qml index 77ba264..138b9f2 100644 --- a/services/Hypr.qml +++ b/services/Hypr.qml @@ -59,7 +59,7 @@ Singleton { Component.onCompleted: reloadDynamicConfs() onCapsLockChanged: { - if (!Config.utilities.toasts.capsLockChanged) + if (!Config.toasts.capsLockChanged) return; if (capsLock) @@ -69,7 +69,7 @@ Singleton { } onNumLockChanged: { - if (!Config.utilities.toasts.numLockChanged) + if (!Config.toasts.numLockChanged) return; if (numLock) @@ -79,7 +79,7 @@ Singleton { } onKbLayoutFullChanged: { - if (hadKeyboard && Config.utilities.toasts.kbLayoutChanged) + if (hadKeyboard && Config.toasts.kbLayoutChanged) Toaster.toast(qsTr("Keyboard layout changed"), qsTr("Layout changed to: %1").arg(kbLayoutFull), "keyboard"); hadKeyboard = !!keyboard; diff --git a/services/Notifs.qml b/services/Notifs.qml index aff2dfc..a702968 100644 --- a/services/Notifs.qml +++ b/services/Notifs.qml @@ -21,7 +21,7 @@ Singleton { property bool loaded onDndChanged: { - if (!Config.utilities.toasts.dndChanged) + if (!Config.toasts.dndChanged) return; if (dnd) diff --git a/services/Players.qml b/services/Players.qml index 1191696..742b4d0 100644 --- a/services/Players.qml +++ b/services/Players.qml @@ -24,7 +24,7 @@ Singleton { target: active function onPostTrackChanged() { - if (!Config.utilities.toasts.nowPlaying) { + if (!Config.toasts.nowPlaying) { return; } if (active.trackArtist != "" && active.trackTitle != "") { diff --git a/services/VPN.qml b/services/VPN.qml deleted file mode 100644 index 2d08631..0000000 --- a/services/VPN.qml +++ /dev/null @@ -1,179 +0,0 @@ -pragma Singleton - -import Quickshell -import Quickshell.Io -import QtQuick -import qs.config -import Caelestia - -Singleton { - id: root - - property bool connected: false - - readonly property bool connecting: connectProc.running || disconnectProc.running - readonly property bool enabled: Config.utilities.vpn.provider.some(p => typeof p === "object" ? (p.enabled === true) : false) - readonly property var providerInput: { - const enabledProvider = Config.utilities.vpn.provider.find(p => typeof p === "object" ? (p.enabled === true) : false); - return enabledProvider || "wireguard"; - } - readonly property bool isCustomProvider: typeof providerInput === "object" - readonly property string providerName: isCustomProvider ? (providerInput.name || "custom") : String(providerInput) - readonly property string interfaceName: isCustomProvider ? (providerInput.interface || "") : "" - readonly property var currentConfig: { - const name = providerName; - const iface = interfaceName; - const defaults = getBuiltinDefaults(name, iface); - - if (isCustomProvider) { - const custom = providerInput; - return { - connectCmd: custom.connectCmd || defaults.connectCmd, - disconnectCmd: custom.disconnectCmd || defaults.disconnectCmd, - interface: custom.interface || defaults.interface, - displayName: custom.displayName || defaults.displayName - }; - } - - return defaults; - } - - function getBuiltinDefaults(name, iface) { - const builtins = { - "wireguard": { - connectCmd: ["pkexec", "wg-quick", "up", iface], - disconnectCmd: ["pkexec", "wg-quick", "down", iface], - interface: iface, - displayName: iface - }, - "warp": { - connectCmd: ["warp-cli", "connect"], - disconnectCmd: ["warp-cli", "disconnect"], - interface: "CloudflareWARP", - displayName: "Warp" - }, - "netbird": { - connectCmd: ["netbird", "up"], - disconnectCmd: ["netbird", "down"], - interface: "wt0", - displayName: "NetBird" - }, - "tailscale": { - connectCmd: ["tailscale", "up"], - disconnectCmd: ["tailscale", "down"], - interface: "tailscale0", - displayName: "Tailscale" - } - }; - - return builtins[name] || { - connectCmd: [name, "up"], - disconnectCmd: [name, "down"], - interface: iface || name, - displayName: name - }; - } - - function connect(): void { - if (!connected && !connecting && root.currentConfig && root.currentConfig.connectCmd) { - connectProc.exec(root.currentConfig.connectCmd); - } - } - - function disconnect(): void { - if (connected && !connecting && root.currentConfig && root.currentConfig.disconnectCmd) { - disconnectProc.exec(root.currentConfig.disconnectCmd); - } - } - - function toggle(): void { - if (connected) { - disconnect(); - } else { - connect(); - } - } - - function checkStatus(): void { - if (root.enabled) { - statusProc.running = true; - } - } - - onConnectedChanged: { - if (!Config.utilities.toasts.vpnChanged) - return; - - const displayName = root.currentConfig ? (root.currentConfig.displayName || "VPN") : "VPN"; - if (connected) { - Toaster.toast(qsTr("VPN connected"), qsTr("Connected to %1").arg(displayName), "vpn_key"); - } else { - Toaster.toast(qsTr("VPN disconnected"), qsTr("Disconnected from %1").arg(displayName), "vpn_key_off"); - } - } - - Component.onCompleted: root.enabled && statusCheckTimer.start() - - Process { - id: nmMonitor - - running: root.enabled - command: ["nmcli", "monitor"] - stdout: SplitParser { - onRead: statusCheckTimer.restart() - } - } - - Process { - id: statusProc - - command: ["ip", "link", "show"] - environment: ({ - LANG: "C.UTF-8", - LC_ALL: "C.UTF-8" - }) - stdout: StdioCollector { - onStreamFinished: { - const iface = root.currentConfig ? root.currentConfig.interface : ""; - root.connected = iface && text.includes(iface + ":"); - } - } - } - - Process { - id: connectProc - - onExited: statusCheckTimer.start() - stderr: StdioCollector { - onStreamFinished: { - const error = text.trim(); - if (error && !error.includes("[#]") && !error.includes("already exists")) { - console.warn("VPN connection error:", error); - } else if (error.includes("already exists")) { - root.connected = true; - } - } - } - } - - Process { - id: disconnectProc - - onExited: statusCheckTimer.start() - stderr: StdioCollector { - onStreamFinished: { - const error = text.trim(); - if (error && !error.includes("[#]")) { - console.warn("VPN disconnection error:", error); - } - } - } - } - - Timer { - id: statusCheckTimer - - interval: 500 - onTriggered: root.checkStatus() - } -} |