Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.3 KiB

4 years ago
  1. #!/bin/sh
  2. # Menu Surfraw: https://github.com/TomboFry/menu-surfraw
  3. # Modified version of https://github.com/onespaceman/menu-calc to display
  4. # available elvi to use in surfraw then get the search term afterwards and open
  5. # it in your browser of choice.
  6. # Edit here to change what browser you open links in
  7. usage() {
  8. echo "Usage: $0 [OPTIONS] [ELVIS [SEARCHTERM]]
  9. OPTIONS:
  10. -h, --help Displays this message
  11. ELVIS:
  12. This is the same as surfraw, any Elvi you have installed. Can be left
  13. blank, as you will be prompted for this in dmenu/rofi.
  14. SEARCHTERM:
  15. Again, the same as surfraw, the term you are searching for. Can also be
  16. left blank as you will be prompted for this in dmenu/rofi."
  17. exit
  18. }
  19. case $1 in
  20. "-h"|"--help") usage ;;
  21. esac
  22. # Path to menu application
  23. if [[ -n $(command -v dmenu) ]]; then
  24. menu="$(command -v dmenu )"
  25. elif [[ -n $(command -v rofi) ]]; then
  26. menu="$(command -v rofi)"
  27. else
  28. echo "Rofi or dmenu not found, exiting."
  29. exit
  30. fi
  31. answerA=$(echo "$1")
  32. answerB=$(echo "${@:2}")
  33. # Change what to display in rofi/dmenu
  34. # If both the first prompt and second prompt are not empty, it will finally open
  35. # the search in surfraw
  36. action=$(echo "" | $menu -p "$answerA ")
  37. if [ "$action" = "" ]; then
  38. exit
  39. fi
  40. surfraw -browser=$BROWSER $answerA $action