From e0b0070fcbb66ed762ecb3bb9d1baf8cce0b7aae Mon Sep 17 00:00:00 2001 From: Lennard Hofmann Date: Mon, 9 Oct 2023 14:16:15 +0200 Subject: [PATCH] hyprctl: add shell completions --- .gitignore | 1 + Makefile | 7 ++ completions/build_completions.sh | 17 +++ completions/generated/hyprctl.bash | 141 +++++++++++++++++++++++ completions/generated/hyprctl.fish | 172 +++++++++++++++++++++++++++++ completions/generated/hyprctl.zsh | 165 +++++++++++++++++++++++++++ completions/hyprctl.usage | 138 +++++++++++++++++++++++ completions/meson.build | 6 + meson.build | 1 + 9 files changed, 648 insertions(+) create mode 100755 completions/build_completions.sh create mode 100644 completions/generated/hyprctl.bash create mode 100644 completions/generated/hyprctl.fish create mode 100644 completions/generated/hyprctl.zsh create mode 100644 completions/hyprctl.usage create mode 100644 completions/meson.build diff --git a/.gitignore b/.gitignore index 96fd6c87..03dbdca2 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ result* *.so hyprctl/hyprctl +completions/generated/*.usage gmon.out *.out diff --git a/Makefile b/Makefile index 07187d73..b03a9e25 100644 --- a/Makefile +++ b/Makefile @@ -55,6 +55,10 @@ install: mkdir -p ${PREFIX}/share/hyprland cp ./assets/wall_* ${PREFIX}/share/hyprland + install -m644 -D ./completions/generated/hyprctl.bash ${PREFIX}/share/bash-completion/completions/hyprctl + install -m644 -D ./completions/generated/hyprctl.fish ${PREFIX}/share/fish/vendor_completions.d/ + install -m644 -D ./completions/generated/hyprctl.zsh ${PREFIX}/share/zsh/site-functions/_hyprctl + mkdir -p ${PREFIX}/share/man/man1 install -m644 ./docs/*.1 ${PREFIX}/share/man/man1 @@ -84,6 +88,9 @@ uninstall: rm -rf ${PREFIX}/share/hyprland rm -f ${PREFIX}/share/man/man1/Hyprland.1 rm -f ${PREFIX}/share/man/man1/hyprctl.1 + rm -f ${PREFIX}/share/bash-completion/completions/hyprctl + rm -f ${PREFIX}/share/fish/vendor_completions.d/hyprctl.fish + rm -f ${PREFIX}/share/zsh/site-functions/_hyprctl fixwlr: sed -E -i -e 's/(soversion = 12)([^032]|$$)/soversion = 12032/g' subprojects/wlroots/meson.build diff --git a/completions/build_completions.sh b/completions/build_completions.sh new file mode 100755 index 00000000..6e918361 --- /dev/null +++ b/completions/build_completions.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +generate_grammar() { + cat hyprctl.usage + echo + printf ' ::= ' + sed -n 's/.*configValues\["\(.*\)"\].*/ | \1/p' ../src/config/ConfigManager.cpp | + sort | uniq | sed 's/\./\\./g' | tail -c +7 + echo ';' +} + +generate_grammar > generated/hyprctl.usage + +cd generated || exit 1 +complgen compile --bash-script hyprctl.bash hyprctl.usage +complgen compile --zsh-script hyprctl.zsh hyprctl.usage +complgen compile --fish-script hyprctl.fish hyprctl.usage diff --git a/completions/generated/hyprctl.bash b/completions/generated/hyprctl.bash new file mode 100644 index 00000000..bcfc0cab --- /dev/null +++ b/completions/generated/hyprctl.bash @@ -0,0 +1,141 @@ +_hyprctl_cmd_0 () { + hyprctl instances -j | sed -n 's/.*"instance": "\(.*\)".*/\1/p' +} + +_hyprctl_cmd_1 () { + printf '%s\n' /usr/share/icons/*/cursors | cut -d/ -f5 +} + +_hyprctl_cmd_2 () { + hyprctl devices -j | awk '/^"keyboards"/,/^\],$/' | sed -n 's/.*"name": "\(.*\)".*/\1/p' +} + +_hyprctl_cmd_3 () { + hyprctl monitors | sed -n 's/^Monitor \(.*\) (ID .*/\1/p' +} + +_hyprctl_spec_1 () { + compgen -A file "$1" +} + +_hyprctl () { + if [[ $(type -t _get_comp_words_by_ref) != function ]]; then + echo _get_comp_words_by_ref: function not defined. Make sure the bash-completions system package is installed + return 1 + fi + + local words cword + _get_comp_words_by_ref -n =:@ words cword + + local -a literals=("misc:enable_swallow" "dwindle:split_width_multiplier" "3" "debug:suppress_errors" "input:touchpad:drag_lock" "decoration:blur:special" "alterzorder" "misc:groupbar_gradients" "misc:swallow_regex" "setprop" "resizeactive" "dwindle:preserve_split" "dwindle:smart_split" "misc:group_insert_after_current" "misc:key_press_enables_dpms" "preload" "next" "centerwindow" "wayland" "fullscreen" "pass" "execr" "misc:focus_on_activate" "input:tablet:output" "gestures:workspace_swipe_create_new" "general:hover_icon_on_border" "debug:log_damage" "general:col.nogroup_border_active" "general:max_fps" "misc:cursor_zoom_factor" "binds:focus_preferred_method" "misc:close_special_on_empty" "debug:watchdog_timeout" "misc:layers_hog_keyboard_focus" "blurls" "resizewindowpixel" "binds" "decoration:dim_inactive" "dwindle:use_active_for_splits" "cursorpos" "input:touchdevice:output" "workspaces" "input:tablet:transform" "misc:always_follow_on_dnd" "misc:vfr" "list" "gestures:workspace_swipe_distance" "devices" "decoration:dim_around" "input:numlock_by_default" "general:allow_tearing" "input:kb_variant" "misc:animate_mouse_windowdragging" "decoration:shadow_ignore_window" "exit" "gestures:workspace_swipe_invert" "misc:mouse_move_focuses_monitor" "general:cursor_inactive_timeout" "top" "decoration:col.shadow_inactive" "unbind" "movewindoworgroup" "exec" "remove" "layerrule" "autogenerated" "xwayland:force_zero_scaling" "plugin" "lockactivegroup" "general:col.inactive_border" "input:touchpad:clickfinger_behavior" "closewindow" "input:touchdevice:transform" "monitor" "animation" "debug:enable_stdout_logs" "general:col.nogroup_border" "misc:no_direct_scanout" "input:repeat_rate" "dwindle:no_gaps_when_only" "togglegroup" "input:scroll_method" "movecursor" "dwindle:permanent_direction_override" "gestures:workspace_swipe_direction_lock_threshold" "input:touchpad:tap-and-drag" "swapactiveworkspaces" "gestures:workspace_swipe" "decoration:col.shadow" "master:mfact" "setcursor" "gestures:workspace_swipe_forever" "input:sensitivity" "input:touchpad:tap-to-click" "misc:swallow_exception_regex" "misc:cursor_zoom_rigid" "activeworkspace" "debug:int" "decoration:active_opacity" "misc:force_hypr_chan" "togglespecialworkspace" "binds:allow_workspace_cycles" "dwindle:smart_resizing" "general:sensitivity" "misc:group_focus_removed_window" "-j" "prev" "pseudo" "load" "decoration:shadow_offset" "decoration:fullscreen_opacity" "togglefloating" "dwindle:pseudotile" "input:touchpad:tap_button_map" "source" "input:tablet:region_size" "decoration:shadow_render_power" "moveactive" "moveworkspacetomonitor" "general:layout" "mfact" "changegroupactive" "0" "decoration:shadow_range" "instances" "general:extend_border_grab_area" "debug:damage_tracking" "misc:render_ahead_of_time" "bezier" "decoration:screen_shader" "input:tablet:region_position" "togglesplit" "globalshortcuts" "decoration:blur:noise" "input:kb_model" "master:allow_small_split" "decoration:blur:enabled" "master:new_is_master" "killactive" "windowrule" "clients" "gestures:workspace_swipe_fingers" "master:no_gaps_when_only" "fakefullscreen" "env" "x11" "general:col.group_border_locked_active" "mouse" "bottom" "notify" "pin" "animations" "gestures:workspace_swipe_direction_lock" "wallpaper" "master:smart_resizing" "general:no_border_on_floating" "input:follow_mouse" "wsbind" "debug:disable_time" "general:no_cursor_warps" "layoutmsg" "1" "master:always_center_master" "cyclenext" "movecursortocorner" "keyword" "general:apply_sens_to_raw" "general:col.group_border_active" "movewindowpixel" "input:accel_profile" "auto" "input:natural_scroll" "activewindow" "swapwindow" "decoration:blur:contrast" "master:inherit_fullscreen" "misc:allow_session_lock_restore" "input:scroll_button_lock" "5" "input:mouse_refocus" "decoration:blur:new_optimizations" "--instance" "decoration:inactive_opacity" "misc:disable_splash_rendering" "forcerendererreload" "master:orientation" "misc:force_default_wallpaper" "xwayland:use_nearest_neighbor" "hyprpaper" "input:touchpad:scroll_factor" "movecurrentworkspacetomonitor" "toggleopaque" "monitors" "input:kb_options" "focuswindow" "renameworkspace" "misc:render_ahead_safezone" "misc:render_titles_in_groupbar" "workspace" "switchxkblayout" "input:force_no_accel" "misc:groupbar_titles_font_size" "create" "general:border_size" "master:new_on_top" "movewindow" "input:scroll_button" "general:col.group_border_locked" "misc:vrr" "decoration:rounding" "misc:groupbar_text_color" "decoration:blur:ignore_opacity" "general:resize_on_border" "dpms" "submap" "general:gaps_out" "output" "workspaceopt" "misc:disable_autoreload" "debug:overlay" "input:touchpad:disable_while_typing" "input:repeat_delay" "dwindle:special_scale_factor" "-i" "moveintogroup" "layers" "focuswindowbyclass" "misc:new_window_takes_over_fullscreen" "unload" "headless" "input:touchpad:middle_button_emulation" "bind" "input:touchpad:natural_scroll" "general:gaps_in" "seterror" "focusmonitor" "input:kb_rules" "misc:background_color" "decoration:blur:brightness" "binds:pass_mouse_when_bound" "splitratio" "binds:ignore_group_lock" "2" "dwindle:default_split_ratio" "misc:mouse_move_enables_dpms" "misc:animate_manual_resizes" "gestures:workspace_swipe_use_r" "misc:disable_hyprland_logo" "decoration:drop_shadow" "debug:manual_crash" "version" "input:left_handed" "exec-once" "dwindle:force_split" "misc:groupbar_scrolling" "misc:hide_cursor_on_touch" "decoration:blur:xray" "gestures:workspace_swipe_min_speed_to_force" "debug:disable_logs" "input:float_switch_override_focus" "-1" "lockgroups" "binds:scroll_event_delay" "decoration:blur:passes" "windowrulev2" "reload" "animations:enabled" "general:col.active_border" "general:no_focus_fallback" "swapnext" "kill" "input:kb_file" "gestures:workspace_swipe_cancel_ratio" "dispatch" "bringactivetotop" "moveoutofgroup" "getoption" "movetoworkspace" "master:drop_at_cursor" "movetoworkspacesilent" "master:special_scale_factor" "binds:workspace_back_and_forth" "4" "decoration:no_blur_on_oversized" "--batch" "debug:damage_blink" "all" "decoration:shadow_scale" "disable" "global" "focusurgentorlast" "splash" "input:kb_layout" "decoration:blur:size" "movefocus" "decoration:dim_strength" "gestures:workspace_swipe_numbered" "general:col.group_border" "focuscurrentorlast" "decoration:dim_special") + + declare -A literal_transitions + literal_transitions[0]="([105]=0 [67]=1 [36]=2 [149]=8 [39]=2 [151]=2 [41]=2 [265]=2 [9]=2 [234]=7 [47]=2 [270]=2 [124]=2 [273]=9 [165]=10 [276]=6 [90]=11 [172]=2 [216]=12 [284]=2 [132]=2 [291]=2 [96]=2 [140]=2 [181]=13 [250]=2 [223]=13 [188]=4 [225]=2 [199]=14 [192]=2)" + literal_transitions[1]="([45]=2 [108]=3 [228]=3)" + literal_transitions[4]="([15]=3 [153]=2 [228]=5)" + literal_transitions[5]="([286]=2)" + literal_transitions[6]="([146]=2 [1]=2 [3]=2 [4]=2 [5]=2 [7]=2 [152]=2 [154]=2 [8]=2 [155]=2 [156]=2 [11]=2 [12]=2 [158]=2 [159]=2 [162]=2 [13]=2 [14]=2 [166]=2 [167]=2 [169]=2 [171]=2 [174]=2 [175]=2 [176]=2 [22]=2 [177]=2 [23]=2 [24]=2 [25]=2 [179]=2 [26]=2 [27]=2 [28]=2 [29]=2 [30]=2 [180]=2 [182]=2 [31]=2 [183]=2 [185]=2 [32]=2 [189]=2 [197]=2 [33]=2 [193]=2 [187]=2 [196]=2 [186]=2 [37]=2 [38]=2 [200]=2 [40]=2 [42]=2 [43]=2 [44]=2 [201]=2 [203]=2 [46]=2 [204]=2 [206]=2 [207]=2 [208]=2 [209]=2 [48]=2 [49]=2 [50]=2 [51]=2 [52]=2 [53]=2 [210]=2 [211]=2 [212]=2 [215]=2 [55]=2 [56]=2 [57]=2 [218]=2 [59]=2 [219]=2 [220]=2 [221]=2 [222]=2 [65]=2 [227]=2 [66]=2 [69]=2 [70]=2 [72]=2 [230]=2 [77]=2 [75]=2 [76]=2 [232]=2 [233]=2 [78]=2 [79]=2 [81]=2 [236]=2 [83]=2 [237]=2 [84]=2 [238]=2 [85]=2 [239]=2 [87]=2 [88]=2 [89]=2 [241]=2 [243]=2 [91]=2 [92]=2 [93]=2 [94]=2 [95]=2 [244]=2 [245]=2 [246]=2 [97]=2 [247]=2 [98]=2 [248]=2 [249]=2 [99]=2 [251]=2 [101]=2 [253]=2 [102]=2 [103]=2 [104]=2 [254]=2 [255]=2 [256]=2 [257]=2 [109]=2 [258]=2 [110]=2 [112]=2 [113]=2 [259]=2 [262]=2 [115]=2 [263]=2 [266]=2 [116]=2 [267]=2 [268]=2 [119]=2 [271]=2 [272]=2 [280]=2 [123]=2 [125]=2 [278]=2 [126]=2 [281]=2 [127]=2 [129]=2 [283]=2 [130]=2 [285]=2 [287]=2 [133]=2 [134]=2 [135]=2 [136]=2 [137]=2 [292]=2 [141]=2 [293]=2 [142]=2 [295]=2 [296]=2 [297]=2 [0]=2 [299]=2)" + literal_transitions[7]="([288]=2)" + literal_transitions[8]="([2]=2 [122]=2 [242]=2 [161]=2 [260]=2 [282]=2 [178]=2)" + literal_transitions[9]="([107]=2 [147]=2 [68]=2 [35]=2 [194]=2 [111]=2 [195]=2 [6]=15 [71]=2 [150]=2 [198]=2 [261]=2 [205]=2 [226]=2 [235]=2 [10]=2 [269]=2 [80]=2 [117]=2 [82]=2 [118]=2 [120]=2 [121]=2 [160]=2 [163]=2 [86]=2 [164]=2 [213]=2 [168]=2 [214]=2 [17]=2 [54]=2 [173]=2 [240]=2 [131]=2 [20]=2 [19]=2 [21]=2 [217]=2 [274]=2 [275]=2 [61]=2 [277]=2 [138]=2 [279]=2 [289]=2 [290]=2 [62]=2 [184]=2 [100]=2 [143]=2 [224]=2 [294]=2 [190]=2 [298]=2 [191]=2)" + literal_transitions[10]="([67]=2 [128]=2 [198]=2 [73]=2 [60]=2 [264]=2 [74]=2 [114]=3 [139]=2 [231]=2 [62]=2 [157]=2 [64]=2 [252]=2 [214]=2 [144]=2 [34]=2)" + literal_transitions[12]="([202]=16 [63]=18)" + literal_transitions[15]="([58]=2 [148]=2)" + literal_transitions[16]="([170]=2 [18]=2 [145]=2 [229]=2)" + literal_transitions[17]="([16]=2 [106]=2)" + + declare -A match_anything_transitions + match_anything_transitions=([3]=2 [13]=0 [11]=2 [5]=2 [14]=17 [18]=2) + declare -A subword_transitions + + local state=0 + local word_index=1 + while [[ $word_index -lt $cword ]]; do + local word=${words[$word_index]} + + if [[ -v "literal_transitions[$state]" ]]; then + local state_transitions_initializer=${literal_transitions[$state]} + declare -A state_transitions + eval "state_transitions=$state_transitions_initializer" + + local word_matched=0 + for literal_id in $(seq 0 $((${#literals[@]} - 1))); do + if [[ ${literals[$literal_id]} = "$word" ]]; then + if [[ -v "state_transitions[$literal_id]" ]]; then + state=${state_transitions[$literal_id]} + word_index=$((word_index + 1)) + word_matched=1 + break + fi + fi + done + if [[ $word_matched -ne 0 ]]; then + continue + fi + fi + + if [[ -v "match_anything_transitions[$state]" ]]; then + state=${match_anything_transitions[$state]} + word_index=$((word_index + 1)) + continue + fi + + return 1 + done + + + local prefix="${words[$cword]}" + + local suffix=${word##*:} + local candidate=${word##*=} + if [[ ${#candidate} -lt ${#suffix} ]]; then + suffix=$candidate + fi + local superfluous_prefix=${word%$suffix} + + if [[ -v "literal_transitions[$state]" ]]; then + local state_transitions_initializer=${literal_transitions[$state]} + declare -A state_transitions + eval "state_transitions=$state_transitions_initializer" + + for literal_id in "${!state_transitions[@]}"; do + local literal="${literals[$literal_id]}" + if [[ $literal = "${prefix}"* ]]; then + local completion=${literal#"$superfluous_prefix"} + COMPREPLY+=("$completion") + fi + done + fi + declare -A commands + commands=([18]=3 [11]=1 [13]=0 [14]=2) + if [[ -v "commands[$state]" ]]; then + local command_id=${commands[$state]} + local completions=() + mapfile -t completions < <(_hyprctl_cmd_${command_id} "$prefix" | cut -f1) + for item in "${completions[@]}"; do + if [[ $item = "${prefix}"* ]]; then + COMPREPLY+=("$item") + fi + done + fi + + + declare -A specialized_commands + specialized_commands=([5]=1 [3]=1) + if [[ -v "specialized_commands[$state]" ]]; then + local command_id=${specialized_commands[$state]} + local completions=() + mapfile -t completions < <(_hyprctl_spec_"${command_id}" "$prefix" | cut -f1) + for item in "${completions[@]}"; do + if [[ $item = "${prefix}"* ]]; then + COMPREPLY+=("$item") + fi + done + fi + + __ltrim_colon_completions "$prefix" + + return 0 +} + +complete -o nospace -F _hyprctl hyprctl diff --git a/completions/generated/hyprctl.fish b/completions/generated/hyprctl.fish new file mode 100644 index 00000000..c27ce03c --- /dev/null +++ b/completions/generated/hyprctl.fish @@ -0,0 +1,172 @@ +function _hyprctl_1 + set 1 $argv[1] + hyprctl instances -j | sed -n 's/.*"instance": "\(.*\)".*/\1/p' +end + +function _hyprctl_2 + set 1 $argv[1] + printf '%s\n' /usr/share/icons/*/cursors | cut -d/ -f5 +end + +function _hyprctl_3 + set 1 $argv[1] + hyprctl devices -j | awk '/^"keyboards"/,/^\],$/' | sed -n 's/.*"name": "\(.*\)".*/\1/p' +end + +function _hyprctl_4 + set 1 $argv[1] + hyprctl monitors | sed -n 's/^Monitor \(.*\) (ID .*/\1/p' +end + +function _hyprctl_spec_2 +set 1 $argv[1] +__fish_complete_path "$1" +end + +function _hyprctl + set COMP_LINE (commandline --cut-at-cursor) + + set COMP_WORDS + echo $COMP_LINE | read --tokenize --array COMP_WORDS + if string match --quiet --regex '.*\s$' $COMP_LINE + set COMP_CWORD (math (count $COMP_WORDS) + 1) + else + set COMP_CWORD (count $COMP_WORDS) + end + + set --local literals "misc:enable_swallow" "dwindle:split_width_multiplier" "3" "debug:suppress_errors" "input:touchpad:drag_lock" "decoration:blur:special" "alterzorder" "misc:groupbar_gradients" "misc:swallow_regex" "setprop" "resizeactive" "dwindle:preserve_split" "dwindle:smart_split" "misc:group_insert_after_current" "misc:key_press_enables_dpms" "preload" "next" "centerwindow" "wayland" "fullscreen" "pass" "execr" "misc:focus_on_activate" "input:tablet:output" "gestures:workspace_swipe_create_new" "general:hover_icon_on_border" "debug:log_damage" "general:col.nogroup_border_active" "general:max_fps" "misc:cursor_zoom_factor" "binds:focus_preferred_method" "misc:close_special_on_empty" "debug:watchdog_timeout" "misc:layers_hog_keyboard_focus" "blurls" "resizewindowpixel" "binds" "decoration:dim_inactive" "dwindle:use_active_for_splits" "cursorpos" "input:touchdevice:output" "workspaces" "input:tablet:transform" "misc:always_follow_on_dnd" "misc:vfr" "list" "gestures:workspace_swipe_distance" "devices" "decoration:dim_around" "input:numlock_by_default" "general:allow_tearing" "input:kb_variant" "misc:animate_mouse_windowdragging" "decoration:shadow_ignore_window" "exit" "gestures:workspace_swipe_invert" "misc:mouse_move_focuses_monitor" "general:cursor_inactive_timeout" "top" "decoration:col.shadow_inactive" "unbind" "movewindoworgroup" "exec" "remove" "layerrule" "autogenerated" "xwayland:force_zero_scaling" "plugin" "lockactivegroup" "general:col.inactive_border" "input:touchpad:clickfinger_behavior" "closewindow" "input:touchdevice:transform" "monitor" "animation" "debug:enable_stdout_logs" "general:col.nogroup_border" "misc:no_direct_scanout" "input:repeat_rate" "dwindle:no_gaps_when_only" "togglegroup" "input:scroll_method" "movecursor" "dwindle:permanent_direction_override" "gestures:workspace_swipe_direction_lock_threshold" "input:touchpad:tap-and-drag" "swapactiveworkspaces" "gestures:workspace_swipe" "decoration:col.shadow" "master:mfact" "setcursor" "gestures:workspace_swipe_forever" "input:sensitivity" "input:touchpad:tap-to-click" "misc:swallow_exception_regex" "misc:cursor_zoom_rigid" "activeworkspace" "debug:int" "decoration:active_opacity" "misc:force_hypr_chan" "togglespecialworkspace" "binds:allow_workspace_cycles" "dwindle:smart_resizing" "general:sensitivity" "misc:group_focus_removed_window" "-j" "prev" "pseudo" "load" "decoration:shadow_offset" "decoration:fullscreen_opacity" "togglefloating" "dwindle:pseudotile" "input:touchpad:tap_button_map" "source" "input:tablet:region_size" "decoration:shadow_render_power" "moveactive" "moveworkspacetomonitor" "general:layout" "mfact" "changegroupactive" "0" "decoration:shadow_range" "instances" "general:extend_border_grab_area" "debug:damage_tracking" "misc:render_ahead_of_time" "bezier" "decoration:screen_shader" "input:tablet:region_position" "togglesplit" "globalshortcuts" "decoration:blur:noise" "input:kb_model" "master:allow_small_split" "decoration:blur:enabled" "master:new_is_master" "killactive" "windowrule" "clients" "gestures:workspace_swipe_fingers" "master:no_gaps_when_only" "fakefullscreen" "env" "x11" "general:col.group_border_locked_active" "mouse" "bottom" "notify" "pin" "animations" "gestures:workspace_swipe_direction_lock" "wallpaper" "master:smart_resizing" "general:no_border_on_floating" "input:follow_mouse" "wsbind" "debug:disable_time" "general:no_cursor_warps" "layoutmsg" "1" "master:always_center_master" "cyclenext" "movecursortocorner" "keyword" "general:apply_sens_to_raw" "general:col.group_border_active" "movewindowpixel" "input:accel_profile" "auto" "input:natural_scroll" "activewindow" "swapwindow" "decoration:blur:contrast" "master:inherit_fullscreen" "misc:allow_session_lock_restore" "input:scroll_button_lock" "5" "input:mouse_refocus" "decoration:blur:new_optimizations" "--instance" "decoration:inactive_opacity" "misc:disable_splash_rendering" "forcerendererreload" "master:orientation" "misc:force_default_wallpaper" "xwayland:use_nearest_neighbor" "hyprpaper" "input:touchpad:scroll_factor" "movecurrentworkspacetomonitor" "toggleopaque" "monitors" "input:kb_options" "focuswindow" "renameworkspace" "misc:render_ahead_safezone" "misc:render_titles_in_groupbar" "workspace" "switchxkblayout" "input:force_no_accel" "misc:groupbar_titles_font_size" "create" "general:border_size" "master:new_on_top" "movewindow" "input:scroll_button" "general:col.group_border_locked" "misc:vrr" "decoration:rounding" "misc:groupbar_text_color" "decoration:blur:ignore_opacity" "general:resize_on_border" "dpms" "submap" "general:gaps_out" "output" "workspaceopt" "misc:disable_autoreload" "debug:overlay" "input:touchpad:disable_while_typing" "input:repeat_delay" "dwindle:special_scale_factor" "-i" "moveintogroup" "layers" "focuswindowbyclass" "misc:new_window_takes_over_fullscreen" "unload" "headless" "input:touchpad:middle_button_emulation" "bind" "input:touchpad:natural_scroll" "general:gaps_in" "seterror" "focusmonitor" "input:kb_rules" "misc:background_color" "decoration:blur:brightness" "binds:pass_mouse_when_bound" "splitratio" "binds:ignore_group_lock" "2" "dwindle:default_split_ratio" "misc:mouse_move_enables_dpms" "misc:animate_manual_resizes" "gestures:workspace_swipe_use_r" "misc:disable_hyprland_logo" "decoration:drop_shadow" "debug:manual_crash" "version" "input:left_handed" "exec-once" "dwindle:force_split" "misc:groupbar_scrolling" "misc:hide_cursor_on_touch" "decoration:blur:xray" "gestures:workspace_swipe_min_speed_to_force" "debug:disable_logs" "input:float_switch_override_focus" "-1" "lockgroups" "binds:scroll_event_delay" "decoration:blur:passes" "windowrulev2" "reload" "animations:enabled" "general:col.active_border" "general:no_focus_fallback" "swapnext" "kill" "input:kb_file" "gestures:workspace_swipe_cancel_ratio" "dispatch" "bringactivetotop" "moveoutofgroup" "getoption" "movetoworkspace" "master:drop_at_cursor" "movetoworkspacesilent" "master:special_scale_factor" "binds:workspace_back_and_forth" "4" "decoration:no_blur_on_oversized" "--batch" "debug:damage_blink" "all" "decoration:shadow_scale" "disable" "global" "focusurgentorlast" "splash" "input:kb_layout" "decoration:blur:size" "movefocus" "decoration:dim_strength" "gestures:workspace_swipe_numbered" "general:col.group_border" "focuscurrentorlast" "decoration:dim_special" + + set --local descriptions + set descriptions[3] "error" + set descriptions[10] "set windowrule properties" + set descriptions[37] "list all keybindings" + set descriptions[40] "print cursor position" + set descriptions[42] "list all workspaces with their properties" + set descriptions[48] "list all connected input devices" + set descriptions[91] "set cursor theme" + set descriptions[97] "show info about active workspace" + set descriptions[106] "JSON output" + set descriptions[123] "warning" + set descriptions[125] "list running Hyprland instances" + set descriptions[133] "list all global shortcuts" + set descriptions[141] "list all windows with their properties" + set descriptions[150] "send notification" + set descriptions[152] "list animations and beziers" + set descriptions[162] "info" + set descriptions[166] "execute a keyword" + set descriptions[173] "print active window name" + set descriptions[179] "ok" + set descriptions[182] "use specified Hyprland instance" + set descriptions[193] "list all outputs with their properties" + set descriptions[200] "switch keyboard layout" + set descriptions[217] "creates/destroys a fake output" + set descriptions[224] "use specified Hyprland instance" + set descriptions[226] "list all layers" + set descriptions[235] "show text in error bar" + set descriptions[243] "hint" + set descriptions[251] "print Hyprland version" + set descriptions[261] "no icon" + set descriptions[266] "reload config file" + set descriptions[271] "kill an app by clicking on it" + set descriptions[274] "run a dispatcher" + set descriptions[277] "print value of config option" + set descriptions[283] "confused" + set descriptions[285] "execute multiple commands, separated by ';'" + set descriptions[292] "print current random splash" + + set --local literal_transitions + set literal_transitions[1] "set inputs 106 68 37 150 40 152 42 266 10 235 48 271 125 274 166 277 91 173 217 285 133 292 97 141 182 251 224 189 226 200 193; set tos 1 2 3 9 3 3 3 3 3 8 3 3 3 10 11 7 12 3 13 3 3 3 3 3 14 3 14 5 3 15 3" + set literal_transitions[2] "set inputs 46 109 229; set tos 3 4 4" + set literal_transitions[5] "set inputs 16 154 229; set tos 4 3 6" + set literal_transitions[6] "set inputs 287; set tos 3" + set literal_transitions[7] "set inputs 147 2 4 5 6 8 153 155 9 156 157 12 13 159 160 163 14 15 167 168 170 172 175 176 177 23 178 24 25 26 180 27 28 29 30 31 181 183 32 184 186 33 190 198 34 194 188 197 187 38 39 201 41 43 44 45 202 204 47 205 207 208 209 210 49 50 51 52 53 54 211 212 213 216 56 57 58 219 60 220 221 222 223 66 228 67 70 71 73 231 78 76 77 233 234 79 80 82 237 84 238 85 239 86 240 88 89 90 242 244 92 93 94 95 96 245 246 247 98 248 99 249 250 100 252 102 254 103 104 105 255 256 257 258 110 259 111 113 114 260 263 116 264 267 117 268 269 120 272 273 281 124 126 279 127 282 128 130 284 131 286 288 134 135 136 137 138 293 142 294 143 296 297 298 1 300; set tos 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3" + set literal_transitions[8] "set inputs 289; set tos 3" + set literal_transitions[9] "set inputs 3 123 243 162 261 283 179; set tos 3 3 3 3 3 3 3" + set literal_transitions[10] "set inputs 108 148 69 36 195 112 196 7 72 151 199 262 206 227 236 11 270 81 118 83 119 121 122 161 164 87 165 214 169 215 18 55 174 241 132 21 20 22 218 275 276 62 278 139 280 290 291 63 185 101 144 225 295 191 299 192; set tos 3 3 3 3 3 3 3 16 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3" + set literal_transitions[11] "set inputs 68 129 199 74 61 265 75 115 140 232 63 158 65 253 215 145 35; set tos 3 3 3 3 3 3 3 4 3 3 3 3 3 3 3 3 3" + set literal_transitions[13] "set inputs 203 64; set tos 17 19" + set literal_transitions[16] "set inputs 59 149; set tos 3 3" + set literal_transitions[17] "set inputs 171 19 146 230; set tos 3 3 3 3" + set literal_transitions[18] "set inputs 17 107; set tos 3 3" + + set --local match_anything_transitions_from 4 14 12 6 15 19 + set --local match_anything_transitions_to 3 1 3 3 18 3 + + set --local state 1 + set --local word_index 2 + while test $word_index -lt $COMP_CWORD + set --local -- word $COMP_WORDS[$word_index] + + if set --query literal_transitions[$state] && test -n $literal_transitions[$state] + set --local --erase inputs + set --local --erase tos + eval $literal_transitions[$state] + + if contains -- $word $literals + set --local literal_matched 0 + for literal_id in (seq 1 (count $literals)) + if test $literals[$literal_id] = $word + set --local index (contains --index -- $literal_id $inputs) + set state $tos[$index] + set word_index (math $word_index + 1) + set literal_matched 1 + break + end + end + if test $literal_matched -ne 0 + continue + end + end + end + + if set --query match_anything_transitions_from[$state] && test -n $match_anything_transitions_from[$state] + set --local index (contains --index -- $state $match_anything_transitions_from) + set state $match_anything_transitions_to[$index] + set word_index (math $word_index + 1) + continue + end + + return 1 + end + + if set --query literal_transitions[$state] && test -n $literal_transitions[$state] + set --local --erase inputs + set --local --erase tos + eval $literal_transitions[$state] + for literal_id in $inputs + if test -n $descriptions[$literal_id] + printf '%s\t%s\n' $literals[$literal_id] $descriptions[$literal_id] + else + printf '%s\n' $literals[$literal_id] + end + end + end + + set command_states 19 12 14 15 + set command_ids 4 2 1 3 + if contains $state $command_states + set --local index (contains --index $state $command_states) + set --local function_id $command_ids[$index] + set --local function_name _hyprctl_$function_id + set --local --erase inputs + set --local --erase tos + $function_name "$COMP_WORDS[$COMP_CWORD]" + end + set specialized_command_states 6 4 + set specialized_command_ids 2 2 + if contains $state $specialized_command_states + set --local index (contains --index $state $specialized_command_states) + set --local function_id $specialized_command_ids[$index] + set --local function_name _hyprctl_spec_$function_id + set --local --erase inputs + set --local --erase tos + set --local lines (eval $function_name $COMP_WORDS[$COMP_CWORD]) + for line in $lines + printf '%s\n' $line + end + end + + return 0 +end + +complete --command hyprctl --no-files --arguments "(_hyprctl)" diff --git a/completions/generated/hyprctl.zsh b/completions/generated/hyprctl.zsh new file mode 100644 index 00000000..7a6fb0e3 --- /dev/null +++ b/completions/generated/hyprctl.zsh @@ -0,0 +1,165 @@ +_hyprctl_cmd_0 () { + hyprctl instances -j | sed -n 's/.*"instance": "\(.*\)".*/\1/p' +} + +_hyprctl_cmd_1 () { + printf '%s\n' /usr/share/icons/*/cursors | cut -d/ -f5 +} + +_hyprctl_cmd_2 () { + hyprctl devices -j | awk '/^"keyboards"/,/^\],$/' | sed -n 's/.*"name": "\(.*\)".*/\1/p' +} + +_hyprctl_cmd_3 () { + hyprctl monitors | sed -n 's/^Monitor \(.*\) (ID .*/\1/p' +} + +_hyprctl_spec_1 () { + _path_files +} + +_hyprctl () { + local -a literals=("misc:enable_swallow" "dwindle:split_width_multiplier" "3" "debug:suppress_errors" "input:touchpad:drag_lock" "decoration:blur:special" "alterzorder" "misc:groupbar_gradients" "misc:swallow_regex" "setprop" "resizeactive" "dwindle:preserve_split" "dwindle:smart_split" "misc:group_insert_after_current" "misc:key_press_enables_dpms" "preload" "next" "centerwindow" "wayland" "fullscreen" "pass" "execr" "misc:focus_on_activate" "input:tablet:output" "gestures:workspace_swipe_create_new" "general:hover_icon_on_border" "debug:log_damage" "general:col.nogroup_border_active" "general:max_fps" "misc:cursor_zoom_factor" "binds:focus_preferred_method" "misc:close_special_on_empty" "debug:watchdog_timeout" "misc:layers_hog_keyboard_focus" "blurls" "resizewindowpixel" "binds" "decoration:dim_inactive" "dwindle:use_active_for_splits" "cursorpos" "input:touchdevice:output" "workspaces" "input:tablet:transform" "misc:always_follow_on_dnd" "misc:vfr" "list" "gestures:workspace_swipe_distance" "devices" "decoration:dim_around" "input:numlock_by_default" "general:allow_tearing" "input:kb_variant" "misc:animate_mouse_windowdragging" "decoration:shadow_ignore_window" "exit" "gestures:workspace_swipe_invert" "misc:mouse_move_focuses_monitor" "general:cursor_inactive_timeout" "top" "decoration:col.shadow_inactive" "unbind" "movewindoworgroup" "exec" "remove" "layerrule" "autogenerated" "xwayland:force_zero_scaling" "plugin" "lockactivegroup" "general:col.inactive_border" "input:touchpad:clickfinger_behavior" "closewindow" "input:touchdevice:transform" "monitor" "animation" "debug:enable_stdout_logs" "general:col.nogroup_border" "misc:no_direct_scanout" "input:repeat_rate" "dwindle:no_gaps_when_only" "togglegroup" "input:scroll_method" "movecursor" "dwindle:permanent_direction_override" "gestures:workspace_swipe_direction_lock_threshold" "input:touchpad:tap-and-drag" "swapactiveworkspaces" "gestures:workspace_swipe" "decoration:col.shadow" "master:mfact" "setcursor" "gestures:workspace_swipe_forever" "input:sensitivity" "input:touchpad:tap-to-click" "misc:swallow_exception_regex" "misc:cursor_zoom_rigid" "activeworkspace" "debug:int" "decoration:active_opacity" "misc:force_hypr_chan" "togglespecialworkspace" "binds:allow_workspace_cycles" "dwindle:smart_resizing" "general:sensitivity" "misc:group_focus_removed_window" "-j" "prev" "pseudo" "load" "decoration:shadow_offset" "decoration:fullscreen_opacity" "togglefloating" "dwindle:pseudotile" "input:touchpad:tap_button_map" "source" "input:tablet:region_size" "decoration:shadow_render_power" "moveactive" "moveworkspacetomonitor" "general:layout" "mfact" "changegroupactive" "0" "decoration:shadow_range" "instances" "general:extend_border_grab_area" "debug:damage_tracking" "misc:render_ahead_of_time" "bezier" "decoration:screen_shader" "input:tablet:region_position" "togglesplit" "globalshortcuts" "decoration:blur:noise" "input:kb_model" "master:allow_small_split" "decoration:blur:enabled" "master:new_is_master" "killactive" "windowrule" "clients" "gestures:workspace_swipe_fingers" "master:no_gaps_when_only" "fakefullscreen" "env" "x11" "general:col.group_border_locked_active" "mouse" "bottom" "notify" "pin" "animations" "gestures:workspace_swipe_direction_lock" "wallpaper" "master:smart_resizing" "general:no_border_on_floating" "input:follow_mouse" "wsbind" "debug:disable_time" "general:no_cursor_warps" "layoutmsg" "1" "master:always_center_master" "cyclenext" "movecursortocorner" "keyword" "general:apply_sens_to_raw" "general:col.group_border_active" "movewindowpixel" "input:accel_profile" "auto" "input:natural_scroll" "activewindow" "swapwindow" "decoration:blur:contrast" "master:inherit_fullscreen" "misc:allow_session_lock_restore" "input:scroll_button_lock" "5" "input:mouse_refocus" "decoration:blur:new_optimizations" "--instance" "decoration:inactive_opacity" "misc:disable_splash_rendering" "forcerendererreload" "master:orientation" "misc:force_default_wallpaper" "xwayland:use_nearest_neighbor" "hyprpaper" "input:touchpad:scroll_factor" "movecurrentworkspacetomonitor" "toggleopaque" "monitors" "input:kb_options" "focuswindow" "renameworkspace" "misc:render_ahead_safezone" "misc:render_titles_in_groupbar" "workspace" "switchxkblayout" "input:force_no_accel" "misc:groupbar_titles_font_size" "create" "general:border_size" "master:new_on_top" "movewindow" "input:scroll_button" "general:col.group_border_locked" "misc:vrr" "decoration:rounding" "misc:groupbar_text_color" "decoration:blur:ignore_opacity" "general:resize_on_border" "dpms" "submap" "general:gaps_out" "output" "workspaceopt" "misc:disable_autoreload" "debug:overlay" "input:touchpad:disable_while_typing" "input:repeat_delay" "dwindle:special_scale_factor" "-i" "moveintogroup" "layers" "focuswindowbyclass" "misc:new_window_takes_over_fullscreen" "unload" "headless" "input:touchpad:middle_button_emulation" "bind" "input:touchpad:natural_scroll" "general:gaps_in" "seterror" "focusmonitor" "input:kb_rules" "misc:background_color" "decoration:blur:brightness" "binds:pass_mouse_when_bound" "splitratio" "binds:ignore_group_lock" "2" "dwindle:default_split_ratio" "misc:mouse_move_enables_dpms" "misc:animate_manual_resizes" "gestures:workspace_swipe_use_r" "misc:disable_hyprland_logo" "decoration:drop_shadow" "debug:manual_crash" "version" "input:left_handed" "exec-once" "dwindle:force_split" "misc:groupbar_scrolling" "misc:hide_cursor_on_touch" "decoration:blur:xray" "gestures:workspace_swipe_min_speed_to_force" "debug:disable_logs" "input:float_switch_override_focus" "-1" "lockgroups" "binds:scroll_event_delay" "decoration:blur:passes" "windowrulev2" "reload" "animations:enabled" "general:col.active_border" "general:no_focus_fallback" "swapnext" "kill" "input:kb_file" "gestures:workspace_swipe_cancel_ratio" "dispatch" "bringactivetotop" "moveoutofgroup" "getoption" "movetoworkspace" "master:drop_at_cursor" "movetoworkspacesilent" "master:special_scale_factor" "binds:workspace_back_and_forth" "4" "decoration:no_blur_on_oversized" "--batch" "debug:damage_blink" "all" "decoration:shadow_scale" "disable" "global" "focusurgentorlast" "splash" "input:kb_layout" "decoration:blur:size" "movefocus" "decoration:dim_strength" "gestures:workspace_swipe_numbered" "general:col.group_border" "focuscurrentorlast" "decoration:dim_special") + + local -A descriptions + descriptions[3]="error" + descriptions[10]="set windowrule properties" + descriptions[37]="list all keybindings" + descriptions[40]="print cursor position" + descriptions[42]="list all workspaces with their properties" + descriptions[48]="list all connected input devices" + descriptions[91]="set cursor theme" + descriptions[97]="show info about active workspace" + descriptions[106]="JSON output" + descriptions[123]="warning" + descriptions[125]="list running Hyprland instances" + descriptions[133]="list all global shortcuts" + descriptions[141]="list all windows with their properties" + descriptions[150]="send notification" + descriptions[152]="list animations and beziers" + descriptions[162]="info" + descriptions[166]="execute a keyword" + descriptions[173]="print active window name" + descriptions[179]="ok" + descriptions[182]="use specified Hyprland instance" + descriptions[193]="list all outputs with their properties" + descriptions[200]="switch keyboard layout" + descriptions[217]="creates/destroys a fake output" + descriptions[224]="use specified Hyprland instance" + descriptions[226]="list all layers" + descriptions[235]="show text in error bar" + descriptions[243]="hint" + descriptions[251]="print Hyprland version" + descriptions[261]="no icon" + descriptions[266]="reload config file" + descriptions[271]="kill an app by clicking on it" + descriptions[274]="run a dispatcher" + descriptions[277]="print value of config option" + descriptions[283]="confused" + descriptions[285]="execute multiple commands, separated by ';'" + descriptions[292]="print current random splash" + + local -A literal_transitions + literal_transitions[1]="([106]=1 [68]=2 [37]=3 [150]=9 [40]=3 [152]=3 [42]=3 [266]=3 [10]=3 [235]=8 [48]=3 [271]=3 [125]=3 [274]=10 [166]=11 [277]=7 [91]=12 [173]=3 [217]=13 [285]=3 [133]=3 [292]=3 [97]=3 [141]=3 [182]=14 [251]=3 [224]=14 [189]=5 [226]=3 [200]=15 [193]=3)" + literal_transitions[2]="([46]=3 [109]=4 [229]=4)" + literal_transitions[5]="([16]=4 [154]=3 [229]=6)" + literal_transitions[6]="([287]=3)" + literal_transitions[7]="([147]=3 [2]=3 [4]=3 [5]=3 [6]=3 [8]=3 [153]=3 [155]=3 [9]=3 [156]=3 [157]=3 [12]=3 [13]=3 [159]=3 [160]=3 [163]=3 [14]=3 [15]=3 [167]=3 [168]=3 [170]=3 [172]=3 [175]=3 [176]=3 [177]=3 [23]=3 [178]=3 [24]=3 [25]=3 [26]=3 [180]=3 [27]=3 [28]=3 [29]=3 [30]=3 [31]=3 [181]=3 [183]=3 [32]=3 [184]=3 [186]=3 [33]=3 [190]=3 [198]=3 [34]=3 [194]=3 [188]=3 [197]=3 [187]=3 [38]=3 [39]=3 [201]=3 [41]=3 [43]=3 [44]=3 [45]=3 [202]=3 [204]=3 [47]=3 [205]=3 [207]=3 [208]=3 [209]=3 [210]=3 [49]=3 [50]=3 [51]=3 [52]=3 [53]=3 [54]=3 [211]=3 [212]=3 [213]=3 [216]=3 [56]=3 [57]=3 [58]=3 [219]=3 [60]=3 [220]=3 [221]=3 [222]=3 [223]=3 [66]=3 [228]=3 [67]=3 [70]=3 [71]=3 [73]=3 [231]=3 [78]=3 [76]=3 [77]=3 [233]=3 [234]=3 [79]=3 [80]=3 [82]=3 [237]=3 [84]=3 [238]=3 [85]=3 [239]=3 [86]=3 [240]=3 [88]=3 [89]=3 [90]=3 [242]=3 [244]=3 [92]=3 [93]=3 [94]=3 [95]=3 [96]=3 [245]=3 [246]=3 [247]=3 [98]=3 [248]=3 [99]=3 [249]=3 [250]=3 [100]=3 [252]=3 [102]=3 [254]=3 [103]=3 [104]=3 [105]=3 [255]=3 [256]=3 [257]=3 [258]=3 [110]=3 [259]=3 [111]=3 [113]=3 [114]=3 [260]=3 [263]=3 [116]=3 [264]=3 [267]=3 [117]=3 [268]=3 [269]=3 [120]=3 [272]=3 [273]=3 [281]=3 [124]=3 [126]=3 [279]=3 [127]=3 [282]=3 [128]=3 [130]=3 [284]=3 [131]=3 [286]=3 [288]=3 [134]=3 [135]=3 [136]=3 [137]=3 [138]=3 [293]=3 [142]=3 [294]=3 [143]=3 [296]=3 [297]=3 [298]=3 [1]=3 [300]=3)" + literal_transitions[8]="([289]=3)" + literal_transitions[9]="([3]=3 [123]=3 [243]=3 [162]=3 [261]=3 [283]=3 [179]=3)" + literal_transitions[10]="([108]=3 [148]=3 [69]=3 [36]=3 [195]=3 [112]=3 [196]=3 [7]=16 [72]=3 [151]=3 [199]=3 [262]=3 [206]=3 [227]=3 [236]=3 [11]=3 [270]=3 [81]=3 [118]=3 [83]=3 [119]=3 [121]=3 [122]=3 [161]=3 [164]=3 [87]=3 [165]=3 [214]=3 [169]=3 [215]=3 [18]=3 [55]=3 [174]=3 [241]=3 [132]=3 [21]=3 [20]=3 [22]=3 [218]=3 [275]=3 [276]=3 [62]=3 [278]=3 [139]=3 [280]=3 [290]=3 [291]=3 [63]=3 [185]=3 [101]=3 [144]=3 [225]=3 [295]=3 [191]=3 [299]=3 [192]=3)" + literal_transitions[11]="([68]=3 [129]=3 [199]=3 [74]=3 [61]=3 [265]=3 [75]=3 [115]=4 [140]=3 [232]=3 [63]=3 [158]=3 [65]=3 [253]=3 [215]=3 [145]=3 [35]=3)" + literal_transitions[13]="([203]=17 [64]=19)" + literal_transitions[16]="([59]=3 [149]=3)" + literal_transitions[17]="([171]=3 [19]=3 [146]=3 [230]=3)" + literal_transitions[18]="([17]=3 [107]=3)" + + local -A match_anything_transitions + match_anything_transitions=([4]=3 [14]=1 [12]=3 [6]=3 [15]=18 [19]=3) + + declare -A subword_transitions + + local state=1 + local word_index=2 + while [[ $word_index -lt $CURRENT ]]; do + if [[ -v "literal_transitions[$state]" ]]; then + local state_transitions_initializer=${literal_transitions[$state]} + local -A state_transitions + eval "state_transitions=$state_transitions_initializer" + + local word=${words[$word_index]} + local word_matched=0 + for literal_id in {1..$#literals}; do + if [[ ${literals[$literal_id]} = "$word" ]]; then + if [[ -v "state_transitions[$literal_id]" ]]; then + state=${state_transitions[$literal_id]} + word_index=$((word_index + 1)) + word_matched=1 + break + fi + fi + done + if [[ $word_matched -ne 0 ]]; then + continue + fi + fi + + if [[ -v "match_anything_transitions[$state]" ]]; then + state=${match_anything_transitions[$state]} + word_index=$((word_index + 1)) + continue + fi + + return 1 + done + + args=() + no_descr_args=() + descrs=() + compadd_completions=() + compadd_descriptions=() + + if [[ -v "literal_transitions[$state]" ]]; then + local state_transitions_initializer=${literal_transitions[$state]} + local -A state_transitions + eval "state_transitions=$state_transitions_initializer" + + for literal_id in ${(k)state_transitions}; do + if [[ -v "descriptions[$literal_id]" ]]; then + args+=("${literals[$literal_id]}") + descrs+=("${literals[$literal_id]//:/\\:}:${descriptions[$literal_id]}") + else + no_descr_args+=("${literals[$literal_id]}") + fi + done + fi + local -A commands=([19]=3 [12]=1 [14]=0 [15]=2) + + if [[ -v "commands[$state]" ]]; then + local command_id=${commands[$state]} + local output=$(_hyprctl_cmd_${command_id} "${words[$CURRENT]}") + local -a command_completions=("${(@f)output}") + for line in ${command_completions[@]}; do + local parts=(${(@s: :)line}) + if [[ -v "parts[2]" ]]; then + args+=(${parts[1]}) + descrs+=("${parts[1]//:/\\:}:${parts[2]}") + else + no_descr_args+=(${parts[1]}) + fi + done + fi + + local -A specialized_commands=([6]=1 [4]=1) + if [[ -v "specialized_commands[$state]" ]]; then + local command_id=${specialized_commands[$state]} + _hyprctl_spec_${command_id} ${words[$CURRENT]} + fi + + compadd -a -Q -S '' no_descr_args + compadd -a -Q -S '' -d compadd_descriptions compadd_completions + _describe '' descrs args -Q -S '' + return 0 +} + +compdef _hyprctl hyprctl diff --git a/completions/hyprctl.usage b/completions/hyprctl.usage new file mode 100644 index 00000000..17de8ef8 --- /dev/null +++ b/completions/hyprctl.usage @@ -0,0 +1,138 @@ +# https://github.com/adaszko/complgen#syntax +hyprctl [