This commit is contained in:
Schrottkatze 2023-04-10 17:54:39 +02:00
parent 9f66453c4a
commit ceccab3cb9
4 changed files with 40 additions and 39 deletions

View file

@ -1,30 +1,2 @@
{ pkgs, ... }:
pkgs.writeShellScriptBin "searchwolf" ''
echo "retv $ROFI_RETV"
if [ x"$@" = x"exit" ]; then
exit 0
fi
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
echo -e "\0data\x1f$(echo $ddgrout | jq -r .[].url | jq -sRc '. | split("\n") | [ .[] | select(length > 0) ]')"
;;
esac
''
pkgs.writeShellScriptBin "searchwolf" builtins.readFile ./searchwolf.sh

View file

@ -0,0 +1,28 @@
echo "retv $ROFI_RETV"
if [ x"$@" = x"exit" ]; then
exit 0
fi
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
echo -e "\0data\x1f$(echo $ddgrout | jq -r .[].url | jq -sRc '. | split("\n") | [ .[] | select(length > 0) ]')"
;;
esac