summaryrefslogtreecommitdiff
path: root/toggles/util.fish
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-01-17 17:54:37 +1100
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-01-17 17:54:37 +1100
commitee9977c26753088dfd20006fe3427737419ab264 (patch)
tree72087d2c1916b7faec165d76f21bcc2b35c8c547 /toggles/util.fish
parentmain: update help (diff)
downloadcaelestia-cli-ee9977c26753088dfd20006fe3427737419ab264.tar.gz
caelestia-cli-ee9977c26753088dfd20006fe3427737419ab264.tar.bz2
caelestia-cli-ee9977c26753088dfd20006fe3427737419ab264.zip
main: special workspace toggles
Diffstat (limited to 'toggles/util.fish')
-rw-r--r--toggles/util.fish21
1 files changed, 21 insertions, 0 deletions
diff --git a/toggles/util.fish b/toggles/util.fish
new file mode 100644
index 0000000..599627c
--- /dev/null
+++ b/toggles/util.fish
@@ -0,0 +1,21 @@
+function move-client -a selector -a workspace
+ if hyprctl -j clients | jq -e 'first(.[] | select('$selector')).workspace.name != "special:'$workspace'"' > /dev/null
+ # Window not in correct workspace
+ set -l window_addr (hyprctl -j clients | jq -r 'first(.[] | select('$selector')).address')
+ hyprctl dispatch movetoworkspacesilent "special:$workspace,address:$window_addr"
+ end
+end
+
+function spawn-client -a selector
+ # Spawn if doesn't exist
+ hyprctl -j clients | jq -e "first(.[] | select($selector))" > /dev/null
+ set -l stat $status
+ if test $stat != 0
+ uwsm app -- $argv[2..] & disown
+ end
+ return $stat
+end
+
+function spawn-or-move -a selector -a workspace
+ spawn-client $selector $argv[3..] || move-client $selector $workspace
+end