change workspace startup script to actually place things on the correct workspace
This commit is contained in:
parent
9582c74c3c
commit
9274fc521d
1 changed files with 46 additions and 23 deletions
|
@ -1,39 +1,62 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Set workspace names/number
|
# === CONFIG ===
|
||||||
ws1=1
|
ws1=1
|
||||||
ws2=2
|
ws2=2
|
||||||
ws3=3
|
ws3=3
|
||||||
ws5=5
|
ws5=5
|
||||||
ws6=6
|
ws6=6
|
||||||
|
|
||||||
|
# === FUNCTION ===
|
||||||
|
# move_when_ready <command> <match_type: app_id|title> <match_value> <workspace>
|
||||||
|
move_when_ready() {
|
||||||
|
local cmd="$1"
|
||||||
|
local match_type="$2" # "app_id" or "title"
|
||||||
|
local match_value="$3"
|
||||||
|
local target_ws="$4"
|
||||||
|
local timeout="${5:-30}" # default timeout: 30 seconds
|
||||||
|
|
||||||
#Split the binary and the options so we can optionally run w/ or w/o the option
|
echo "▶ Launching: $cmd (waiting for $match_type=$match_value, timeout ${timeout}s)"
|
||||||
# full path to the toolwait binary itself
|
eval "$cmd" &
|
||||||
TOOLWAITBIN="/home/kellya/.config/sway/scripts/i3-toolwait"
|
|
||||||
# Options to pass
|
|
||||||
TOOLWAITOPTIONS="--nocheck"
|
|
||||||
# binary, with options
|
|
||||||
TOOLWAIT="$TOOLWAITBIN $TOOLWAITOPTIONS"
|
|
||||||
|
|
||||||
|
local waited=0
|
||||||
|
local interval=0.5
|
||||||
|
local max_wait=$(echo "$timeout / $interval" | bc)
|
||||||
|
|
||||||
swaymsg workspace $ws6
|
while true; do
|
||||||
$TOOLWAIT --waitfor org.mozilla.thunderbird /usr/bin/thunderbird
|
if swaymsg -t get_tree | grep -q "\"$match_type\": \"$match_value\""; then
|
||||||
$TOOLWAIT --waitfor logseq /home/kellya/bin/logseq
|
echo "✓ Found $match_type=$match_value — moving to workspace $target_ws"
|
||||||
|
swaymsg "[${match_type}=\"${match_value}\"] move to workspace ${target_ws}" >/dev/null
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
# Start spotify
|
sleep $interval
|
||||||
swaymsg workspace $ws5
|
waited=$((waited+1))
|
||||||
$TOOLWAIT -- /usr/bin/flatpak run --branch=stable --arch=x86_64 --command=spotify --file-forwarding com.spotify.Client
|
|
||||||
|
|
||||||
|
if [ "$waited" -ge "$max_wait" ]; then
|
||||||
|
echo "⏰ Timeout waiting for $match_type=$match_value after ${timeout}s"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
# === APPS ===
|
||||||
|
|
||||||
swaymsg workspace $ws2
|
move_when_ready "/usr/bin/thunderbird" "app_id" "net.thunderbird.Thunderbird" "$ws6"
|
||||||
$TOOLWAITBIN --waitfor slack -- flatpak run com.slack.Slack
|
|
||||||
$TOOLWAIT --waitfor teams-for-linux -- /opt/teams-for-linux/teams-for-linux --optInTeamsV2 true
|
|
||||||
|
|
||||||
swaymsg workspace $ws1
|
move_when_ready "/home/kellya/bin/logseq" "class" "Logseq" "$ws6"
|
||||||
$TOOLWAITBIN --waitfor org.mozilla.firefox firefox
|
|
||||||
|
move_when_ready "flatpak run com.spotify.Client" "instance" "spotify" "$ws5"
|
||||||
|
|
||||||
|
move_when_ready "flatpak run com.slack.Slack" "instance" "slack" "$ws2"
|
||||||
|
|
||||||
|
move_when_ready "/opt/teams-for-linux/teams-for-linux --optInTeamsV2 true" "instance" "teams-for-linux" "$ws2"
|
||||||
|
|
||||||
|
move_when_ready "ghostty" "app_id" "com.mitchellh.ghostty" "$ws3"
|
||||||
|
|
||||||
|
move_when_ready "1password" "instance" "1password" "$ws3"
|
||||||
|
|
||||||
|
move_when_ready "firefox" "app_id" "org.mozilla.firefox" "$ws1"
|
||||||
|
|
||||||
|
swaymsg workspace "$ws1"
|
||||||
|
swaymsg workspace "$ws3"
|
||||||
|
|
||||||
# Switch to the terminal/email workspace by default
|
|
||||||
swaymsg workspace $ws3
|
|
||||||
$TOOLWAIT --waitfor kitty kitty
|
|
||||||
$TOOLWAIT --waitfor 1password 1password
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue