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
30
clipmenu
30
clipmenu
|
@ -30,14 +30,28 @@ if [[ "$CM_LAUNCHER" == rofi ]]; then
|
||||||
set -- -dmenu "$@"
|
set -- -dmenu "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# It's okay to hardcode `-l 8` here as a sensible default without checking
|
list_clips() {
|
||||||
# whether `-l` is also in "$@", because the way that dmenu works allows a later
|
cat "$cache_file_prefix"_* /dev/null | LC_ALL=C sort -rnk 1 | cut -d' ' -f2- | awk '!seen[$0]++'
|
||||||
# argument to override an earlier one. That is, if the user passes in `-l`, our
|
}
|
||||||
# one will be ignored.
|
|
||||||
chosen_line=$(
|
if [[ "$CM_LAUNCHER" == rofi-script ]]; then
|
||||||
cat "$cache_file_prefix"_* /dev/null | LC_ALL=C sort -rnk 1 |
|
if ! (( $# )); then
|
||||||
cut -d' ' -f2- | awk '!seen[$0]++' | "$CM_LAUNCHER" -l 8 "$@"
|
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=$(
|
||||||
|
list_clips | "$CM_LAUNCHER" -l 8 "$@"
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
|
||||||
[[ $chosen_line ]] || exit 1
|
[[ $chosen_line ]] || exit 1
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue