qutebrowser: Make use of dotter for dir structure
Since we now use dotter we can simplify the dir structure for qutebrowser a lot. Everything dot-filed earlier can now reside in simple directories called config (for ~/.config/qutebrowser), data (for ~/.local/share/qutebrowser), and scripts (for ~/.local/bin) files.
This commit is contained in:
parent
dcde027a67
commit
8681d34946
49 changed files with 9 additions and 5 deletions
60
qutebrowser/scripts/qutedmenu
Executable file
60
qutebrowser/scripts/qutedmenu
Executable file
|
|
@ -0,0 +1,60 @@
|
|||
#!/usr/bin/env bash
|
||||
# Open any of: quickmarks, bookmarks and browser history via dmenu (or rofi)
|
||||
# Handle open -s && open -t with bemenu
|
||||
#
|
||||
# Requires sqlite3 binary installed to traverse the history.
|
||||
|
||||
#:bind o spawn --userscript /path/to/userscripts/qutedmenu open
|
||||
#:bind O spawn --userscript /path/to/userscripts/qutedmenu tab
|
||||
|
||||
readonly confdir=${XDG_CONFIG_HOME:-$HOME/.config}
|
||||
readonly datadir=${XDG_DATA_HOME:-$HOME/.local/share}
|
||||
readonly optsfile=$confdir/dmenu/bemenucolors
|
||||
readonly QUTE_CONFIG_DIR="${QUTE_CONFIG_DIR:-$confdir/qutebrowser}"
|
||||
readonly QUTE_DATA_DIR="${QUTE_DATA_DIR:-$datadir/qutebrowser}"
|
||||
|
||||
create_menu() {
|
||||
# Check quickmarks
|
||||
while read -r url; do
|
||||
printf -- '%s\n' "$url"
|
||||
done <"$QUTE_CONFIG_DIR"/quickmarks
|
||||
|
||||
# Next bookmarks
|
||||
while read -r url _; do
|
||||
printf -- '%s\n' "$url"
|
||||
done <"$QUTE_CONFIG_DIR"/bookmarks/urls
|
||||
|
||||
# Finally history
|
||||
printf -- '%s\n' "$(sqlite3 -separator ' ' "$QUTE_DATA_DIR/history.sqlite" 'select title, url from CompletionHistory')"
|
||||
}
|
||||
|
||||
get_selection() {
|
||||
opts+=(-p qutebrowser)
|
||||
local launcher
|
||||
if exist bemenu; then
|
||||
launcher=bemenu
|
||||
elif exist dmenu; then
|
||||
launcher=dmenu
|
||||
fi
|
||||
create_menu | "$launcher" -l 10 "${opts[@]}"
|
||||
}
|
||||
|
||||
# Main
|
||||
# https://github.com/halfwit/dotfiles/blob/master/.config/dmenu/font
|
||||
[[ -s $confdir/dmenu/font ]] && read -r font <"$confdir"/dmenu/font
|
||||
|
||||
[[ -n $font ]] && opts+=(-fn "$font")
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
[[ -s $optsfile ]] && source "$optsfile"
|
||||
|
||||
url=$(get_selection)
|
||||
url=${url/*http/http}
|
||||
|
||||
# If no selection is made, exit (escape pressed, e.g.)
|
||||
[[ -z $url ]] && exit 0
|
||||
|
||||
case $1 in
|
||||
open) printf '%s' "open $url" >>"$QUTE_FIFO" || qutebrowser "$url" ;;
|
||||
tab | *) printf '%s' "open -t $url" >>"$QUTE_FIFO" || qutebrowser "$url" ;;
|
||||
esac
|
||||
Loading…
Add table
Add a link
Reference in a new issue