aboutsummaryrefslogtreecommitdiffstats
path: root/completions/bash/swaymsg
blob: 20092bdc46b7c96c738f8a1180bd7c4040292a58 (plain) (blame)
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
48
49
50
51
52
53
54
55
56
57
58
59
# swaymsg(1) completion

_swaymsg()
{
  local cur prev
  _get_comp_words_by_ref cur prev

  types=(
    'get_workspaces'
    'get_seats'
    'get_inputs'
    'get_outputs'
    'get_tree'
    'get_marks'
    'get_bar_config'
    'get_version'
    'get_binding_modes'
    'get_config'
    'send_tick'
  )

  short=(
    -h
    -q
    -r
    -s
    -t
    -v
  )

  long=(
    --help
    --quiet
    --raw
    --socket
    --type
    --verbose
  )

  case $prev in
    -s|--socket)
      _filedir
      return
      ;;
    -t|--type)
      COMPREPLY=($(compgen -W "${types[*]}" -- "$cur"))
      return
      ;;
  esac

  if [[ $cur == --* ]]; then
    COMPREPLY=($(compgen -W "${long[*]}" -- "$cur"))
  else
    COMPREPLY=($(compgen -W "${short[*]}" -- "$cur"))
    COMPREPLY+=($(compgen -W "${long[*]}" -- "$cur"))
  fi

} &&
complete -F _swaymsg swaymsg