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.

51 lines
1.3 KiB

4 years ago
  1. #!/bin/bash
  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. browser="firefox-developer-edition"
  8. usage() {
  9. echo "Usage: $0 [OPTIONS] [ELVIS [SEARCHTERM]]
  10. OPTIONS:
  11. -h, --help Displays this message
  12. ELVIS:
  13. This is the same as surfraw, any Elvi you have installed. Can be left
  14. blank, as you will be prompted for this in dmenu/rofi.
  15. SEARCHTERM:
  16. Again, the same as surfraw, the term you are searching for. Can also be
  17. left blank as you will be prompted for this in dmenu/rofi."
  18. exit
  19. }
  20. case $1 in
  21. "-h"|"--help") usage ;;
  22. esac
  23. # Path to menu application
  24. if [[ -n $(command -v dmenu) ]]; then
  25. menu="$(command -v dmenu )"
  26. elif [[ -n $(command -v rofi) ]]; then
  27. menu="$(command -v rofi)"
  28. else
  29. echo "Rofi or dmenu not found, exiting."
  30. exit
  31. fi
  32. answerA=$(echo "$1")
  33. answerB=$(echo "${@:2}")
  34. # Change what to display in rofi/dmenu
  35. # If both the first prompt and second prompt are not empty, it will finally open
  36. # the search in surfraw
  37. action=$(echo "" | $menu -p "$answerA ")
  38. surfraw -browser=$browser $answerA $action