diff --git a/Makefile b/Makefile index 32479c54..d84544ec 100644 --- a/Makefile +++ b/Makefile @@ -54,6 +54,7 @@ install: $(INSTALL_DATA) "./data/icons/asus_notif_green.png" "$(DESTDIR)$(datarootdir)/icons/hicolor/512x512/apps/asus_notif_green.png" $(INSTALL_DATA) "./data/icons/asus_notif_red.png" "$(DESTDIR)$(datarootdir)/icons/hicolor/512x512/apps/asus_notif_red.png" $(INSTALL_DATA) "./data/_asusctl" "$(DESTDIR)$(zshcpl)/_asusctl" + $(INSTALL_DATA) "./data/completions/asusctl.fish" "$(DESTDIR)$(datarootdir)/fish/vendor_completions.d/asusctl.fish" uninstall: rm -f "$(DESTDIR)$(bindir)/$(BIN_C)" @@ -70,6 +71,7 @@ uninstall: rm -r "$(DESTDIR)$(datarootdir)/icons/hicolor/512x512/apps/asus_notif_green.png" rm -r "$(DESTDIR)$(datarootdir)/icons/hicolor/512x512/apps/asus_notif_red.png" rm -f "$(DESTDIR)$(zshcpl)/_asusctl" + rm -f "$(DESTDIR)$(datarootdir)/fish/vendor_completions.d/asusctl.fish" update: cargo update diff --git a/data/completions/asusctl.fish b/data/completions/asusctl.fish new file mode 100644 index 00000000..4b2dac03 --- /dev/null +++ b/data/completions/asusctl.fish @@ -0,0 +1,77 @@ +# Author: AlenPaulVarghese + +set -l progname asusctl + +set -l noopt "not __fish_contains_opt -s -s h -s v -s s -s k -s f -s c help version show-supported kbd-bright fan-mode chg-limit; and not __fish_seen_subcommand_from led-mode profile graphics;" + + +set -l gmod_options '__fish_contains_opt -s m mode;' +set -l fan_options '__fish_contains_opt -s f fan-mode;' +set -l led_options '__fish_seen_subcommand_from led-mode;' +set -l profile_options '__fish_seen_subcommand_from profile;' +set -l keyboard_options '__fish_contains_opt -s k kbd-bright;' +set -l graphics_options '__fish_seen_subcommand_from graphics;' + +set -l fan_modes 'silent normal boost' +set -l brightness_modes 'off low med high' +set -l led_modes 'static breathe strobe rainbow comet' +set -l graphics_modes 'nvidia hybird compute integrated' + + +complete -c $progname -e +complete -c $progname -f + +# asusctl completion +complete -c $progname -s h -f -l help -n "$noopt" -d "print help message" +complete -c $progname -s v -f -l version -n "$noopt" -d "show program version number" +complete -c $progname -s s -f -l show-supported -n "$noopt" -d "show supported functions of this laptop" +complete -c $progname -s k -f -l kbd-bright -n "$noopt" -d "set led brightness" +complete -c $progname -s f -f -l fan-mode -n "$noopt" -d "set fan mode independent of profile" +complete -c $progname -s c -f -l chg-limit -n "$noopt" -d "set charge limit <20-100>" +complete -c $progname -f -a "led-mode" -n "$noopt" -d "Set the keyboard lighting from built-in modes" +complete -c $progname -f -a "profile" -n "$noopt" -d "Create and configure profiles" +complete -c $progname -f -a "graphics" -n "$noopt" -d "Set the graphics mode" + +# brightness completion +complete -c $progname -n "$keyboard_options" -d "available brightness modes" -a "$brightness_modes" + +# fan completion +complete -c $progname -n "$fan_options" -d "available fan modes" -a $fan_modes + +# graphics completion +set -l gopt 'not __fish_contains_opt -s h -s g -s m -s p help mode get pow;' + +complete -c $progname -n "$graphics_options and $gopt" -a "-h" -d "print help message" +complete -c $progname -n "$graphics_options and $gopt" -a "-g" -d "Get the current mode" + +complete -c $progname -s h -f -l help -n "$graphics_options and $gopt" -d "print help message" +complete -c $progname -s m -f -l mode -n "$graphics_options and $gopt" -d "Set graphics mode: " +complete -c $progname -s g -f -l get -n "$graphics_options and $gopt" -d "Get the current mode" +complete -c $progname -s p -f -l pow -n "$graphics_options and $gopt" -d "Get the current power status" + +complete -c $progname -n "$graphics_options and $gmod_options" -d "available graphics modes" -a "$graphics_modes" + +# led-mode completion +complete -c $progname -n "$led_options" -a "-h" -d "print help message" +complete -c $progname -n "$led_options" -a "-n" -d "switch to next aura mode" + +complete -c $progname -s h -f -l help -n "$led_options" -d "print help message" +complete -c $progname -s n -f -l next-mode -n "$led_options" -d "switch to nex aura mode" +complete -c $progname -s p -f -l prev-mode -n "$led_options" -d "switch to previous aura mode" +complete -c $progname -n "$led_options" -d "available led modes" -a "$led_modes" + +# profile completion +set -l popt 'not __fish_contains_opt -s h -s n -s c -s t -s m -s M -s f help next create turbo min-percentage max-percentage fan-preset;' + +complete -c $progname -n "$profile_options and $popt" -a "-h" -d "print help message" +complete -c $progname -n "$profile_options and $popt" -a "-n" -d "toggle to next profile in list" + +complete -c $progname -s h -f -l help -n "$profile_options and $popt" -d "print help message" +complete -c $progname -s n -f -l next -n "$profile_options and $popt" -d "toggle to next profile in list" +complete -c $progname -s c -f -l create -n "$profile_options and $popt" -d "create the profile if it doesn't exist" +complete -c $progname -s t -f -l turbo -n "$profile_options and $popt" -d "enable or disable cpu turbo" +complete -c $progname -s m -f -l min-percentage -n "$profile_options and $popt" -d "set min cpu scaling (intel)" +complete -c $progname -s M -f -l max-percentage -n "$profile_options and $popt" -d "set max cpu scaling (intel)" +complete -c $progname -s f -f -l fan-preset -n "$profile_options and $popt" -d "" +complete -c $progname -n "$profile_option and __fish_contains_opt fan-preset" -d "available fan modes" -a $fan_modes +