1
0
Fork 0
mirror of https://github.com/Raymo111/i3lock-color.git synced 2024-12-02 14:05:43 -05:00

Tab completion (#204) (#230)

* Tab completion

* Added --special-passthrough flag

* Integration with autotools

* Fixed build test

* Update completions

* Indent

Co-authored-by: Raymond Li <hi@raymond.li>
This commit is contained in:
Jezer Mejía 2021-09-18 22:44:07 -06:00 committed by GitHub
parent d78d22017a
commit 995f58dc73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 385 additions and 0 deletions

View file

@ -13,6 +13,33 @@ pamddir = $(sysconfdir)/pam.d
pamd_files = pam/i3lock pamd_files = pam/i3lock
pamd_DATA = $(pamd_files) pamd_DATA = $(pamd_files)
if ENABLE_BASH_COMPLETION
bashcompletiondir = $(BASH_COMPLETION_DIR)
dist_bashcompletion_DATA = i3lock-bash
endif
if ENABLE_ZSH_COMPLETION
zshcompletiondir = $(ZSH_COMPLETION_DIR)
dist_zshcompletion_DATA = i3lock-zsh
endif
install-data-hook:
if ENABLE_BASH_COMPLETION
test -f "${BASH_COMPLETION_DIR}/i3lock-bash" && mv -f "${BASH_COMPLETION_DIR}/i3lock-bash" "${BASH_COMPLETION_DIR}/i3lock" || true
endif
if ENABLE_ZSH_COMPLETION
test -f "${ZSH_COMPLETION_DIR}/i3lock-zsh" && mv -f "${ZSH_COMPLETION_DIR}/i3lock-zsh" "${ZSH_COMPLETION_DIR}/_i3lock" || true
endif
uninstall-hook:
if ENABLE_BASH_COMPLETION
rm -f ${BASH_COMPLETION_DIR}/i3lock
endif
if ENABLE_ZSH_COMPLETION
rm -f ${ZSH_COMPLETION_DIR}/_i3lock
endif
AM_CPPFLAGS = \ AM_CPPFLAGS = \
@AX_EXTEND_SRCDIR_CPPFLAGS@ @AX_EXTEND_SRCDIR_CPPFLAGS@

View file

@ -124,6 +124,9 @@ AX_APPEND_FLAG([-pthread], [AM_CFLAGS])
AX_CHECK_COMPILE_FLAG([-Wunused-value], [AX_APPEND_FLAG([-Wunused-value], [AM_CFLAGS])]) AX_CHECK_COMPILE_FLAG([-Wunused-value], [AX_APPEND_FLAG([-Wunused-value], [AM_CFLAGS])])
AC_SUBST(AM_CFLAGS) AC_SUBST(AM_CFLAGS)
AX_CHECK_BASH_COMPLETION
AX_CHECK_ZSH_COMPLETION
# Checks for header files. # Checks for header files.
AC_CHECK_HEADERS([fcntl.h float.h inttypes.h limits.h locale.h netinet/in.h paths.h stddef.h stdint.h stdlib.h string.h sys/param.h sys/socket.h sys/time.h unistd.h], , [AC_MSG_FAILURE([cannot find the $ac_header header, which i3lock requires])]) AC_CHECK_HEADERS([fcntl.h float.h inttypes.h limits.h locale.h netinet/in.h paths.h stddef.h stdint.h stdlib.h string.h sys/param.h sys/socket.h sys/time.h unistd.h], , [AC_MSG_FAILURE([cannot find the $ac_header header, which i3lock requires])])

113
i3lock-bash Normal file
View file

@ -0,0 +1,113 @@
#!/usr/bin/env bash
# bash completion for i3lock-color
_i3lock() {
local cur="${COMP_WORDS[COMP_CWORD]}"
local last="${COMP_WORDS[COMP_CWORD - 1]}"
local -a options=(
"--version -v"
"--nofork -n"
"--beep -b"
"--no-unlock-indicator -u"
"--image -i"
"--raw"
"--color -c"
"--tiling -t"
"--centered -C"
"--fill -F"
"--max -M"
"--scale -L"
"--pointer -p"
"--ignore-empty-password -e"
"--show-failed-attempts"
"--debug"
# i3lock-color OPTIONS
"--screen -S"
"--blur -B"
"--clock --force-clocl -k"
"--indicator"
"--radius"
"--ring-width"
# Colors
"--inside-color"
"--ring-color"
"--insidever-color"
"--ringver-color"
"--insidewrong-color"
"--ringwrong-color"
"--line-color"
"--line-uses-inside"
"--line-uses-ring"
"--keyhl-color"
"--bshl-color"
"--separator-color"
"--verif-color"
"--wrong-color"
"--modif-color"
"--layout-color"
"--time-color"
"--date-color"
"--greeter-color"
# Text
"--time-str"
"--date-str"
"--verif-text"
"--wrong-text"
"--keylayout"
"--noinput-text"
"--lock-text"
"--lockfailed-text"
"--greeter-text"
"--no-modkey-text"
# Align
"--time-align --date-align --layout-align --verif-align --wrong-algin --modif-align --greeter-align"
# Outline
"--timeoutlinecolor --dateoutlinecolor --layoutoutlinecolor --verifoutlinecolor --wrongoutlinecolor --modifoutline-color --greeteroutlinecolor"
# Fonts
"--time-font --date-font --layout-font --verif-font --wrong-font --greeter-font"
# Size
"--timesize --datesize --layoutsize --verifsize --wrongsize --greetersize"
# Outline width
"--timeoutlinewidth --dateoutlinewidth --layoutoutlinewidth --verifoutlinewidth --wrongoutlinewidth --modifieroutline-width --greeteroutlinewidth"
# Position
"--ind-pos"
"--time-pos"
"--date-pos"
"--greeter-pos"
# Media keys
"--pass-media-keys"
"--pass-screen-keys"
"--pass-power-keys"
"--pass-volume-keys"
"--special-passthrough"
# Bar mode
"--bar-indicator"
"--bar-direction"
"--bar-orientation"
"--bar-step"
"--bar-max-height"
"--bar-base-width"
"--bar-color"
"--bar-periodic-step"
"--bar-pos"
"--bar-count"
"--bar-total-width"
# Extra configs
"--redraw-thread"
"--refresh-rate"
"--composite"
"--no-verify"
"--slideshow-interval"
"--slideshow-random-selection"
)
local args=""
for i in "${options[@]}"; do
args+="$i "
done
COMPREPLY=( $(compgen -W "${args}" -- ${cur}) )
}
complete -F _i3lock i3lock

171
i3lock-zsh Normal file
View file

@ -0,0 +1,171 @@
#compdef i3lock
_i3lock() {
integer ret=1
local -a args
zstyle ':completion:*:*:i3lock:*:descriptions' format ''
args+=(
"(--version -v)"{--version,-v}"[Display the version of i3lock]"
"(--nofork -n)"{--nofork,-n}"[Don't fork after starting]"
"(--beep -b)"{--beeping,-b}"[Enable beeping]"
"(--no-unlock-indicator -u)"{--no-unlock-indicator,-u}"[Disable the unlock indicator]"
"(--image -i)"{--image,-i}"[Display the given PNG image instead of a blank screen]:filename:_files -g '*.(png|jpg)'"
"--raw[Read the image given by --image as a raw image instead of PNG]:raw:"
"(--color -c)"{--color,-c}"[Turn the screen into the given hex color]:hex:->hex"
"(--tiling -t)"{--tiling,-t}"[Image will be displayed tiled all over the screen]"
"(--centered -C)"{--centered,-C}"[Image will be displayed centered on the screen]"
"(--fill -F)"{--fill,-F}"[Image will fill all over the screen]"
"(--max -M)"{--max,-M}"[Image will fit the screen at width or height]"
"(--scale -L)"{--scale,-L}"[Image will be stretched on the screen]"
"(--pointer -p)"{--pointer,-p}"[Sets mouse pointer type]:pointer:(win default)"
"(--ignore-empty-password -e)"{--ignore-empty-password,-e}"[Do not validate empty password]"
"(--show-failed-attempts -f)"{--show-failed-attempts,-f}"[Show the number of failed attemps]"
"--debug[Enables debug logging.]"
# i3lock-color OPTIONS
"(--screen -S)"{--screen,-S}"[Specifies which display to draw the unlock indicator]:int:"
"(--blur -B)"{--blur,-B}"[Captures the screen and blurs it using the given sigma]:sigma:"
"(--clock --force-clock -k)"{--clock,--force-clock,-k}"[Displays the clock]"
"--indicator[Forces the indicator to always be visible]"
"--radius[The radius of the circle]:float:"
"--ring-width[The width of the ring unlock indicator]:float:"
# Colors
"--inside-color[Sets the default \"resting\" color for the interior circle]:hex:->hex"
"--ring-color[Sets the default ring color]:hex:->hex"
"--insidever-color[Sets the interior circle color while the password is being verified]:hex:->hex"
"--ringver-color[Sets the ring color while the password is being verified]:hex:->hex"
"--insidewrong-color[Sets the interior circle color for suring flash for an incorrect password]:hex:->hex"
"--ringwrong-color[Sets the ring color during the flas for an incorrect password]:hex:->hex"
"--line-color[Sets the color for the line separating the inside circle, and the outer ring]:hex:->hex"
"--line-uses-inside[Conflicts with --line-uses-ring. Overrides --linecolor; the line will match the inside color]"
"--line-uses-ring[Conflicts with --line-uses-inside. Overrides --linecolor; The line will match the ring color]"
"--keyhl-color[Sets the color of the ring 'highlight' strokes that appear upon keypress]:hex:->hex"
"--bshl-color[Sets the color of the ring 'highlight' strokes that appear upon backspace]:hex:->hex"
"--separator-color[Sets the color of the 'separator', which is at both ends of the ring highlights]:hex:->hex"
"--verif-color[Sets the color of the status text while verifying]:hex:->hex"
"--wrong-color[Sets the color of the status when \"wrong\"]:hex:->hex"
"--modif-color[Sets the color of the status text while verifying]:hex:->hex"
"--layout-color[Sets the color of the keyboard layout text]:hex:->hex"
"--time-color[Sets te color of the time in the clock]:hex:->hex"
"--date-color[Sets the color of the date in the clock]:hex:->hex"
"--greeter-color[Sets the color of the greeter text]:hex:->hex"
# Text
"--time-str[Sets the format used for generating the time string]:str:"
"--date-str[Sets the format used for generating the date string]:str:"
"--verif-text[Sets the string to be shown while verifying]:str:"
"--wrong-text[Sets the string to be shown upon entering an incorrect password]:str:"
"--keylayout[Displays the keylayout]:mode:((0\:'Displays the full string returned by the query, i.e. English (US)' 1\:'Displays up until the first parenthesis, i.e. English' 2\:'Displays just the contents of the parenthesis, i.e US'))"
"--noinput-text[Sets the string to be shown upon pressing backspace whithout anything to delete]:str:"
"--lock-text[Sets the string to be shown while acquiring pointer and keyboard focus]:str:"
"--lockfailed-text[Sets the string to be shown after failing to acquire pointer and keyboard focus]:str:"
"--greeter-text[Sets the greeter text]:str:"
"--no-modkey-text[Hides the modkey indicator]"
# Align
"(--time-align --date-align --layout-align --verif-align --wrong-align --modif-align --greeter-align)"{--time-align,--date-align,--layout-align,--verif-align,--wrong-align,--modif-align,--greeter-align}"[Sets the text alignment]:alignment:((0\:'default' 1\:'left aligned' 2\:'right aligned'))"
# Outline color
"(--timeoutline-color --dateoutline-color --layoutoutline-color --verifoutline-color --wrongoutline-color --modifoutline-color --greeteroutline-color)"{--timeoutline-color,--dateoutline-color,--layoutoutline-color,--verifoutline-color,--wrongoutline-color,--modifoutline-color,--greeteroutline-color}"[Sets the color of the outline]:hex:->hex"
# Fonts
"(--time-font --date-font --layout-font --verif-font --wrong-font --greeter-font)"{--time-font,--date-font,--layout-font,--verif-font,--wrong-font,--greeter-font}"[Sets the font used to render various strings]:str:"
# Size
"(--time-size --date-size --layout-size --verif-size --wrong-size --greeter-size)"{--time-size,--date-size,--layout-size,--verif-size,--wrong-size,--greeter-size}"[Sets the font size used to render various strings]:int:"
# Outline width
"(--timeoutline-width --dateoutline-width --layoutoutline-width --verifoutline-width --wrongoutline-width --modifieroutline-width --greeteroutline-width)"{--timeoutline-width,--dateoutline-width,--layoutoutline-width,--verifoutline-width,--wrongoutline-width,--modifieroutline-width,--greeteroutline-width}"[Sets the width of the outline]:float:"
# Position
"--ind-pos[Sets the position for the unlock indicator]:pos:->ind_pos"
"--time-pos[Sets the position for the time string]:pos:->time_pos"
"--date-pos[Sets the position for the date string]:pos:->date_pos"
"--greeter-pos[Sets the position for the greeter string]:pos:->greeter_pos"
# Media keys
"--pass-media-keys[Allow media keys to be used while the screen is locked]"
"--pass-screen-keys[Allow screen keys to be used while the screen is locked]"
"--pass-power-keys[Allow power keys to be used while the screen is locked]"
"--pass-volume-keys[Allow volume keys to be used while the screen is locked]"
"--special-passthrough[Force allowed key to be sent to wm/de]"
# Bar mode
"--bar-indicator[Replaces the usual ring indicator with a bar indicator]"
"--bar-direction[Sets the direction the bars grow in]:direction:((0\:'default' 1\:'reverse' 2\:'both'))"
"--bar-orientation[Sets whether the bar is vertically or horizontally oriented]:orientation:(vertical horizontal)"
"--bar-step[Sets the step that each bar decreases by when a key is pressed]:int:"
"--bar-max-height[The maximum height a bar can get to]:float:"
"--bar-base-width[The thickness of the \"base\" bar that all the bar originate from]:float:"
"--bar-color[Sets the default color of the bar base]:hex:->hex"
"--bar-periodic-step[The value by which the bars decrease each time the screen is redrawn]:int:"
"--bar-pos[Sets the bar position]:pos:->bar_pos"
"--bar-count[Sets the number of minibars to draw on each screen]:int:"
"--bar-total-width[The total width of the bar]:float:"
# Extra configs
"--redraw-thread[Starts a separate thread for redrawing the screen]"
"--refresh-rate[The refresh rate of the indicator]:double:"
"--composite"
"--no-verify[Do not verify the password provided by the user and unlock inmediately]"
# Slideshow
"--slideshow-interval[The interval to wait until switching to the nex image]:double:"
"--slideshow-random-selection[Randomize the order of the images]"
)
_arguments $args[@] && ret=0
case "$state" in
hex)
zstyle ':completion:*:*:i3lock:*:descriptions' format '%d'
_message "Color in hexadecimal rrggbbaa, like #ff0000ff or #354F9AFF"
;;
ind_pos)
zstyle ':completion:*:*:i3lock:*:normal' format '%d'
zstyle ':completion:*:*:i3lock:*:descriptions' format '%B%d%b'
_message "\"x position:y position\""
_message -e "normal" "'x' - x position of the current display. Corresponds to the left-most row of pixels"
_message -e "normal" "'y' - y position of the current display. Corresponds to the topmost row of pixels"
_message -e "normal" "'w' - width of the current display"
_message -e "normal" "'w' - height of the current display"
_message -e "normal" "'r' - unlock indicator radius"
;;
time_pos)
zstyle ':completion:*:*:i3lock:*:normal' format '%d'
zstyle ':completion:*:*:i3lock:*:descriptions' format '%B%d%b'
_message "\"x position:y position\""
_message -e "normal" "All the variables from --ind-pos may be used, in addition to:"
_message -e "normal" "'ix' - x position of the indicator on the current display"
_message -e "normal" "'iy' - y position of the indicator on the current display"
_message -e "normal" "If the --bar-indicator option is used, the following may be used"
_message -e "normal" "'bw' - width od the bar indicator"
_message -e "normal" "'bx' - x position of the bar indicator on the current display"
_message -e "normal" "'by' - y position of the bar indicator on the current display"
;;
date_pos)
zstyle ':completion:*:*:i3lock:*:normal' format '%d'
zstyle ':completion:*:*:i3lock:*:descriptions' format '%B%d%b'
_message "\"x position:y position\""
_message -e "normal" "All the variables from --ind-pos and --time-pos may be used, in addition to:"
_message -e "normal" "'tx' - x position of the timestring on the current display"
_message -e "normal" "'ty' - y position of the timestring on the current display"
;;
greeter_pos)
zstyle ':completion:*:*:i3lock:*:normal' format '%d'
zstyle ':completion:*:*:i3lock:*:descriptions' format '%B%d%b'
_message "\"x position:y position\""
_message -e "normal" "All the variables from --ind-pos and --time-pos may be used"
;;
bar_pos)
zstyle ':completion:*:*:i3lock:*:normal' format '%d'
zstyle ':completion:*:*:i3lock:*:descriptions' format '%B%d%b'
_message "\"x position:y position\""
_message -e "normal" "All the variables from --ind-pos and --time-pos may be used"
_message -e "normal" "If only one number is provided, sets the vertical offset from the top or left edge"
_message -e "normal" "If two numbers are provided, sets the starting position of the bar"
;;
esac
return ret
}
_i3lock

