summaryrefslogtreecommitdiff
path: root/.local/bin/dropdowntoggle
blob: d1c1e3b7abbbaf2b440594dfa4d363cd320ad33c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/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.

title_flag="--title"
class_flag="--class"
cmd_flag="--command"

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


case "$active" in
	0) $TERMINAL --class "dropdown" --title "$title" --command "$@" & ;;
	*) kill -9 `xdotool search --name "$class" getwindowpid` ;;
esac