This commit is contained in:
Sander 2026-01-07 16:35:52 -08:00 committed by GitHub
commit ff03f7fa09
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 33 additions and 17 deletions

View File

@ -3,6 +3,8 @@
#:bind o spawn --userscript /path/to/userscripts/qutedmenu open
#:bind O spawn --userscript /path/to/userscripts/qutedmenu tab
#:bind wo spawn --userscript /path/to/userscripts/qutedmenu window
#:bind po spawn --userscript /path/to/userscripts/qutedmenu private
# If you would like to set a custom colorscheme/font use these dirs.
# https://github.com/halfwit/dotfiles/blob/master/.config/dmenu/bemenucolors
@ -12,6 +14,13 @@ readonly confdir=${XDG_CONFIG_HOME:-$HOME/.config}
readonly optsfile=$confdir/dmenu/bemenucolors
create_menu() {
opts+=(-p qutebrowser -l 10)
dmenu "${opts[@]}"
# bemenu "${opts[@]}"
# rofi -dmenu -kb-custom-1 "<Alt>d" "${opts[@]}"
}
create_menu_items() {
# Check quickmarks
while read -r url; do
printf -- '%s\n' "$url"
@ -23,13 +32,8 @@ create_menu() {
done < "$QUTE_CONFIG_DIR"/bookmarks/urls
# Finally history
printf -- '%s\n' "$(sqlite3 -separator ' ' "$QUTE_DATA_DIR/history.sqlite" 'select title, url from CompletionHistory ORDER BY last_atime DESC')"
}
get_selection() {
opts+=(-p qutebrowser)
create_menu | dmenu -l 10 "${opts[@]}"
#create_menu | bemenu -l 10 "${opts[@]}"
printf -- '%s\n' "$(sqlite3 -separator ' ' "$QUTE_DATA_DIR/history.sqlite" \
'select title, url from CompletionHistory ORDER BY last_atime DESC')"
}
# Main
@ -41,15 +45,27 @@ get_selection() {
# shellcheck source=/dev/null
[[ -s $optsfile ]] && source "$optsfile"
url=$(get_selection)
url=${url/*http/http}
while true; do
selection=$(create_menu_items | create_menu)
exit_code=$?
url=${selection/*http/http}
# If no selection is made, exit (escape pressed, e.g.)
[[ -z $url ]] && exit 0
# 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" ;;
window) printf '%s' "open -w $url" >> "$QUTE_FIFO" || qutebrowser "$url --target window" ;;
private) printf '%s' "open -p $url" >> "$QUTE_FIFO" || qutebrowser "$url --target private-window" ;;
esac
# Remove the corresponding history item if the menu exits with code 10
if [[ $exit_code -eq 10 ]]; then
sqlite3 "$QUTE_DATA_DIR/history.sqlite" \
"DELETE FROM CompletionHistory WHERE url='$url';"
continue
fi
# Normal selection → open and exit
case $1 in
open) printf '%s' "open $url" >> "$QUTE_FIFO" || qutebrowser "$url" ;;
tab) printf '%s' "open -t $url" >> "$QUTE_FIFO" || qutebrowser "$url" ;;
window) printf '%s' "open -w $url" >> "$QUTE_FIFO" || qutebrowser "$url --target window" ;;
private) printf '%s' "open -p $url" >> "$QUTE_FIFO" || qutebrowser "$url --target private-window" ;;
esac
exit 0
done