aboutsummaryrefslogtreecommitdiffhomepage
path: root/hyprctl/hyprctl.bash
diff options
context:
space:
mode:
authorloseardes77 <[email protected]>2024-08-18 22:25:23 +0200
committerMihai Fufezan <[email protected]>2024-08-19 00:21:59 +0300
commit83d88fa56467a2b749fb2320e1595281107bd326 (patch)
treeb38a6b045db6e25c8da7ace36d0cde0d5efc9783 /hyprctl/hyprctl.bash
parent11dfb8397becca85cad078dd31bf043d1c40ceac (diff)
downloadHyprland-83d88fa56467a2b749fb2320e1595281107bd326.tar.gz
Hyprland-83d88fa56467a2b749fb2320e1595281107bd326.zip
hyprpm, hyprctl: update shell completions
Diffstat (limited to 'hyprctl/hyprctl.bash')
-rw-r--r--hyprctl/hyprctl.bash87
1 files changed, 44 insertions, 43 deletions
diff --git a/hyprctl/hyprctl.bash b/hyprctl/hyprctl.bash
index c69cca21..e26e623e 100644
--- a/hyprctl/hyprctl.bash
+++ b/hyprctl/hyprctl.bash
@@ -1,17 +1,17 @@
-_hyprctl_cmd_2 () {
+_hyprctl_cmd_1 () {
hyprctl monitors | awk '/Monitor/{ print $2 }'
}
_hyprctl_cmd_3 () {
- hyprpm list | awk '/Plugin/{ print $4 }'
+ hyprctl clients | awk '/class/{print $2}'
}
-_hyprctl_cmd_0 () {
- hyprctl clients | awk '/class/{ print $2 }'
+_hyprctl_cmd_2 () {
+ hyprctl devices | sed -n '/Keyboard at/{n; s/^\s\+//; p}'
}
-_hyprctl_cmd_1 () {
- hyprctl devices | sed -n '/Keyboard at/{n; s/^\s\+//; p}'
+_hyprctl_cmd_0 () {
+ hyprpm list | awk '/Plugin/{print $4}'
}
_hyprctl () {
@@ -23,25 +23,25 @@ _hyprctl () {
local words cword
_get_comp_words_by_ref -n "$COMP_WORDBREAKS" words cword
- local -a literals=("cyclenext" "globalshortcuts" "cursorpos" "bordersize" "renameworkspace" "animationstyle" "focuswindow" "0" "auto" "swapnext" "forceallowsinput" "moveactive" "activebordercolor" "alphafullscreen" "wayland" "layers" "minsize" "monitors" "1" "kill" "settiled" "3" "focusmonitor" "swapwindow" "moveoutofgroup" "notify" "movecursor" "setcursor" "seterror" "movecurrentworkspacetomonitor" "4" "nomaxsize" "forcenoanims" "setprop" "-i" "-q" "togglefloating" "workspacerules" "movetoworkspace" "disable" "setignoregrouplock" "workspaces" "movegroupwindow" "closewindow" "0" "--instance" "binds" "movewindow" "splitratio" "alpha" "denywindowfromgroup" "workspace" "configerrors" "togglegroup" "getoption" "forceopaque" "keepaspectratio" "killactive" "pass" "decorations" "devices" "focuscurrentorlast" "submap" "global" "alphafullscreenoverride" "forcerendererreload" "movewindowpixel" "headless" "version" "dpms" "resizeactive" "moveintogroup" "5" "alphaoverride" "setfloating" "rollinglog" "::=" "rounding" "layouts" "moveworkspacetomonitor" "exec" "alphainactiveoverride" "alterzorder" "fakefullscreen" "nofocus" "keyword" "forcenoborder" "forcenodim" "--quiet" "pin" "output" "forcenoblur" "togglespecialworkspace" "fullscreen" "toggleopaque" "focusworkspaceoncurrentmonitor" "next" "changegroupactive" "-j" "instances" "execr" "exit" "clients" "all" "--batch" "dismissnotify" "inactivebordercolor" "switchxkblayout" "movetoworkspacesilent" "tagwindow" "movewindoworgroup" "-r" "movefocus" "focusurgentorlast" "remove" "activeworkspace" "dispatch" "create" "centerwindow" "2" "hyprpaper" "-1" "reload" "alphainactive" "systeminfo" "plugin" "dimaround" "activewindow" "swapactiveworkspaces" "splash" "sendshortcut" "maxsize" "lockactivegroup" "windowdancecompat" "forceopaqueoverriden" "lockgroups" "movecursortocorner" "x11" "prev" "1" "resizewindowpixel" "forcenoshadow")
-
+ declare -a literals=(resizeactive 2 changegroupactive -r moveintogroup forceallowsinput 4 ::= systeminfo all layouts setprop animationstyle switchxkblayout create denywindowfromgroup headless activebordercolor exec setcursor wayland focusurgentorlast workspacerules movecurrentworkspacetomonitor movetoworkspacesilent hyprpaper alpha inactivebordercolor movegroupwindow movecursortocorner movewindowpixel prev movewindow globalshortcuts clients dimaround setignoregrouplock splash execr monitors 0 forcenoborder -q animations 1 nomaxsize splitratio moveactive pass swapnext devices layers rounding lockactivegroup 5 moveworkspacetomonitor -f -i --quiet forcenodim pin 0 1 forceopaque forcenoshadow setfloating minsize alphaoverride sendshortcut workspaces cyclenext alterzorder togglegroup lockgroups bordersize dpms focuscurrentorlast -1 --batch notify remove instances 1 3 moveoutofgroup killactive 2 movetoworkspace movecursor configerrors closewindow swapwindow tagwindow forcerendererreload centerwindow auto focuswindow seterror nofocus alphafullscreen binds version -h togglespecialworkspace fullscreen windowdancecompat 0 keyword toggleopaque 3 --instance togglefloating renameworkspace alphafullscreenoverride activeworkspace x11 kill forceopaqueoverriden output global dispatch reload forcenoblur -j event --help disable -1 activewindow keepaspectratio dismissnotify focusmonitor movefocus plugin exit workspace fullscreenstate getoption alphainactiveoverride alphainactive decorations settiled config-only descriptions resizewindowpixel fakefullscreen rollinglog swapactiveworkspaces submap next movewindoworgroup cursorpos forcenoanims focusworkspaceoncurrentmonitor maxsize)
declare -A literal_transitions
- literal_transitions[0]="([105]=1 [75]=2 [33]=3 [35]=4 [1]=2 [2]=2 [78]=2 [107]=5 [37]=2 [111]=4 [41]=2 [46]=2 [115]=2 [85]=6 [116]=8 [52]=2 [88]=4 [54]=2 [90]=9 [120]=2 [122]=2 [124]=2 [15]=2 [59]=10 [60]=2 [17]=11 [125]=12 [19]=2 [127]=2 [129]=2 [25]=13 [68]=2 [98]=4 [99]=2 [27]=2 [28]=14 [102]=2 [104]=4)"
- literal_transitions[3]="([73]=17 [13]=2 [32]=17 [55]=17 [56]=17 [91]=17 [106]=2 [123]=2 [77]=1 [16]=2 [126]=17 [3]=1 [5]=2 [64]=17 [131]=2 [133]=17 [81]=17 [134]=17 [84]=17 [31]=17 [49]=2 [12]=2 [86]=17 [10]=17 [87]=17 [141]=17)"
- literal_transitions[7]="([105]=1 [75]=2 [33]=3 [1]=2 [2]=2 [78]=2 [107]=5 [37]=2 [41]=2 [46]=2 [115]=2 [85]=6 [116]=8 [52]=2 [54]=2 [90]=9 [120]=2 [122]=2 [124]=2 [15]=2 [59]=10 [60]=2 [17]=11 [125]=12 [19]=2 [127]=2 [129]=2 [25]=13 [68]=2 [99]=2 [27]=2 [28]=14 [102]=2)"
- literal_transitions[8]="([101]=2 [130]=2 [132]=2 [0]=2 [74]=2 [36]=2 [108]=2 [109]=2 [38]=2 [110]=2 [4]=2 [79]=2 [40]=2 [80]=2 [113]=2 [6]=2 [42]=2 [43]=2 [82]=2 [83]=2 [47]=2 [48]=2 [9]=2 [50]=2 [51]=2 [53]=2 [11]=2 [112]=2 [89]=2 [118]=2 [57]=2 [92]=2 [58]=2 [93]=2 [94]=2 [61]=2 [62]=2 [128]=2 [95]=2 [63]=2 [20]=2 [97]=2 [22]=2 [23]=2 [65]=2 [66]=2 [135]=2 [136]=2 [24]=2 [26]=2 [69]=2 [100]=2 [70]=2 [140]=2 [29]=2 [71]=2)"
- literal_transitions[9]="([117]=20 [114]=16)"
- literal_transitions[11]="([103]=2)"
- literal_transitions[13]="([21]=1 [119]=1 [30]=1 [139]=1 [121]=1 [44]=1 [72]=1)"
- literal_transitions[14]="([39]=2)"
- literal_transitions[15]="([138]=2 [96]=2)"
- literal_transitions[17]="([18]=2 [7]=2)"
- literal_transitions[18]="([76]=19)"
- literal_transitions[19]="([34]=4 [45]=4)"
- literal_transitions[20]="([8]=2 [67]=2 [14]=2 [137]=2)"
-
- declare -A match_anything_transitions
- match_anything_transitions=([1]=2 [0]=7 [6]=2 [15]=2 [10]=2 [5]=15 [14]=18 [7]=7 [2]=18 [16]=2 [12]=2 [11]=18)
+ literal_transitions[0]="([120]=14 [43]=2 [125]=21 [81]=2 [3]=21 [51]=2 [50]=2 [128]=2 [89]=2 [58]=21 [8]=2 [10]=2 [11]=3 [130]=4 [13]=5 [97]=6 [101]=2 [102]=21 [133]=7 [100]=2 [137]=2 [22]=2 [19]=2 [140]=8 [25]=2 [143]=2 [107]=9 [146]=10 [69]=2 [33]=2 [34]=2 [78]=21 [114]=2 [37]=2 [151]=2 [116]=2 [121]=13 [123]=21 [39]=11 [42]=21 [79]=15 [118]=12)"
+ literal_transitions[1]="([81]=2 [51]=2 [50]=2 [128]=2 [8]=2 [89]=2 [10]=2 [11]=3 [130]=4 [13]=5 [97]=6 [101]=2 [133]=7 [100]=2 [22]=2 [19]=2 [137]=2 [140]=8 [25]=2 [143]=2 [107]=9 [146]=10 [69]=2 [33]=2 [34]=2 [114]=2 [37]=2 [151]=2 [116]=2 [39]=11 [118]=12 [121]=13 [120]=14 [79]=15 [43]=2)"
+ literal_transitions[3]="([139]=2 [63]=16 [64]=16 [45]=16 [105]=16 [27]=2 [26]=2 [52]=4 [5]=16 [66]=2 [67]=16 [129]=16 [113]=16 [12]=2 [74]=4 [99]=2 [35]=16 [152]=16 [98]=16 [59]=16 [117]=16 [41]=16 [17]=2 [138]=16 [154]=2 [122]=16)"
+ literal_transitions[6]="([126]=2)"
+ literal_transitions[10]="([56]=2)"
+ literal_transitions[11]="([9]=2)"
+ literal_transitions[12]="([14]=19 [80]=22)"
+ literal_transitions[13]="([142]=2)"
+ literal_transitions[14]="([0]=2 [84]=2 [2]=2 [85]=2 [4]=2 [87]=2 [88]=2 [90]=2 [91]=2 [92]=2 [93]=2 [94]=2 [96]=2 [15]=2 [18]=2 [103]=2 [21]=2 [104]=2 [23]=2 [24]=2 [28]=2 [29]=2 [30]=2 [108]=2 [111]=2 [32]=2 [112]=2 [36]=2 [38]=2 [119]=2 [124]=2 [46]=2 [47]=2 [48]=2 [49]=2 [53]=2 [55]=2 [131]=2 [132]=2 [134]=2 [135]=2 [60]=2 [136]=20 [141]=2 [65]=2 [144]=2 [145]=2 [68]=2 [147]=2 [70]=2 [71]=2 [72]=2 [73]=2 [148]=2 [75]=2 [76]=2 [150]=2 [153]=2)"
+ literal_transitions[15]="([86]=4 [6]=4 [109]=4 [61]=4 [77]=4 [54]=4 [62]=4)"
+ literal_transitions[16]="([40]=2 [44]=2)"
+ literal_transitions[17]="([7]=23)"
+ literal_transitions[18]="([31]=2 [149]=2)"
+ literal_transitions[19]="([95]=2 [16]=2 [115]=2 [20]=2)"
+ literal_transitions[20]="([106]=2 [82]=2 [127]=2 [1]=2 [83]=2)"
+ literal_transitions[23]="([57]=21 [110]=21)"
+ declare -A match_anything_transitions=([6]=17 [7]=2 [0]=1 [22]=2 [5]=18 [4]=2 [2]=17 [18]=2 [11]=17 [8]=2 [9]=2 [13]=17 [10]=17 [1]=1)
declare -A subword_transitions
local state=0
@@ -79,21 +79,9 @@ _hyprctl () {
done
- local prefix="${words[$cword]}"
-
- local shortest_suffix="$word"
- for ((i=0; i < ${#COMP_WORDBREAKS}; i++)); do
- local char="${COMP_WORDBREAKS:$i:1}"
- local candidate="${word##*$char}"
- if [[ ${#candidate} -lt ${#shortest_suffix} ]]; then
- shortest_suffix=$candidate
- fi
- done
- local superfluous_prefix=""
- if [[ "$shortest_suffix" != "$word" ]]; then
- local superfluous_prefix=${word%$shortest_suffix}
- fi
+ local -a matches=()
+ local prefix="${words[$cword]}"
if [[ -v "literal_transitions[$state]" ]]; then
local state_transitions_initializer=${literal_transitions[$state]}
declare -A state_transitions
@@ -102,25 +90,38 @@ _hyprctl () {
for literal_id in "${!state_transitions[@]}"; do
local literal="${literals[$literal_id]}"
if [[ $literal = "${prefix}"* ]]; then
- local completion=${literal#"$superfluous_prefix"}
- COMPREPLY+=("$completion ")
+ matches+=("$literal ")
fi
done
fi
declare -A commands
- commands=([5]=1 [16]=2 [12]=3 [10]=0)
+ commands=([7]=0 [22]=1 [8]=3 [5]=2)
if [[ -v "commands[$state]" ]]; then
local command_id=${commands[$state]}
local completions=()
- mapfile -t completions < <(_hyprctl_cmd_${command_id} "$prefix" | cut -f1)
+ readarray -t completions < <(_hyprctl_cmd_${command_id} "$prefix" | cut -f1)
for item in "${completions[@]}"; do
if [[ $item = "${prefix}"* ]]; then
- COMPREPLY+=("$item")
+ matches+=("$item")
fi
done
fi
+ local shortest_suffix="$prefix"
+ for ((i=0; i < ${#COMP_WORDBREAKS}; i++)); do
+ local char="${COMP_WORDBREAKS:$i:1}"
+ local candidate=${prefix##*$char}
+ if [[ ${#candidate} -lt ${#shortest_suffix} ]]; then
+ shortest_suffix=$candidate
+ fi
+ done
+ local superfluous_prefix=""
+ if [[ "$shortest_suffix" != "$prefix" ]]; then
+ local superfluous_prefix=${prefix%$shortest_suffix}
+ fi
+ COMPREPLY=("${matches[@]#$superfluous_prefix}")
+
return 0
}