aboutsummaryrefslogtreecommitdiff
path: root/dotfiles/.local/bin/workspace
blob: 972d97d7a8cebadb2cfadb99f3ab17a617d994a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh

# Yaroslav de la Peña Smirnov 2021
# 
# A quick script to quickly open several terminal windows, in a layout that I
# often use, all in the specified directory. The layout looks something like
# this:
# 
# ┌──────────────────┬──────────────────────────────────────────────┐
# │                  │                                              │
# │                  │                                              │
# │        lf        │                                              │
# │                  │                                              │
# │                  │                                              │
# ├──────────────────┤                                              │
# │                  │                    shell                     │
# │                  │                                              │
# │                  │                                              │
# │       shell      │                                              │
# │                  │                                              │
# │                  │                                              │
# │                  │                                              │
# └──────────────────┴──────────────────────────────────────────────┘

if [ -z "$1" ]; then
	echo "Specify working directory"
	exit 1
fi

displayw=$(swaymsg -rt get_outputs |\
	jq --raw-output '.[] | select(.focused == true) | .rect.width')
sidebarw=25

if [ $displayw -lt 2560 ]; then
	swaymsg "gaps inner current set 0; gaps outer current set 0"
	sidebarw=27
fi

cd "$1"
setsid $TERMINAL --class "$TERMINAL lf:$1" -e zsh -ic "lfcd" >/dev/null 2>&1 & sleep 0.1
setsid $TERMINAL --class "$TERMINAL edit:$1" >/dev/null 2>&1 & sleep 0.1

sleep 0.2
swaymsg "[app_id=\"$TERMINAL lf:$1\"] focus; resize set width ${sidebarw}ppt; split v"
setsid $TERMINAL >/dev/null 2>&1 & sleep 0.2
swaymsg "resize set height 60ppt" && sleep 0.1
swaymsg "[app_id=\"$TERMINAL edit:$1\"] focus"