2015-11-12 07:21:33 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# Handle open -s && open -t with bemenu
|
|
|
|
|
2015-11-17 15:56:40 +01:00
|
|
|
#:bind o spawn --userscript /path/to/userscripts/qutedmenu open
|
2015-11-17 16:41:20 +01:00
|
|
|
#:bind O spawn --userscript /path/to/userscripts/qutedmenu tab
|
2015-11-12 07:21:33 +01:00
|
|
|
|
|
|
|
# If you would like to set a custom colorscheme/font use these dirs.
|
|
|
|
# https://github.com/halfwit/dotfiles/blob/master/.config/dmenu/bemenucolors
|
|
|
|
readonly confdir=${XDG_CONFIG_HOME:-$HOME/.config}
|
|
|
|
|
|
|
|
readonly optsfile=$confdir/dmenu/bemenucolors
|
|
|
|
|
|
|
|
create_menu() {
|
|
|
|
# Check quickmarks
|
|
|
|
while read -r url; do
|
|
|
|
printf -- '%s\n' "$url"
|
2016-07-01 15:53:21 +02:00
|
|
|
done < "$QUTE_CONFIG_DIR"/quickmarks
|
2015-11-12 07:21:33 +01:00
|
|
|
|
|
|
|
# Next bookmarks
|
|
|
|
while read -r url _; do
|
|
|
|
printf -- '%s\n' "$url"
|
2016-07-01 15:53:21 +02:00
|
|
|
done < "$QUTE_CONFIG_DIR"/bookmarks/urls
|
2015-11-12 07:21:33 +01:00
|
|
|
|
|
|
|
# Finally history
|
|
|
|
while read -r _ url; do
|
|
|
|
printf -- '%s\n' "$url"
|
2016-07-01 15:53:21 +02:00
|
|
|
done < "$QUTE_DATA_DIR"/history
|
2015-11-12 07:21:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
get_selection() {
|
2015-11-17 15:52:02 +01:00
|
|
|
opts+=(-p qutebrowser)
|
2015-11-12 07:21:33 +01:00
|
|
|
#create_menu | dmenu -l 10 "${opts[@]}"
|
|
|
|
create_menu | bemenu -l 10 "${opts[@]}"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Main
|
|
|
|
# https://github.com/halfwit/dotfiles/blob/master/.config/dmenu/font
|
|
|
|
if [[ -s $confdir/dmenu/font ]]; then
|
|
|
|
read -r font < "$confdir"/dmenu/font
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $font ]]; then
|
|
|
|
opts+=(-fn "$font")
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -s $optsfile ]]; then
|
|
|
|
source "$optsfile"
|
|
|
|
fi
|
|
|
|
|
|
|
|
url=$(get_selection)
|
|
|
|
url=${url/*http/http}
|
|
|
|
|
|
|
|
# If no selection is made, exit (escape pressed, e.g.)
|
|
|
|
[[ ! $url ]] && exit 0
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
open) printf '%s' "open $url" >> "$QUTE_FIFO" || qutebrowser "$url" ;;
|
2015-11-17 16:41:20 +01:00
|
|
|
tab) printf '%s' "open -t $url" >> "$QUTE_FIFO" || qutebrowser "$url" ;;
|
2015-11-12 07:21:33 +01:00
|
|
|
esac
|