From 4fa645ea5e2623c110a4c0a99dc4dc9ea00d9fef Mon Sep 17 00:00:00 2001 From: CronyAkatsuki Date: Sun, 26 Nov 2023 15:18:10 +0100 Subject: [PATCH] Know when run from terminal or keybinding. --- pirokit | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) 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')