-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8876c91
commit 648cb32
Showing
6 changed files
with
290 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#compdef i3lockr | ||
|
||
autoload -U is-at-least | ||
|
||
_i3lockr() { | ||
typeset -A opt_args | ||
typeset -a _arguments_options | ||
local ret=1 | ||
|
||
if is-at-least 5.2; then | ||
_arguments_options=(-s -S -C) | ||
else | ||
_arguments_options=(-s -C) | ||
fi | ||
|
||
local context curcontext="$curcontext" state line | ||
_arguments "${_arguments_options[@]}" \ | ||
'(--brighten)--darken=[Darken the screenshot by \[1, 255\]. Example\: 15]:DARK: ' \ | ||
'(--brighten)--dark=[Darken the screenshot by \[1, 255\]. Example\: 15]:DARK: ' \ | ||
'--brighten=[Brighten the screenshot by \[1, 255\]. Example\: 15]:BRIGHT: ' \ | ||
'--bright=[Brighten the screenshot by \[1, 255\]. Example\: 15]:BRIGHT: ' \ | ||
'-b+[Blur strength. Example\: 10]:RADIUS: ' \ | ||
'--blur=[Blur strength. Example\: 10]:RADIUS: ' \ | ||
'-p+[Scale factor. Increases blur strength by a factor of this. Example\: 2]:FACTOR: ' \ | ||
'--scale=[Scale factor. Increases blur strength by a factor of this. Example\: 2]:FACTOR: ' \ | ||
'*--ignore-monitors=[Don'\''t overlay an icon on these monitors. Useful if you'\''re mirroring displays. Must be comma separated. Example\: 0,2]:0,2: ' \ | ||
'*--ignore=[Don'\''t overlay an icon on these monitors. Useful if you'\''re mirroring displays. Must be comma separated. Example\: 0,2]:0,2: ' \ | ||
'-u+[Icon placement, "x,y" (from top-left), or "-x,-y" (from bottom-right). Has no effect without --icon. Must be comma separated. Defaults to center if not specified. Example\: "945,-20"]:x,y: ' \ | ||
'--position=[Icon placement, "x,y" (from top-left), or "-x,-y" (from bottom-right). Has no effect without --icon. Must be comma separated. Defaults to center if not specified. Example\: "945,-20"]:x,y: ' \ | ||
'--pos=[Icon placement, "x,y" (from top-left), or "-x,-y" (from bottom-right). Has no effect without --icon. Must be comma separated. Defaults to center if not specified. Example\: "945,-20"]:x,y: ' \ | ||
'-i+[Path to icon to overlay on screenshot]:lock.png:_files' \ | ||
'--icon=[Path to icon to overlay on screenshot]:lock.png:_files' \ | ||
'-v[Print how long each step takes, among other things. Always enabled in debug builds]' \ | ||
'--verbose[Print how long each step takes, among other things. Always enabled in debug builds]' \ | ||
'--invert[Interpret the icon as a mask, inverting masked pixels on the screenshot. Try it to see an example]' \ | ||
'-h[Print help]' \ | ||
'--help[Print help]' \ | ||
'-V[Print version]' \ | ||
'--version[Print version]' \ | ||
'*::i3lock -- Arguments to pass to i3lock. Example\: "--nofork --ignore-empty-password":' \ | ||
&& ret=0 | ||
} | ||
|
||
(( $+functions[_i3lockr_commands] )) || | ||
_i3lockr_commands() { | ||
local commands; commands=() | ||
_describe -t commands 'i3lockr commands' commands "$@" | ||
} | ||
|
||
if [ "$funcstack[1]" = "_i3lockr" ]; then | ||
_i3lockr "$@" | ||
else | ||
compdef _i3lockr i3lockr | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
using namespace System.Management.Automation | ||
using namespace System.Management.Automation.Language | ||
|
||
Register-ArgumentCompleter -Native -CommandName 'i3lockr' -ScriptBlock { | ||
param($wordToComplete, $commandAst, $cursorPosition) | ||
|
||
$commandElements = $commandAst.CommandElements | ||
$command = @( | ||
'i3lockr' | ||
for ($i = 1; $i -lt $commandElements.Count; $i++) { | ||
$element = $commandElements[$i] | ||
if ($element -isnot [StringConstantExpressionAst] -or | ||
$element.StringConstantType -ne [StringConstantType]::BareWord -or | ||
$element.Value.StartsWith('-') -or | ||
$element.Value -eq $wordToComplete) { | ||
break | ||
} | ||
$element.Value | ||
}) -join ';' | ||
|
||
$completions = @(switch ($command) { | ||
'i3lockr' { | ||
[CompletionResult]::new('--darken', 'darken', [CompletionResultType]::ParameterName, 'Darken the screenshot by [1, 255]. Example: 15') | ||
[CompletionResult]::new('--dark', 'dark', [CompletionResultType]::ParameterName, 'Darken the screenshot by [1, 255]. Example: 15') | ||
[CompletionResult]::new('--brighten', 'brighten', [CompletionResultType]::ParameterName, 'Brighten the screenshot by [1, 255]. Example: 15') | ||
[CompletionResult]::new('--bright', 'bright', [CompletionResultType]::ParameterName, 'Brighten the screenshot by [1, 255]. Example: 15') | ||
[CompletionResult]::new('-b', 'b', [CompletionResultType]::ParameterName, 'Blur strength. Example: 10') | ||
[CompletionResult]::new('--blur', 'blur', [CompletionResultType]::ParameterName, 'Blur strength. Example: 10') | ||
[CompletionResult]::new('-p', 'p', [CompletionResultType]::ParameterName, 'Scale factor. Increases blur strength by a factor of this. Example: 2') | ||
[CompletionResult]::new('--scale', 'scale', [CompletionResultType]::ParameterName, 'Scale factor. Increases blur strength by a factor of this. Example: 2') | ||
[CompletionResult]::new('--ignore-monitors', 'ignore-monitors', [CompletionResultType]::ParameterName, 'Don''t overlay an icon on these monitors. Useful if you''re mirroring displays. Must be comma separated. Example: 0,2') | ||
[CompletionResult]::new('--ignore', 'ignore', [CompletionResultType]::ParameterName, 'Don''t overlay an icon on these monitors. Useful if you''re mirroring displays. Must be comma separated. Example: 0,2') | ||
[CompletionResult]::new('-u', 'u', [CompletionResultType]::ParameterName, 'Icon placement, "x,y" (from top-left), or "-x,-y" (from bottom-right). Has no effect without --icon. Must be comma separated. Defaults to center if not specified. Example: "945,-20"') | ||
[CompletionResult]::new('--position', 'position', [CompletionResultType]::ParameterName, 'Icon placement, "x,y" (from top-left), or "-x,-y" (from bottom-right). Has no effect without --icon. Must be comma separated. Defaults to center if not specified. Example: "945,-20"') | ||
[CompletionResult]::new('--pos', 'pos', [CompletionResultType]::ParameterName, 'Icon placement, "x,y" (from top-left), or "-x,-y" (from bottom-right). Has no effect without --icon. Must be comma separated. Defaults to center if not specified. Example: "945,-20"') | ||
[CompletionResult]::new('-i', 'i', [CompletionResultType]::ParameterName, 'Path to icon to overlay on screenshot') | ||
[CompletionResult]::new('--icon', 'icon', [CompletionResultType]::ParameterName, 'Path to icon to overlay on screenshot') | ||
[CompletionResult]::new('-v', 'v', [CompletionResultType]::ParameterName, 'Print how long each step takes, among other things. Always enabled in debug builds') | ||
[CompletionResult]::new('--verbose', 'verbose', [CompletionResultType]::ParameterName, 'Print how long each step takes, among other things. Always enabled in debug builds') | ||
[CompletionResult]::new('--invert', 'invert', [CompletionResultType]::ParameterName, 'Interpret the icon as a mask, inverting masked pixels on the screenshot. Try it to see an example') | ||
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') | ||
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') | ||
[CompletionResult]::new('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version') | ||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') | ||
break | ||
} | ||
}) | ||
|
||
$completions.Where{ $_.CompletionText -like "$wordToComplete*" } | | ||
Sort-Object -Property ListItemText | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
_i3lockr() { | ||
local i cur prev opts cmd | ||
COMPREPLY=() | ||
cur="${COMP_WORDS[COMP_CWORD]}" | ||
prev="${COMP_WORDS[COMP_CWORD-1]}" | ||
cmd="" | ||
opts="" | ||
|
||
for i in ${COMP_WORDS[@]} | ||
do | ||
case "${cmd},${i}" in | ||
",$1") | ||
cmd="i3lockr" | ||
;; | ||
*) | ||
;; | ||
esac | ||
done | ||
|
||
case "${cmd}" in | ||
i3lockr) | ||
opts="-v -b -p -u -i -h -V --verbose --dark --darken --bright --brighten --blur --scale --ignore --ignore-monitors --invert --pos --position --icon --help --version [i3lock]..." | ||
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then | ||
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) | ||
return 0 | ||
fi | ||
case "${prev}" in | ||
--darken) | ||
COMPREPLY=($(compgen -f "${cur}")) | ||
return 0 | ||
;; | ||
--dark) | ||
COMPREPLY=($(compgen -f "${cur}")) | ||
return 0 | ||
;; | ||
--brighten) | ||
COMPREPLY=($(compgen -f "${cur}")) | ||
return 0 | ||
;; | ||
--bright) | ||
COMPREPLY=($(compgen -f "${cur}")) | ||
return 0 | ||
;; | ||
--blur) | ||
COMPREPLY=($(compgen -f "${cur}")) | ||
return 0 | ||
;; | ||
-b) | ||
COMPREPLY=($(compgen -f "${cur}")) | ||
return 0 | ||
;; | ||
--scale) | ||
COMPREPLY=($(compgen -f "${cur}")) | ||
return 0 | ||
;; | ||
-p) | ||
COMPREPLY=($(compgen -f "${cur}")) | ||
return 0 | ||
;; | ||
--ignore-monitors) | ||
COMPREPLY=($(compgen -f "${cur}")) | ||
return 0 | ||
;; | ||
--ignore) | ||
COMPREPLY=($(compgen -f "${cur}")) | ||
return 0 | ||
;; | ||
--position) | ||
COMPREPLY=($(compgen -f "${cur}")) | ||
return 0 | ||
;; | ||
--pos) | ||
COMPREPLY=($(compgen -f "${cur}")) | ||
return 0 | ||
;; | ||
-u) | ||
COMPREPLY=($(compgen -f "${cur}")) | ||
return 0 | ||
;; | ||
--icon) | ||
local oldifs | ||
if [ -n "${IFS+x}" ]; then | ||
oldifs="$IFS" | ||
fi | ||
IFS=$'\n' | ||
COMPREPLY=($(compgen -f "${cur}")) | ||
if [ -n "${oldifs+x}" ]; then | ||
IFS="$oldifs" | ||
fi | ||
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then | ||
compopt -o filenames | ||
fi | ||
return 0 | ||
;; | ||
-i) | ||
local oldifs | ||
if [ -n "${IFS+x}" ]; then | ||
oldifs="$IFS" | ||
fi | ||
IFS=$'\n' | ||
COMPREPLY=($(compgen -f "${cur}")) | ||
if [ -n "${oldifs+x}" ]; then | ||
IFS="$oldifs" | ||
fi | ||
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then | ||
compopt -o filenames | ||
fi | ||
return 0 | ||
;; | ||
*) | ||
COMPREPLY=() | ||
;; | ||
esac | ||
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) | ||
return 0 | ||
;; | ||
esac | ||
} | ||
|
||
if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then | ||
complete -F _i3lockr -o nosort -o bashdefault -o default i3lockr | ||
else | ||
complete -F _i3lockr -o bashdefault -o default i3lockr | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
use builtin; | ||
use str; | ||
|
||
set edit:completion:arg-completer[i3lockr] = {|@words| | ||
fn spaces {|n| | ||
builtin:repeat $n ' ' | str:join '' | ||
} | ||
fn cand {|text desc| | ||
edit:complex-candidate $text &display=$text' '(spaces (- 14 (wcswidth $text)))$desc | ||
} | ||
var command = 'i3lockr' | ||
for word $words[1..-1] { | ||
if (str:has-prefix $word '-') { | ||
break | ||
} | ||
set command = $command';'$word | ||
} | ||
var completions = [ | ||
&'i3lockr'= { | ||
cand --darken 'Darken the screenshot by [1, 255]. Example: 15' | ||
cand --dark 'Darken the screenshot by [1, 255]. Example: 15' | ||
cand --brighten 'Brighten the screenshot by [1, 255]. Example: 15' | ||
cand --bright 'Brighten the screenshot by [1, 255]. Example: 15' | ||
cand -b 'Blur strength. Example: 10' | ||
cand --blur 'Blur strength. Example: 10' | ||
cand -p 'Scale factor. Increases blur strength by a factor of this. Example: 2' | ||
cand --scale 'Scale factor. Increases blur strength by a factor of this. Example: 2' | ||
cand --ignore-monitors 'Don''t overlay an icon on these monitors. Useful if you''re mirroring displays. Must be comma separated. Example: 0,2' | ||
cand --ignore 'Don''t overlay an icon on these monitors. Useful if you''re mirroring displays. Must be comma separated. Example: 0,2' | ||
cand -u 'Icon placement, "x,y" (from top-left), or "-x,-y" (from bottom-right). Has no effect without --icon. Must be comma separated. Defaults to center if not specified. Example: "945,-20"' | ||
cand --position 'Icon placement, "x,y" (from top-left), or "-x,-y" (from bottom-right). Has no effect without --icon. Must be comma separated. Defaults to center if not specified. Example: "945,-20"' | ||
cand --pos 'Icon placement, "x,y" (from top-left), or "-x,-y" (from bottom-right). Has no effect without --icon. Must be comma separated. Defaults to center if not specified. Example: "945,-20"' | ||
cand -i 'Path to icon to overlay on screenshot' | ||
cand --icon 'Path to icon to overlay on screenshot' | ||
cand -v 'Print how long each step takes, among other things. Always enabled in debug builds' | ||
cand --verbose 'Print how long each step takes, among other things. Always enabled in debug builds' | ||
cand --invert 'Interpret the icon as a mask, inverting masked pixels on the screenshot. Try it to see an example' | ||
cand -h 'Print help' | ||
cand --help 'Print help' | ||
cand -V 'Print version' | ||
cand --version 'Print version' | ||
} | ||
] | ||
$completions[$command] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
complete -c i3lockr -l darken -l dark -d 'Darken the screenshot by [1, 255]. Example: 15' -r | ||
complete -c i3lockr -l brighten -l bright -d 'Brighten the screenshot by [1, 255]. Example: 15' -r | ||
complete -c i3lockr -s b -l blur -d 'Blur strength. Example: 10' -r | ||
complete -c i3lockr -s p -l scale -d 'Scale factor. Increases blur strength by a factor of this. Example: 2' -r | ||
complete -c i3lockr -l ignore-monitors -l ignore -d 'Don\'t overlay an icon on these monitors. Useful if you\'re mirroring displays. Must be comma separated. Example: 0,2' -r | ||
complete -c i3lockr -s u -l position -l pos -d 'Icon placement, "x,y" (from top-left), or "-x,-y" (from bottom-right). Has no effect without --icon. Must be comma separated. Defaults to center if not specified. Example: "945,-20"' -r | ||
complete -c i3lockr -s i -l icon -d 'Path to icon to overlay on screenshot' -r -F | ||
complete -c i3lockr -s v -l verbose -d 'Print how long each step takes, among other things. Always enabled in debug builds' | ||
complete -c i3lockr -l invert -d 'Interpret the icon as a mask, inverting masked pixels on the screenshot. Try it to see an example' | ||
complete -c i3lockr -s h -l help -d 'Print help' | ||
complete -c i3lockr -s V -l version -d 'Print version' |