aboutsummaryrefslogtreecommitdiffstats
path: root/completions/bash/swaylock
blob: 33925480e0c22135dd25cee049e43b4b7762a55c (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
60
61
62
63
64
65
66
# swaylock(1) completion

_swaylock()
{
  local cur prev
  _get_comp_words_by_ref -n : cur prev

  short=(
    -h
    -c
    -s
    -t
    -v
    -i
    -u
    -f
  )

  long=(
    --help
    --color
    --scaling
    --tiling
    --version
    --image
    --no-unlock-indicator
    --daemonize
  )

  scaling=(
    'stretch'
    'fill'
    'fit'
    'center'
    'tile'
  )

  case $prev in
    -c|--color)
      return
      ;;
    --scaling)
      COMPREPLY=($(compgen -W "${scaling[*]}" -- "$cur"))
      return
      ;;
    -i|--image)
      if grep -q : <<< "$cur"; then
        output="${cur%%:*}:"
        cur="${cur#*:}"
      else
        output=
      fi
      COMPREPLY=($(compgen -f -- "$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 _swaylock swaylock