Add and use $QUTE_DATA_DIR, $QUTE_DOWNLOAD_DIR

Also fix a few small issues in the userscripts like unquoted variables
and trailing whitespace.
This commit is contained in:
Jan Verbeek 2016-07-01 15:53:21 +02:00
parent 980cf5ada1
commit cc67dba9f1
5 changed files with 15 additions and 11 deletions

View File

@ -39,10 +39,9 @@
[ -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)
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")
[ -z "${url// }" ] && exit
echo "open $url" >> "$QUTE_FIFO" || qutebrowser "$url"

View File

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

View File

@ -17,7 +17,7 @@
# You should have received a copy of the GNU General Public License
# 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.
# :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.
# https://github.com/halfwit/dotfiles/blob/master/.config/dmenu/bemenucolors
readonly confdir=${XDG_CONFIG_HOME:-$HOME/.config}
readonly datadir=${XDG_DATA_HOME:-$HOME/.local/share}
readonly optsfile=$confdir/dmenu/bemenucolors
@ -15,17 +14,17 @@ create_menu() {
# Check quickmarks
while read -r url; do
printf -- '%s\n' "$url"
done < "$confdir"/qutebrowser/quickmarks
done < "$QUTE_CONFIG_DIR"/quickmarks
# Next bookmarks
while read -r url _; do
printf -- '%s\n' "$url"
done < "$confdir"/qutebrowser/bookmarks/urls
done < "$QUTE_CONFIG_DIR"/bookmarks/urls
# Finally history
while read -r _ url; do
printf -- '%s\n' "$url"
done < "$datadir"/qutebrowser/history
done < "$QUTE_DATA_DIR"/history
}
get_selection() {

View File

@ -29,6 +29,7 @@ from qutebrowser.utils import message, log, objreg, standarddir
from qutebrowser.commands import runners, cmdexc
from qutebrowser.config import config
from qutebrowser.misc import guiprocess
from qutebrowser.browser.webkit import downloads
class _QtFIFOReader(QObject):
@ -379,6 +380,12 @@ def run(cmd, *args, win_id, env, verbose=False):
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)
# if cmd is not given as an absolute path, look it up