summaryrefslogtreecommitdiff
path: root/.local/bin/dropdowntoggle
blob: 11f5521b98f04c5a68a87716f013623909163e3d (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
#!/bin/sh

# Toggle dropdown terminal windows.
# The first argument is the title of the window.
# The rest of it is the program/command to be run
# in the dropdown window.

name="$1"
class="dropdown"
title="dropdown_$name"
active="$(xdotool search --name "$title" | wc -l)"
shift

case "$TERMINAL" in
*st)
	classflag="-c"
	titleflag="-t"
	cmdflag="-e"
	;;
*alacritty)
	classflag="--class"
	titleflag="--title"
	cmdflag="--command"
	;;
 *foot)
	classflag="-a"
	titleflag="-T"
	cmdflag="-e"
esac

case "$active" in
0) $TERMINAL "$classflag" "dropdown" "$titleflag" "$title" "$cmdflag" "$@" & ;;
*) kill -9 "$(xdotool search --name "$class" getwindowpid)" ;;
esac