-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsuggest
executable file
·31 lines (29 loc) · 1.01 KB
/
suggest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# Requires:
# rofi-blocks : https://github.com/OmarCastro/rofi-blocks
# Author https://github.com/Belkadev
[ -z "$1" ] && echo "suggest google|youtube|ddg|wikipedia|deezer|lastfm|books" && exit 1
API="$1"
#Full path to the handler script
handler=$(dirname $0)/handler
[ ! -f "$handler" ] && echo "invalid path to handler script" && exit 1
case "$API" in
"google") prompt="Google: " ;;
"deezer") prompt="Music: " ;;
"youtube") prompt="Youtube: " ;;
"lastfm") prompt="Music: " ;;
"books") prompt="Books: " ;;
"wikipedia") prompt="Wikipedia: " ;;
"ddg") prompt="Ddg: " ;;
"amazon") prompt="Amazon: " ;;
"archwiki") prompt="Archwiki: " ;;
"baidu") prompt="Baidu: " ;;
*) echo "unrecognized API" && exit 1 ;;
esac
###############
logfile="$(dirname $handler)/logfile.tmp" # logfile to communicate between two ends
printf "$API" > "$logfile"
rofi -modi blocks -show blocks -blocks-wrap $handler -display-blocks "$prompt" 2>/dev/null
[ -f $logfile ] && selection="$(cat "$logfile")" || exit 0
echo "$selection"
exit 0