summaryrefslogtreecommitdiff
path: root/ar/.local/bin/dmenubrowse
blob: a7446ac5a6eec9a316efddcbeb49be921f9b0b66 (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh

# Use dmenu to choose a search option
SEARCH_TOOL=$(printf "DuckDuckGo\nSearx\nWebsite\nYouTube" | dmenu -i -p "Which option?")

# Exit if no option is selected
[ -z "$SEARCH_TOOL" ] && exit 1

# Determine the command to execute based on the search tool
case "$SEARCH_TOOL" in
"DuckDuckGo")
  # For DuckDuckGo, run ddgr in the terminal
  TOOL="$TERMINAL -e browse -d"
  ;;
"Searx")
  # Searx can be run directly in the browser
  TOOL="browse"
  ;;
"Website")
  # Ask the user for the website
  SITE=$(dmenu -i -p "Which site?")

  # Exit if no site is provided
  [ -z "$SITE" ] && exit 1

  # For website searches, run ddgr in the terminal with the website option
  TOOL="$TERMINAL -e browse -w $SITE"
  ;;
"YouTube")
  TOOL="browse -y"
  ;;
*)
  TOOL="browse"
  ;;
esac

# Get the search query from the user
SEARCH_QUERY=$(echo | dmenu -i -p "Search: ")

# Exit if no search query is provided
[ -z "$SEARCH_QUERY" ] && exit 1

# Execute the command
$TOOL "$SEARCH_QUERY"