62 lines
1.8 KiB
Bash
Executable file
62 lines
1.8 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# === CONFIG ===
|
|
ws1=1
|
|
ws2=2
|
|
ws3=3
|
|
ws5=5
|
|
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
|
|
|
|
echo "▶ Launching: $cmd (waiting for $match_type=$match_value, timeout ${timeout}s)"
|
|
eval "$cmd" &
|
|
|
|
local waited=0
|
|
local interval=0.5
|
|
local max_wait=$(echo "$timeout / $interval" | bc)
|
|
|
|
while true; do
|
|
if swaymsg -t get_tree | grep -q "\"$match_type\": \"$match_value\""; then
|
|
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
|
|
|
|
sleep $interval
|
|
waited=$((waited+1))
|
|
|
|
if [ "$waited" -ge "$max_wait" ]; then
|
|
echo "⏰ Timeout waiting for $match_type=$match_value after ${timeout}s"
|
|
break
|
|
fi
|
|
done
|
|
}
|
|
# === APPS ===
|
|
|
|
move_when_ready "/usr/bin/thunderbird" "app_id" "net.thunderbird.Thunderbird" "$ws6"
|
|
|
|
move_when_ready "/home/kellya/bin/logseq" "class" "Logseq" "$ws6"
|
|
|
|
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"
|
|
|