Debian Codegraph @

data/colormgr

raw
1 #
2 # bash completion support for colormgr console commands.
3 #
4 # Copyright (C) 2012-2013 Richard Hughes <[email protected]>
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 # 02110-1301 USA
20
21
22 __colormgr_commandlist="
23 create-device
24 create-profile
25 delete-device
26 delete-profile
27 device-add-profile
28 device-get-default-profile
29 device-get-profile-for-qualifier
30 device-inhibit
31 device-make-profile-default
32 device-set-enabled
33 device-set-kind
34 device-set-model
35 device-set-serial
36 device-set-vendor
37 find-device
38 find-device-by-property
39 find-profile
40 find-profile-by-filename
41 get-devices
42 get-devices-by-kind
43 get-profiles
44 get-sensor-reading
45 get-sensors
46 get-standard-space
47 import-profile
48 profile-set-property
49 sensor-lock
50 sensor-set-options
51 "
52
53 __colormgrcomp ()
54 {
55 local all c s=$'\n' IFS=' '$'\t'$'\n'
56 local cur="${COMP_WORDS[COMP_CWORD]}"
57 if [ $# -gt 2 ]; then
58 cur="$3"
59 fi
60 for c in $1; do
61 case "$c$4" in
62 *.) all="$all$c$4$s" ;;
63 *) all="$all$c$4 $s" ;;
64 esac
65 done
66 IFS=$s
67 COMPREPLY=($(compgen -P "$2" -W "$all" -- "$cur"))
68 return
69 }
70
71 _colormgr ()
72 {
73 local i c=1 command
74
75 while [ $c -lt $COMP_CWORD ]; do
76 i="${COMP_WORDS[c]}"
77 case "$i" in
78 --help|--verbose|-v|-h|-?) ;;
79 *) command="$i"; break ;;
80 esac
81 c=$((++c))
82 done
83
84 if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
85 case "${COMP_WORDS[COMP_CWORD]}" in
86 --*=*) COMPREPLY=() ;;
87 --*) __colormgrcomp "
88 --verbose
89 --help
90 "
91 ;;
92 -*) __colormgrcomp "
93 -v
94 -h
95 -?
96 "
97 ;;
98 *) __colormgrcomp "$__colormgr_commandlist" ;;
99 esac
100 return
101 fi
102
103 case "$command" in
104 *) COMPREPLY=() ;;
105 esac
106 }
107
108 complete -o default -o nospace -F _colormgr colormgr