summaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-09-24 23:48:47 +1000
committerGitHub <noreply@github.com>2025-09-24 23:48:47 +1000
commit57e3989185b8209a11d79bac477479019d515180 (patch)
tree27e94dcaef9f41bb8f294eab1a91a27ce4da03d0 /services
parentplugin: sub namespace modules (diff)
downloadcaelestia-shell-57e3989185b8209a11d79bac477479019d515180.tar.gz
caelestia-shell-57e3989185b8209a11d79bac477479019d515180.tar.bz2
caelestia-shell-57e3989185b8209a11d79bac477479019d515180.zip
plugin: add hypr extras (#690)
* move machine * works * prevent duplicate refreshes * use instead of hyprctl proc
Diffstat (limited to 'services')
-rw-r--r--services/GameMode.qml15
-rw-r--r--services/Hypr.qml48
2 files changed, 25 insertions, 38 deletions
diff --git a/services/GameMode.qml b/services/GameMode.qml
index 6771d59..edd741c 100644
--- a/services/GameMode.qml
+++ b/services/GameMode.qml
@@ -1,5 +1,6 @@
pragma Singleton
+import qs.services
import qs.config
import Caelestia
import Quickshell
@@ -12,7 +13,7 @@ Singleton {
property alias enabled: props.enabled
function setDynamicConfs(): void {
- Quickshell.execDetached(["hyprctl", "--batch", "keyword animations:enabled 0;keyword decoration:shadow:enabled 0;keyword decoration:blur:enabled 0;keyword general:gaps_in 0;keyword general:gaps_out 0;keyword general:border_size 1;keyword decoration:rounding 0;keyword general:allow_tearing 1"]);
+ Hypr.message("[[BATCH]]keyword animations:enabled 0;keyword decoration:shadow:enabled 0;keyword decoration:blur:enabled 0;keyword general:gaps_in 0;keyword general:gaps_out 0;keyword general:border_size 1;keyword decoration:rounding 0;keyword general:allow_tearing 1");
}
onEnabledChanged: {
@@ -21,7 +22,7 @@ Singleton {
if (Config.utilities.toasts.gameModeChanged)
Toaster.toast(qsTr("Game mode enabled"), qsTr("Disabled Hyprland animations, blur, gaps and shadows"), "gamepad");
} else {
- Quickshell.execDetached(["hyprctl", "reload"]);
+ Hypr.message("reload");
if (Config.utilities.toasts.gameModeChanged)
Toaster.toast(qsTr("Game mode disabled"), qsTr("Hyprland settings restored"), "gamepad");
}
@@ -30,7 +31,7 @@ Singleton {
PersistentProperties {
id: props
- property bool enabled
+ property bool enabled: Hypr.options["animations:enabled"] === 0
reloadableId: "gameMode"
}
@@ -44,14 +45,6 @@ Singleton {
}
}
- Process {
- running: true
- command: ["hyprctl", "getoption", "animations:enabled", "-j"]
- stdout: StdioCollector {
- onStreamFinished: props.enabled = JSON.parse(text).int === 0
- }
- }
-
IpcHandler {
target: "gameMode"
diff --git a/services/Hypr.qml b/services/Hypr.qml
index cd68d72..7a17212 100644
--- a/services/Hypr.qml
+++ b/services/Hypr.qml
@@ -3,6 +3,7 @@ pragma Singleton
import qs.components.misc
import qs.config
import Caelestia
+import Caelestia.Internal
import Quickshell
import Quickshell.Hyprland
import Quickshell.Io
@@ -20,16 +21,24 @@ Singleton {
readonly property HyprlandMonitor focusedMonitor: Hyprland.focusedMonitor
readonly property int activeWsId: focusedWorkspace?.id ?? 1
- property var keyboard
+ readonly property HyprKeyboard keyboard: extras.devices.keyboards.find(kb => kb.main) ?? null
readonly property bool capsLock: keyboard?.capsLock ?? false
readonly property bool numLock: keyboard?.numLock ?? false
readonly property string defaultKbLayout: keyboard?.layout.split(",")[0] ?? "??"
- readonly property string kbLayoutFull: keyboard?.active_keymap ?? "Unknown"
+ readonly property string kbLayoutFull: keyboard?.activeKeymap ?? "Unknown"
readonly property string kbLayout: kbMap.get(kbLayoutFull) ?? "??"
readonly property var kbMap: new Map()
+ readonly property alias extras: extras
+ readonly property alias options: extras.options
+ readonly property alias devices: extras.devices
+
signal configReloaded
+ function message(message: string): void {
+ extras.message(message);
+ }
+
function dispatch(request: string): void {
Hyprland.dispatch(request);
}
@@ -68,9 +77,7 @@ Singleton {
if (n === "configreloaded") {
root.configReloaded();
- setDynamicConfsProc.running = true;
- } else if (n === "activelayout") {
- devicesProc.running = true;
+ extras.message("[[BATCH]]keyword bindln ,Caps_Lock,global,caelestia:refreshDevices;keyword bindln ,Num_Lock,global,caelestia:refreshDevices");
} else if (["workspace", "moveworkspace", "activespecial", "focusedmon"].includes(n)) {
Hyprland.refreshWorkspaces();
Hyprland.refreshMonitors();
@@ -104,35 +111,22 @@ Singleton {
}
}
- Process {
- id: devicesProc
-
- running: true
- command: ["hyprctl", "-j", "devices"]
- stdout: StdioCollector {
- onStreamFinished: root.keyboard = JSON.parse(text).keyboards.find(k => k.main)
- }
- }
-
- Process {
- id: setDynamicConfsProc
-
- running: true
- command: ["hyprctl", "--batch", "keyword bindln ,Caps_Lock,global,caelestia:reloadDevices;keyword bindln ,Num_Lock,global,caelestia:reloadDevices"]
- }
-
IpcHandler {
target: "hypr"
- function reloadDevices(): void {
- devicesProc.running = true;
+ function refreshDevices(): void {
+ extras.refreshDevices();
}
}
CustomShortcut {
- name: "reloadDevices"
+ name: "refreshDevices"
description: "Reload devices"
- onPressed: devicesProc.running = true
- onReleased: devicesProc.running = true
+ onPressed: extras.refreshDevices()
+ onReleased: extras.refreshDevices()
+ }
+
+ HyprExtras {
+ id: extras
}
}