diff --git a/pirokit b/pirokit index a1d3b16..8509a45 100755 --- a/pirokit +++ b/pirokit @@ -30,18 +30,25 @@ launcher() { 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 case "$1" in -"--dmenu") - prompt="dmenu" - query=$(printf '%s' "" | launcher $prompt "Search Torrent: " | sed 's/ /+/g') - ;; "") - printf '%s' "Search Torrent: " - read -r query - query=$(printf '%s\n' "$query" | sed 's/ /+/g') + if [ "$prompt" = "dmenu" ]; then + query=$(printf '%s' "" | launcher $prompt "Search Torrent: " | 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')