summaryrefslogtreecommitdiff
path: root/bspt
blob: 541d5251d57fbdb5ee5d115a5a2fe3839b01e305 (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
#!/bin/sh

get_cmd () {
  echo "$@" | sed "s/"$1" //"
}

toggle_sp() {
  id="$(xdotool search --class "$1")"
  if [ "$id" != "" ]; then
    bspc node "$id" --flag hidden -f
  fi
}

spawn_sp() {
  st -c "$1" -g 100x40 -e "${@:2}"
}

unset __SP_EXISTS

pgrep -x `get_cmd $@` && __SP_EXISTS=y

if [ -z "$__SP_EXISTS" ]; then
  st -c "$1" -g 100x40 -e "$(get_cmd $@)"
else
  id="$(xdotool search --class $1)"
  if [ "$id" != "" ]; then
    bspc node "$id" --flag hidden -f
  fi
fi