From 6069dd0b2bc1cee32a70b1ae68e441a21fd1c356 Mon Sep 17 00:00:00 2001 From: Jade Date: Wed, 12 Apr 2023 14:21:46 +0200 Subject: [PATCH] get searchwolf running --- scripts/desktop/searchwolf.nix | 2 +- scripts/desktop/searchwolf.sh | 47 ++++++++++++++++------------------ 2 files changed, 23 insertions(+), 26 deletions(-) mode change 100644 => 100755 scripts/desktop/searchwolf.sh diff --git a/scripts/desktop/searchwolf.nix b/scripts/desktop/searchwolf.nix index b2928f1..2f7a9e7 100644 --- a/scripts/desktop/searchwolf.nix +++ b/scripts/desktop/searchwolf.nix @@ -1,2 +1,2 @@ { pkgs, ... }: -pkgs.writeShellScriptBin "searchwolf" builtins.readFile ./searchwolf.sh +pkgs.writeShellScriptBin "searchwolf" (builtins.readFile ./searchwolf.sh) diff --git a/scripts/desktop/searchwolf.sh b/scripts/desktop/searchwolf.sh old mode 100644 new mode 100755 index d142d44..056c689 --- a/scripts/desktop/searchwolf.sh +++ b/scripts/desktop/searchwolf.sh @@ -1,28 +1,25 @@ +if [ x"$@" = x"exit" ]; then + exit 0 +fi - echo "retv $ROFI_RETV" - if [ x"$@" = x"exit" ]; then - exit 0 - fi +case $ROFI_RETV in +0) + ;; +1) + val=${@%%.*} + res=$(echo $ROFI_DATA | jq -r ".[$val]" ) + coproc ( librewolf --new-tab $res > /dev/null 2>&1 ) + exit 0 + ;; +2) + ddgrout=$(ddgr --json --num=25 "$@") - case $ROFI_RETV in - 0) - ;; - 1) - if [ $ROFI_DATA = x"" ]; then - exit 0 - fi - coproc ( librewolf --new-tab "$(echo $ROFI_DATA | jq -r.[${@%%.*}])" > /dev/null 2>&1 ) - exit 0 - ;; - 2) - ddgrout=$(ddgr --json --num=25 "$@") + for i in $(echo $ddgrout | jq -r 'keys | @sh'); do + title=$(echo $ddgrout | jq -r .[$i].title) + url=$(echo $ddgrout | jq -r .[$i].url) + echo "$i. $title ($url)" + done - for i in $(echo $ddgrout | jq -r 'keys | @sh'); do - title=$(echo $ddgrout | jq -r .[$i].title) - url=$(echo $ddgrout | jq -r .[$i].url) - echo "$i. $title ($url)" - done - - echo -e "\0data\x1f$(echo $ddgrout | jq -r .[].url | jq -sRc '. | split("\n") | [ .[] | select(length > 0) ]')" - ;; - esac + echo -e "\0data\x1f$(echo $ddgrout | jq -r .[].url | jq -sRc '. | split("\n") | [ .[] | select(length > 0) ]')" + ;; +esac