From 0c26e8fa43207710cf5bc381177f557f613bfca2 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Wed, 31 Mar 2021 09:42:30 -0500 Subject: [PATCH] Adding qutebrowser searching with rofi --- awesome/keybindings.fnl | 2 ++ mpv/mpv.conf | 1 + qutebrowser/config.py | 2 +- scripts/dmqute | 59 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 1 deletion(-) create mode 100755 scripts/dmqute diff --git a/awesome/keybindings.fnl b/awesome/keybindings.fnl index bab59e2..8d79791 100644 --- a/awesome/keybindings.fnl +++ b/awesome/keybindings.fnl @@ -155,6 +155,8 @@ {:description "launch rofi bitwarden selector" :group "launcher"}) (awful.key [modkey] "y" (fn [] (awful.spawn "yt -r")) {:description "search youtube" :group "launcher"}) + (awful.key [modkey] "q" (fn [] (awful.spawn "dmqute")) + {:description "search internet through qutebrowser" :group "launcher"}) ;; audio (awful.key [modkey] "a" (fn [] (awful.spawn "alacritty --class pulsemixer -e pulsemixer")) {:description "launch pulsemixer" :group "audio"}) diff --git a/mpv/mpv.conf b/mpv/mpv.conf index 42816dd..62b2627 100644 --- a/mpv/mpv.conf +++ b/mpv/mpv.conf @@ -6,5 +6,6 @@ autofit=75% geometry=50%:50% input-ipc-server="/tmp/mpvsocket" hwdec=auto +rtsp-transport=udp ytdl-format=bestvideo[height<=?720][fps<=?30]+bestaudio/best diff --git a/qutebrowser/config.py b/qutebrowser/config.py index 4caee3e..64c42f2 100644 --- a/qutebrowser/config.py +++ b/qutebrowser/config.py @@ -814,7 +814,7 @@ c.colors.webpage.darkmode.policy.page = "smart" ## Force `prefers-color-scheme: dark` colors for websites. ## Type: Bool -c.colors.webpage.prefered_color_scheme = dark +#c.colors.webpage.prefered_color_scheme = "dark" ## Number of commands to save in the command history. 0: no history / -1: ## unlimited diff --git a/scripts/dmqute b/scripts/dmqute new file mode 100755 index 0000000..b48f386 --- /dev/null +++ b/scripts/dmqute @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +# +# Script name: dmqute +# Description: Search your qutebrowswer bookmarks and quickmarks. +# Dependencies: dmenu, qutebrowser +# GitLab: https://www.gitlab.com/dwt1/dmscripts +# License: https://www.gitlab.com/dwt1/dmscripts/LICENSE +# Contributors: Derek Taylor + +if [ $(hostname) = "chris-linuxlaptop" ]; then + style="laptop" + #echo "this is hidpi" +else + style="desktop" + #echo "this is not hidpi" +fi + +# Defining location of bookmarks file +BMFILE="$HOME/.config/qutebrowser/bookmarks/urls" + +# Defining location of quickmarks file +QMFILE="$HOME/.config/qutebrowser/quickmarks" + +# Defining location of history database +HISTDB="$HOME/.local/share/qutebrowser/history.sqlite" + +# A separator that will appear in between quickmarks, bookmarks and history urls. +SEPARATOR="----------" + +# Read array of options to choose. +readarray -t bmarks < "$BMFILE" +readarray -t qmarks < "$QMFILE" + +# Sort the bookmark, quickmark and history lists so that the url is the last field. +# We will awk print the last field later. +# History list is formed by grep'ing "http" from the history table. +bmlist=$(printf '%s\n' "${bmarks[@]}" | awk '{print $2" - "$1}') +qmlist=$(printf '%s\n' "${qmarks[@]}" | awk '{print "["$1"] - "$NF}' | sort) +SQL="SELECT h.title, h.url FROM history as h where url like 'http%';" +histlist=$(printf '%s\n' "$(sqlite3 "$HISTDB" "${SQL}")" | awk -F "|" '{print $1" - "$NF}') + +# Piping the above lists into dmenu. +# We use "printf '%s\n'" to format the array one item to a line. +# The urls are listed quickmarks first, then the SEPARATOR, and then bookmarks. +choice=$(printf '%s\n' "$qmlist" "$SEPARATOR" "$bmlist" "$SEPARATOR" "$histlist" | rofi -font "VictorMono Nerd Font 30.0" -dmenu -p 'Qutebrowser open:') "$@" || exit + +# What to do if the separator is chosen from the list. +# We simply launch qutebrowser without any url arguments. +# shellcheck disable=SC2154 +if [ "$choice" == "$SEPARATOR" ]; then + qutebrowser +# What to do when/if we choose a url to view. +elif [ "$choice" ]; then + url=$(echo "${choice}" | awk '{print $NF}') || exit + qutebrowser "$url" +# What to do if we just escape without choosing anything. +else + echo "Program terminated." && exit 0 +fi