Know when run from terminal or keybinding.

This commit is contained in:
CronyAkatsuki 2023-11-26 15:18:10 +01:00
parent 4cd2b1f8e4
commit 4fa645ea5e

23
pirokit
View File

@ -30,18 +30,25 @@ launcher() {
baseurl="https://www.1377x.to/" baseurl="https://www.1377x.to/"
prompt="fzf" prompt=""
# check wherer script is run from a terminal or keybinding/dmenu
if [ -t 0 ]; then
prompt="fzf"
else
prompt="dmenu"
fi
#get query from dmenu #get query from dmenu
case "$1" in case "$1" in
"--dmenu")
prompt="dmenu"
query=$(printf '%s' "" | launcher $prompt "Search Torrent: " | sed 's/ /+/g')
;;
"") "")
printf '%s' "Search Torrent: " if [ "$prompt" = "dmenu" ]; then
read -r query query=$(printf '%s' "" | launcher $prompt "Search Torrent: " | sed 's/ /+/g')
query=$(printf '%s\n' "$query" | sed 's/ /+/g') else
printf '%s' "Search Torrent: "
read -r query
query=$(printf '%s\n' "$query" | sed 's/ /+/g')
fi
;; ;;
*) *)
query=$(printf '%s\n' "$1" | sed 's/ /+/g') query=$(printf '%s\n' "$1" | sed 's/ /+/g')