View file

@ -0,0 +1,34 @@
# SYNOPSIS
#
# AX_CHECK_BASH_COMPLETION()
#
# DESCRIPTION
#
# Checks for the presence of an --with-bash-completion-dir option to set a
# custom path to bash completions. If no specified, it will use the default
# path as long as bash-completion is available.
#
#serial 1
AC_DEFUN([AX_CHECK_BASH_COMPLETION], [
AC_ARG_WITH([bash-completion-dir],
AS_HELP_STRING([--with-bash-completion-dir[=PATH]],
[Install the bash auto-completion script in this directory. @<:@default=yes@:>@]),
[],
[with_bash_completion_dir=yes])
# Check bash-completion
if test "x$with_bash_completion_dir" = "xyes"; then
PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0], [
BASH_COMPLETION_DIR="$datadir/bash-completion/completions"
], [
BASH_COMPLETION_DIR=""
])
else
BASH_COMPLETION_DIR="$with_bash_completion_dir"
fi
AC_SUBST([BASH_COMPLETION_DIR])
AM_CONDITIONAL([ENABLE_BASH_COMPLETION], [test "x$with_bash_completion_dir" != "xno" && test "$BASH_COMPLETION_DIR" != ""])
])

View file

@ -0,0 +1,37 @@
# SYNOPSIS
#
# AX_CHECK_ZSH_COMPLETION()
#
# DESCRIPTION
#
# Checks for the presence of an --with-zsh-completion-dir option to set a
# custom path to zsh completions. If no specified, it will use the default
# path as long as zsh is available.
#
#serial 1
AC_DEFUN([AX_CHECK_ZSH_COMPLETION], [
AC_ARG_WITH([zsh-completion-dir],
AS_HELP_STRING([--with-zsh-completion-dir[=PATH]],
[Install the zsh auto-completion script in this directory. @<:@default=yes@:>@]),
[],
[with_zsh_completion_dir=yes])
# Check zsh-completion
if test "x$with_zsh_completion_dir" = "xyes"; then
AC_ARG_VAR([ZSH_AVAILABLE], [])
AC_CHECK_PROG([ZSH_AVAILABLE], [zsh], [yes], [no])
AS_IF([test "$ZSH_AVAILABLE" = "yes"], [
ZSH_COMPLETION_DIR="$datadir/zsh/vendor-completions"
], [
ZSH_COMPLETION_DIR=""
])
else
ZSH_COMPLETION_DIR="$with_zsh_completion_dir"
fi
AC_SUBST([ZSH_COMPLETION_DIR])
AM_CONDITIONAL([ENABLE_ZSH_COMPLETION], [test "x$with_zsh_completion_dir" != "xno" && test "$ZSH_COMPLETION_DIR" != ""])
])