Mae various style changes, fixed fetching workspace state from system
This commit is contained in:
1 parent
f6cd33e2fb
commit
a33d8d6ac5
3 files changed
+98
-56
No files matched your search
+22
-7
@@ -1,12 +1,27 @@
|
||||
import { execAsync } from "ags/process"
|
||||
import { createPoll } from "ags/time"
|
||||
import { execAsync, createSubprocess } from "ags/process"
|
||||
import GLib from "gi://GLib?version=2.0"
|
||||
|
||||
const HIS = GLib.getenv("HYPRLAND_INSTANCE_SIGNATURE")
|
||||
const sock = `${GLib.getenv("XDG_RUNTIME_DIR")}/hypr/${HIS}/.socket2.sock`
|
||||
|
||||
export default function Workspaces() {
|
||||
// Poll the active workspace ID from Hyprland
|
||||
const activeWs = createPoll(1, 250, (prev) =>
|
||||
execAsync("hyprctl activeworkspace -j")
|
||||
.then((out) => JSON.parse(out).id as number)
|
||||
.catch(() => prev),
|
||||
// Listen to the Hyprland socket for instant workspace updates
|
||||
const activeWs = createSubprocess(
|
||||
1,
|
||||
[
|
||||
"sh",
|
||||
"-c",
|
||||
`hyprctl activeworkspace -j | grep '"id":' | head -1 | awk '{print $2}' | tr -d ','; nc -U ${sock}`,
|
||||
],
|
||||
(out, prev) => {
|
||||
const match = out.match(/(?:^|\n)workspace>>(\d+)/)
|
||||
if (match) return parseInt(match[1])
|
||||
|
||||
const num = parseInt(out)
|
||||
if (!isNaN(num) && num > 0) return num
|
||||
|
||||
return prev
|
||||
},
|
||||
)
|
||||
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user