blob: b8df9b4d643dc5cce72a99268ca0fe1113b3ff66 (
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
|
#!/bin/sh
# Yaroslav de la Peña Smirnov 2019-2022
# hacky script to spawn a dropdown-like terminal for quickly typing some
# commands
# reposition the terminal right below the status bar; as a side effect, this
# can be used with any floating window, not just ddterminal by calling the
# script with '-r'
reposition() {
curwiny=$(swaygetcurrentwindow | cut -d ' ' -f1 | cut -d ',' -f2 )
curdisy=$(swaymsg -pt get_outputs | grep -A3 focused | grep Position | cut -d ',' -f2)
moveup=$(($curwiny - $curdisy - 30))
swaymsg move up "$moveup px"
}
if [ "$1" = "-r" ]; then
reposition
exit
fi
ddstatus=$(swaymsg -t get_tree | jq -r '
..
| objects
| select(.type == "workspace") as $ws
| ..
| objects
| select(has("app_id"))
| select(.name == "ddterminal")
| (if .focused == true then "+" else "-" end)')
if [ "$ddstatus" = "-" ]; then
swaymsg '[title="ddterminal"] scratchpad show'
elif [ "$ddstatus" = "+" ]; then
swaymsg '[title="ddterminal"] move scratchpad'
else
$TERMINAL -T "ddterminal" -e zsh -ic "tmuxatt" &
sleep 0.2s
reposition
fi
|