Merge branch 'blyxxyz-userscript_vars'

This commit is contained in:
Florian Bruhin 2016-07-06 13:26:58 +02:00
commit 80238ec2ac
7 changed files with 22 additions and 12 deletions

View File

@ -169,13 +169,13 @@ Contributors, sorted by the number of commits in descending order:
* ZDarian * ZDarian
* Milan Svoboda * Milan Svoboda
* John ShaggyTwoDope Jenkins * John ShaggyTwoDope Jenkins
* Jan Verbeek
* Peter Vilim * Peter Vilim
* Clayton Craft * Clayton Craft
* Oliver Caldwell * Oliver Caldwell
* Jonas Schürmann * Jonas Schürmann
* error800 * error800
* Liam BEGUIN * Liam BEGUIN
* Jan Verbeek
* skinnay * skinnay
* Zach-Button * Zach-Button
* Tomasz Kramkowski * Tomasz Kramkowski

View File

@ -33,6 +33,9 @@ The following environment variables will be set when a userscript is launched:
- `QUTE_FIFO`: The FIFO or file to write commands to. - `QUTE_FIFO`: The FIFO or file to write commands to.
- `QUTE_HTML`: Path of a file containing the HTML source of the current page. - `QUTE_HTML`: Path of a file containing the HTML source of the current page.
- `QUTE_TEXT`: Path of a file containing the plaintext of the current page. - `QUTE_TEXT`: Path of a file containing the plaintext of the current page.
- `QUTE_CONFIG_DIR`: Path of the directory containing qutebrowser's configuration.
- `QUTE_DATA_DIR`: Path of the directory containing qutebrowser's data.
- `QUTE_DOWNLOAD_DIR`: Path of the downloads directory.
In `command` mode: In `command` mode:

View File

@ -39,10 +39,9 @@
[ -z "$QUTE_URL" ] && QUTE_URL='http://google.com' [ -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 "$QUTE_URL" | cat - "$QUTE_CONFIG_DIR/quickmarks" "$QUTE_DATA_DIR/history" | dmenu -l 15 -p qutebrowser)
url=$(echo $url | sed -E 's/[^ ]+ +//g' | egrep "https?:" || echo $url) url=$(echo "$url" | sed -E 's/[^ ]+ +//g' | egrep "https?:" || echo "$url")
[ -z "${url// }" ] && exit [ -z "${url// }" ] && exit
echo "open $url" >> "$QUTE_FIFO" || qutebrowser "$url" echo "open $url" >> "$QUTE_FIFO" || qutebrowser "$url"

View File

@ -19,6 +19,7 @@
# Any feedback is welcome! # Any feedback is welcome!
# open a file from the download directory using rofi # open a file from the download directory using rofi
DOWNLOAD_DIR=${DOWNLOAD_DIR:-$QUTE_DOWNLOAD_DIR}
DOWNLOAD_DIR=${DOWNLOAD_DIR:-$HOME/Downloads} DOWNLOAD_DIR=${DOWNLOAD_DIR:-$HOME/Downloads}
# the name of the rofi command # the name of the rofi command
ROFI_CMD=${ROFI_CMD:-rofi} ROFI_CMD=${ROFI_CMD:-rofi}
@ -49,7 +50,7 @@ die() {
if ! [ -d "$DOWNLOAD_DIR" ] ; then if ! [ -d "$DOWNLOAD_DIR" ] ; then
die "Download directory »$DOWNLOAD_DIR« not found!" die "Download directory »$DOWNLOAD_DIR« not found!"
fi fi
if ! $(which "${ROFI_CMD}" > /dev/null ) ; then if ! which "${ROFI_CMD}" > /dev/null ; then
die "Rofi command »${ROFI_CMD}« not found in PATH!" die "Rofi command »${ROFI_CMD}« not found in PATH!"
fi fi
@ -109,5 +110,3 @@ fi
msg info "Opening »$file« (of type $filetype) with ${application%.desktop}" msg info "Opening »$file« (of type $filetype) with ${application%.desktop}"
xdg-open "$path" & xdg-open "$path" &

View File

@ -17,7 +17,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>. # along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
# #
# This script fetches the unprocessed HTML source for a page and opens it in vim. # This script fetches the unprocessed HTML source for a page and opens it in vim.
# :bind gf spawn --userscript qutebrowser_viewsource # :bind gf spawn --userscript qutebrowser_viewsource
# #

View File

@ -7,7 +7,6 @@
# If you would like to set a custom colorscheme/font use these dirs. # If you would like to set a custom colorscheme/font use these dirs.
# https://github.com/halfwit/dotfiles/blob/master/.config/dmenu/bemenucolors # https://github.com/halfwit/dotfiles/blob/master/.config/dmenu/bemenucolors
readonly confdir=${XDG_CONFIG_HOME:-$HOME/.config} readonly confdir=${XDG_CONFIG_HOME:-$HOME/.config}
readonly datadir=${XDG_DATA_HOME:-$HOME/.local/share}
readonly optsfile=$confdir/dmenu/bemenucolors readonly optsfile=$confdir/dmenu/bemenucolors
@ -15,17 +14,17 @@ create_menu() {
# Check quickmarks # Check quickmarks
while read -r url; do while read -r url; do
printf -- '%s\n' "$url" printf -- '%s\n' "$url"
done < "$confdir"/qutebrowser/quickmarks done < "$QUTE_CONFIG_DIR"/quickmarks
# Next bookmarks # Next bookmarks
while read -r url _; do while read -r url _; do
printf -- '%s\n' "$url" printf -- '%s\n' "$url"
done < "$confdir"/qutebrowser/bookmarks/urls done < "$QUTE_CONFIG_DIR"/bookmarks/urls
# Finally history # Finally history
while read -r _ url; do while read -r _ url; do
printf -- '%s\n' "$url" printf -- '%s\n' "$url"
done < "$datadir"/qutebrowser/history done < "$QUTE_DATA_DIR"/history
} }
get_selection() { get_selection() {

View File

@ -29,6 +29,7 @@ from qutebrowser.utils import message, log, objreg, standarddir
from qutebrowser.commands import runners, cmdexc from qutebrowser.commands import runners, cmdexc
from qutebrowser.config import config from qutebrowser.config import config
from qutebrowser.misc import guiprocess from qutebrowser.misc import guiprocess
from qutebrowser.browser.webkit import downloads
class _QtFIFOReader(QObject): class _QtFIFOReader(QObject):
@ -376,6 +377,15 @@ def run(cmd, *args, win_id, env, verbose=False):
user_agent = config.get('network', 'user-agent') user_agent = config.get('network', 'user-agent')
if user_agent is not None: if user_agent is not None:
env['QUTE_USER_AGENT'] = user_agent env['QUTE_USER_AGENT'] = user_agent
config_dir = standarddir.config()
if config_dir is not None:
env['QUTE_CONFIG_DIR'] = config_dir
data_dir = standarddir.data()
if data_dir is not None:
env['QUTE_DATA_DIR'] = data_dir
download_dir = downloads.download_dir()
if download_dir is not None:
env['QUTE_DOWNLOAD_DIR'] = download_dir
cmd_path = os.path.expanduser(cmd) cmd_path = os.path.expanduser(cmd)
# if cmd is not given as an absolute path, look it up # if cmd is not given as an absolute path, look it up