Allow use as a rofi script (#68)
* Allow use as a rofi script * fixup! Allow use as a rofi script * fixup! Allow use as a rofi script * fixup! Allow use as a rofi script
This commit is contained in:
parent
09e654731e
commit
b73e742c50
18
clipmenu
18
clipmenu
|
@ -30,14 +30,28 @@ if [[ "$CM_LAUNCHER" == rofi ]]; then
|
|||
set -- -dmenu "$@"
|
||||
fi
|
||||
|
||||
list_clips() {
|
||||
cat "$cache_file_prefix"_* /dev/null | LC_ALL=C sort -rnk 1 | cut -d' ' -f2- | awk '!seen[$0]++'
|
||||
}
|
||||
|
||||
if [[ "$CM_LAUNCHER" == rofi-script ]]; then
|
||||
if ! (( $# )); then
|
||||
list_clips
|
||||
exit
|
||||
else
|
||||
# https://github.com/koalaman/shellcheck/issues/1141
|
||||
# shellcheck disable=SC2124
|
||||
chosen_line="${@: -1}"
|
||||
fi
|
||||
else
|
||||
# It's okay to hardcode `-l 8` here as a sensible default without checking
|
||||
# whether `-l` is also in "$@", because the way that dmenu works allows a later
|
||||
# argument to override an earlier one. That is, if the user passes in `-l`, our
|
||||
# one will be ignored.
|
||||
chosen_line=$(
|
||||
cat "$cache_file_prefix"_* /dev/null | LC_ALL=C sort -rnk 1 |
|
||||
cut -d' ' -f2- | awk '!seen[$0]++' | "$CM_LAUNCHER" -l 8 "$@"
|
||||
list_clips | "$CM_LAUNCHER" -l 8 "$@"
|
||||
)
|
||||
fi
|
||||
|
||||
[[ $chosen_line ]] || exit 1
|
||||
|
||||
|
|
Loading…
Reference in a new issue