bopen.sh 590 B

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/sh
  2. bfile="/tmp/bookmarks.json"
  3. prepare_bmarks ()
  4. {
  5. jq -r '.. | objects | select(.type == "text/x-moz-place") | [.uri, .title] | @tsv' "$bfile" | tr '\t' ' '
  6. }
  7. uri=$(prepare_bmarks | dmenu -b -l 10 -i | cut -f1 -d' ')
  8. if [ -z "$uri" ]; then
  9. echo 'Nothing selected' >&2
  10. exit 0
  11. fi
  12. echo "$uri" >&2
  13. if [ -n "$(pgrep icecat)" ]; then
  14. echo 'Icecat running. Open new tab…' >&2
  15. icecat --new-tab "$uri"
  16. exit $?
  17. fi
  18. if [ -n "$(pgrep firefox)" ]; then
  19. echo 'Firefox running. Open new tab…' >&2
  20. firefox --new-tab "$uri"
  21. exit $?
  22. fi
  23. echo 'No web browsers available.' >&2
  24. exit 1