diff options
| -rwxr-xr-x | main.fish | 6 | ||||
| -rwxr-xr-x | toggles/communication.fish | 12 | ||||
| -rwxr-xr-x | toggles/music.fish | 8 | ||||
| -rwxr-xr-x | toggles/specialws.fish | 10 | ||||
| -rwxr-xr-x | toggles/sysmon.fish | 7 | ||||
| -rw-r--r-- | toggles/util.fish | 21 |
6 files changed, 64 insertions, 0 deletions
@@ -18,6 +18,12 @@ if test "$argv[1]" = shell exit end +if test "$argv[1]" = toggle + set -l valid_toggles communication music sysmon specialws + contains "$argv[2]" $valid_toggles && ./toggles/$argv[2].fish || error "Invalid toggle: $argv[2]" + exit +end + if test "$argv[1]" = screenshot ./screenshot.fish $argv[2..] exit diff --git a/toggles/communication.fish b/toggles/communication.fish new file mode 100755 index 0000000..c9ca00b --- /dev/null +++ b/toggles/communication.fish @@ -0,0 +1,12 @@ +#!/bin/fish + +. (dirname (status filename))/util.fish + +spawn-or-move '.class == "vesktop"' communication vesktop --enable-features=WebRTCPipeWireCapturer + +# Has whatsapp firefox profile +if grep -q 'Name=whatsapp' ~/.mozilla/firefox/profiles.ini + spawn-or-move '.class == "whatsapp"' communication firefox --name whatsapp -P whatsapp 'https://web.whatsapp.com' +end + +hyprctl dispatch togglespecialworkspace communication diff --git a/toggles/music.fish b/toggles/music.fish new file mode 100755 index 0000000..95f2c0d --- /dev/null +++ b/toggles/music.fish @@ -0,0 +1,8 @@ +#!/bin/fish + +. (dirname (status filename))/util.fish + +move-client '.class == "feishin"' music +move-client '.class == "Spotify" or .initialTitle == "Spotify" or .initialTitle == "Spotify Free"' music + +hyprctl dispatch togglespecialworkspace music diff --git a/toggles/specialws.fish b/toggles/specialws.fish new file mode 100755 index 0000000..445539d --- /dev/null +++ b/toggles/specialws.fish @@ -0,0 +1,10 @@ +#!/bin/fish + +if ! hyprctl workspaces -j | jq -e 'first(.[] | select(.name == "special:special"))' + set activews (hyprctl activewindow -j | jq -r '.workspace.name') + string match -r -- '^special:' $activews && set togglews (string sub -s 9 $activews) || set togglews special +else + set togglews special +end + +hyprctl dispatch togglespecialworkspace $togglews diff --git a/toggles/sysmon.fish b/toggles/sysmon.fish new file mode 100755 index 0000000..2fd7b6c --- /dev/null +++ b/toggles/sysmon.fish @@ -0,0 +1,7 @@ +#!/bin/fish + +. (dirname (status filename))/util.fish + +spawn-client '.class == "btop" and .title == "btop" and .workspace.name == "special:sysmon"' foot -a 'btop' -T 'btop' btop + +hyprctl dispatch togglespecialworkspace sysmon 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 |