From 5359463d79abc31b0213519a2c15f007d2fcce56 Mon Sep 17 00:00:00 2001 From: Zach-Button Date: Tue, 21 Apr 2015 14:52:43 -0600 Subject: [PATCH 1/5] Add misc/userscripts - Added misc/userscripts/dmenu_qutebrowser - Added misc/userscripts/qutebrowser_viewsource --- misc/userscripts/dmenu_qutebrowser | 31 +++++++++++++++++++++++++ misc/userscripts/qutebrowser_viewsource | 13 +++++++++++ 2 files changed, 44 insertions(+) create mode 100755 misc/userscripts/dmenu_qutebrowser create mode 100755 misc/userscripts/qutebrowser_viewsource diff --git a/misc/userscripts/dmenu_qutebrowser b/misc/userscripts/dmenu_qutebrowser new file mode 100755 index 000000000..5da1d8462 --- /dev/null +++ b/misc/userscripts/dmenu_qutebrowser @@ -0,0 +1,31 @@ +#!/bin/bash + +# Pipes history, quickmarks, and URL into dmenu. +# +# If run from qutebrowser as a userscript, it runs :open on the URL +# If not, it opens a new qutebrowser window at the URL +# +# Ideal for use with tabs-are-windows. Set a hotkey to launch this script, then: +# :bind o spawn --userscript dmenu_qutebrowser +# +# Use the hotkey to open in new tab/window, press 'o' to open URL in current tab/window +# You can simulate "go" by pressing "o", as the current URL is always first in the list +# +# I personally use "q" to launch this script. For me, my workflow is: +# Default keys Keys with this script +# O q +# o o +# go o +# gO [ I haven't decided what to do with this yet ] +# + +url=$(echo "$QUTE_URL" | cat - ~/.local/share/qutebrowser/history ~/.config/qutebrowser/quickmarks | dmenu -l 15 -p qutebrowser) +url=$(echo $url | sed -E 's/[^ ]+ +//g' | egrep "https?:" || echo $url) + +[ -z "${url// }" ] && exit + +if [ -n "$QUTE_FIFO" ]; then + echo "open $url" >> "$QUTE_FIFO" +else + qutebrowser "$url" +fi diff --git a/misc/userscripts/qutebrowser_viewsource b/misc/userscripts/qutebrowser_viewsource new file mode 100755 index 000000000..891d09dce --- /dev/null +++ b/misc/userscripts/qutebrowser_viewsource @@ -0,0 +1,13 @@ +#!/bin/bash + +# +# This script fetches the unprocessed HTML source for a page and opens it in vim. +# :bind gf spawn --userscript qutebrowser_viewsource +# + +path=/tmp/qutebrowser-src_$(date "+%s") + +curl "$QUTE_URL" > $path +urxvt -e vim "$path" + +rm "$path" From 049955dfd5e32026c9eca7da45282b114737af90 Mon Sep 17 00:00:00 2001 From: Zach-Button Date: Tue, 21 Apr 2015 16:12:05 -0600 Subject: [PATCH 2/5] Change path to use mktemp Path now uses mktemp instead of timestamp --- misc/userscripts/qutebrowser_viewsource | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/userscripts/qutebrowser_viewsource b/misc/userscripts/qutebrowser_viewsource index 891d09dce..9175d43d2 100755 --- a/misc/userscripts/qutebrowser_viewsource +++ b/misc/userscripts/qutebrowser_viewsource @@ -5,7 +5,7 @@ # :bind gf spawn --userscript qutebrowser_viewsource # -path=/tmp/qutebrowser-src_$(date "+%s") +path=/tmp/qutebrowser_$(mktemp XXXXXXXX).html curl "$QUTE_URL" > $path urxvt -e vim "$path" From 205f37fe090b559019d2d16681d6ba4ab9e10232 Mon Sep 17 00:00:00 2001 From: Zach-Button Date: Fri, 24 Apr 2015 14:04:27 -0600 Subject: [PATCH 3/5] Update dmenu_qutebrowser --- misc/userscripts/dmenu_qutebrowser | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/misc/userscripts/dmenu_qutebrowser b/misc/userscripts/dmenu_qutebrowser index 5da1d8462..3a73cdde5 100755 --- a/misc/userscripts/dmenu_qutebrowser +++ b/misc/userscripts/dmenu_qutebrowser @@ -1,5 +1,22 @@ #!/bin/bash +# Copyright 2015 Zach-Button +# +# This file is part of qutebrowser. +# +# qutebrowser is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# qutebrowser is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with qutebrowser. If not, see . + # Pipes history, quickmarks, and URL into dmenu. # # If run from qutebrowser as a userscript, it runs :open on the URL @@ -16,7 +33,7 @@ # O q # o o # go o -# gO [ I haven't decided what to do with this yet ] +# gO gC, then o # url=$(echo "$QUTE_URL" | cat - ~/.local/share/qutebrowser/history ~/.config/qutebrowser/quickmarks | dmenu -l 15 -p qutebrowser) From 329030e913f01e17b2a6fe648378115173ab5b2a Mon Sep 17 00:00:00 2001 From: Zach-Button Date: Fri, 24 Apr 2015 14:05:27 -0600 Subject: [PATCH 4/5] Update qutebrowser_viewsource --- misc/userscripts/qutebrowser_viewsource | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/misc/userscripts/qutebrowser_viewsource b/misc/userscripts/qutebrowser_viewsource index 9175d43d2..0985297d7 100755 --- a/misc/userscripts/qutebrowser_viewsource +++ b/misc/userscripts/qutebrowser_viewsource @@ -1,9 +1,28 @@ #!/bin/bash +# Copyright 2015 Zach-Button +# +# This file is part of qutebrowser. +# +# qutebrowser is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# qutebrowser is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with qutebrowser. If not, see . + # # This script fetches the unprocessed HTML source for a page and opens it in vim. # :bind gf spawn --userscript qutebrowser_viewsource # +# Caveat: Does not use authentication of any kind. Add it in if you want it to. +# path=/tmp/qutebrowser_$(mktemp XXXXXXXX).html From d496ea2d59a9e17e7f426bb596254be1f8256380 Mon Sep 17 00:00:00 2001 From: Zach-Button Date: Tue, 28 Apr 2015 11:02:45 -0600 Subject: [PATCH 5/5] Update dmenu_qutebrowser --- misc/userscripts/dmenu_qutebrowser | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/misc/userscripts/dmenu_qutebrowser b/misc/userscripts/dmenu_qutebrowser index 3a73cdde5..36651e77a 100755 --- a/misc/userscripts/dmenu_qutebrowser +++ b/misc/userscripts/dmenu_qutebrowser @@ -28,21 +28,21 @@ # Use the hotkey to open in new tab/window, press 'o' to open URL in current tab/window # You can simulate "go" by pressing "o", as the current URL is always first in the list # -# I personally use "q" to launch this script. For me, my workflow is: +# I personally use "o" to launchq this script. For me, my workflow is: # Default keys Keys with this script -# O q +# O o # o o # go o # gO gC, then o +# (This is unnecessarily long. I use this rarely, feel free to make this script accept parameters.) # -url=$(echo "$QUTE_URL" | cat - ~/.local/share/qutebrowser/history ~/.config/qutebrowser/quickmarks | dmenu -l 15 -p qutebrowser) +[ -z "$QUTE_URL" ] && QUTE_URL='http://google.com' + +url=$(echo "$QUTE_URL" | cat - ~/.config/qutebrowser/quickmarks ~/.local/share/qutebrowser/history | dmenu -l 15 -p qutebrowser) url=$(echo $url | sed -E 's/[^ ]+ +//g' | egrep "https?:" || echo $url) [ -z "${url// }" ] && exit -if [ -n "$QUTE_FIFO" ]; then - echo "open $url" >> "$QUTE_FIFO" -else - qutebrowser "$url" -fi +echo "open $url" >> "$QUTE_FIFO" || qutebrowser "$url" +