]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/commitdiff
contrib: zsh completion
authorVincent Bernat <vincent@bernat.ch>
Fri, 31 Jan 2020 07:34:51 +0000 (08:34 +0100)
committerPhillip Berndt <phillip.berndt@googlemail.com>
Fri, 31 Jan 2020 07:40:07 +0000 (08:40 +0100)
contrib/zsh_completion/_autorandr [new file with mode: 0644]

diff --git a/contrib/zsh_completion/_autorandr b/contrib/zsh_completion/_autorandr
new file mode 100644 (file)
index 0000000..96e7f7b
--- /dev/null
@@ -0,0 +1,40 @@
+#compdef autorandr
+
+__autorandr_profile () {
+    declare -a virtual
+    virtual=("off":"disable all outputs"
+             "common":"clone at the largest common resolution"
+             "clone-largest":"clone with the largest resolution"
+             "horizontal":"stack all connected outputs horizontally"
+             "vertical":"stack all connected outputs vertically")
+    _describe -t virtual-profiles "virtual profiles" virtual
+    __autorandr_saved_profile
+}
+__autorandr_saved_profile () {
+    declare -a saved
+    saved=(${${(f)${:-$(autorandr)}}/ /:})
+    _describe -t profiles "saved profiles" saved
+}
+
+_autorandr () {
+    local curcontext="$curcontext" state line exclude="-s --save -l --load -r --remove -c --change"
+
+    _arguments -C \
+       "(: -)"{-h,--help}"[get help]" \
+       "($exclude)"{-c,--change}"[automatically load the first detected profile]" \
+       "($exclude)"{-d,--default}"[set default profile]:profile:__autorandr_profile" \
+       "($exclude)"{-l,--load}"[load profile]:profile:__autorandr_profile" \
+       "($exclude)"{-s,--save}"[save current setup to a profile]:profile: " \
+       "($exclude)"{-r,--remove}"[remove profile]:profile:__autorandr_saved_profile" \
+       --batch"[run autorandr for all users]" \
+       --current"[list current active configurations]" \
+       --config"[dump current xrandr setup]" \
+       --debug"[enable verbose output]" \
+       --dry-run"[don't change anything]" \
+       --fingerprint"[fingerprint current hardware]" \
+       --force"[force loading of a profile]" \
+       --skip-options"[skip xrandr options]:xrandr options:_values -s , options gamma brightness panning transform primary mode pos rate" \
+       --version"[show version]"
+}
+
+_autorandr "$@"