aboutsummaryrefslogtreecommitdiff
path: root/sway/terminal.sh
diff options
context:
space:
mode:
authorbozo.kopic <bozo@kopic.xyz>2021-10-03 23:21:15 +0200
committerbozo.kopic <bozo@kopic.xyz>2021-10-03 23:21:15 +0200
commitfa5dd5f3c014a250b1748c340255d8b4d0b7d773 (patch)
treeb923aabfdfd4e46fe8c0a42164dc78ceb5435217 /sway/terminal.sh
parent112a38a0d4f3debab29749352c61968bee98e477 (diff)
.
Diffstat (limited to 'sway/terminal.sh')
-rwxr-xr-xsway/terminal.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/sway/terminal.sh b/sway/terminal.sh
new file mode 100755
index 0000000..ec864ab
--- /dev/null
+++ b/sway/terminal.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+DESKTOP=term
+INSTANCE=tmux_term
+
+TERM_WORKSPACE="9:term"
+TERM_APP_ID=tmux_term
+
+FOCUSED_OUTPUT=$(swaymsg -t get_outputs -r |
+ jq '.[] | select(.focused == true) | .name' |
+ tr -d '"')
+FOCUSED_WORKSPACE=$(swaymsg -t get_workspaces -r |
+ jq '.[] | select(.focused == true) | .name' |
+ tr -d '"')
+
+if [ "$FOCUSED_WORKSPACE" = "$TERM_WORKSPACE" ]; then
+ swaymsg workspace back_and_forth
+else
+ swaymsg workspace $TERM_WORKSPACE
+ swaymsg move workspace to $FOCUSED_OUTPUT
+ swaymsg workspace $TERM_WORKSPACE
+
+ if ! (swaymsg -t get_tree -r |
+ jq -e "recurse(.nodes[]) | select(.app_id == \"$TERM_APP_ID\")" > /dev/null); then
+ exec alacritty --class $TERM_APP_ID -e \
+ tmux new-session -A -s default
+ fi
+fi