]> rtime.felk.cvut.cz Git - sojka/lightdm.git/commitdiff
Add bash autocompletion for dm-tool
authorRobert Ancell <robert.ancell@canonical.com>
Tue, 27 Jan 2015 03:23:13 +0000 (16:23 +1300)
committerRobert Ancell <robert.ancell@canonical.com>
Tue, 27 Jan 2015 03:23:13 +0000 (16:23 +1300)
data/Makefile.am
data/bash-completion/dm-tool [new file with mode: 0644]

index b5601b940a0c432e5c322912e1cfdd4a65aa4211..63cdc09524315eb65c46ffb27cf5317a1dcab733 100644 (file)
@@ -12,6 +12,9 @@ dist_pam_DATA = pam/lightdm \
                 pam/lightdm-autologin \
                 pam/lightdm-greeter
 
+completionsdir = $(datadir)/bash-completion/completions
+dist_completions_DATA = bash-completion/dm-tool
+
 lightdm-guest-session: $(srcdir)/apparmor/lightdm-guest-session.in
        sed -e 's|@libexecdir[@]|$(libexecdir)|g' $< >$@
 
diff --git a/data/bash-completion/dm-tool b/data/bash-completion/dm-tool
new file mode 100644 (file)
index 0000000..1550395
--- /dev/null
@@ -0,0 +1,51 @@
+#-*- mode: shell-script;-*-
+
+_dm_tool()
+{
+    local cur prev opts
+    _init_completion || return
+    opts='switch-to-greeter switch-to-user switch-to-guest lock list-seats add-nested-seat add-local-x-seat add-seat'
+
+    case "$prev" in
+    switch-to-greeter)
+        return 0
+        ;;
+    switch-to-user)
+        COMPREPLY=($(compgen -u -- "${cur}"))
+        return 0
+        ;;
+    switch-to-guest)
+        # FIXME: session name
+        return 0
+        ;;
+    lock)
+        return 0
+        ;;
+    list-seats)
+        return 0
+        ;;
+    add-nested-seat)
+        # FIXME ...
+        return 0
+        ;;
+    add-local-x-seat)
+        # FIXME ...
+        return 0
+        ;;
+    add-seat)
+        # FIXME ...
+        return 0
+        ;;
+    *)
+        ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+        return 0
+    fi
+
+    COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
+    return 0
+}
+complete -F _dm_tool dm-tool