blob: b70d1c78d6b8d99fd5f06c80027d9002bdc4f2b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
#!/usr/bin/env sh
#
# See https://github.com/qutebrowser/qutebrowser/issues/572
# Thanks https://github.com/ayekat/dotfiles/blob/master/bin/qutebrowser
# Adapted to be sourced from another wrapper
# Wrapper around qutebrowser that makes sessions (-r, --restore SESSION) behave
# like they used to in dwb.
#
# We do so by filtering out the -r/--restore option passed to qutebrowser and
# using the argument to set up the following directory structure and symbolic
# links:
#
# $XDG_CACHE_HOME/qutebrowser/$session/cache → $XDG_CACHE_HOME/qutebrowser/$session
# $XDG_DATA_HOME/qutebrowser/$session/data → $XDG_DATA_HOME/qutebrowser/$session
# $XDG_CONFIG_HOME/qutebrowser/$session/config → $XDG_CONFIG_HOME/qutebrowser
# $XDG_RUNTIME_DIR/qutebrowser/$session/runtime (no symlink, regular directory)
#
# We then specify $XDG_RUNTIME_DIR/qutebrowser/$session as a --basedir, and the
# files will end up in their intended locations (notice how the config directory
# is the same for all sessions, as there is no point in keeping it separate).
#
# Written by ayekat in an burst of nostalgy, on a mildly cold wednesday night in
# February 2017.
#set -e
# Set default values for the variables as defined in the XDG base directory spec
# (https://specifications.freedesktop.org/basedir-spec/latest/):
XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
# Translate options: remove occurrences of -r/--restore from the list of
# command line arguments and save the session name for later; ignore -R (TODO):
session=default
basedir_specified=n
opts_read=0
while [ $opts_read -lt $# ]; do
opt="$1" && shift
case "$opt" in
(--basedir) basedir_specified=y ;;
(-r|-[!-]*r|--restore) test $# -gt 0 && session="$1" && shift && continue ;;
(-R) continue ;; # TODO
esac
set -- "$@" "$opt"
opts_read=$((opts_read + 1))
done
# Set up session base directory, unless --basedir has been specified by the
# user:
if [ "$basedir_specified" != 'y' ]; then
basedir="$XDG_RUNTIME_DIR/qutebrowser/$session"
set -- --basedir "$basedir" "$@"
mkdir -p \
"$basedir" \
"$XDG_CONFIG_HOME/qutebrowser" \
"$XDG_CACHE_HOME/qutebrowser/$session" \
"$XDG_DATA_HOME/qutebrowser/$session" \
"$basedir/runtime"
ln -fsT "$XDG_CONFIG_HOME/qutebrowser" "$basedir/config"
ln -fsT "$XDG_CACHE_HOME/qutebrowser/$session" "$basedir/cache"
ln -fsT "$XDG_DATA_HOME/qutebrowser/$session" "$basedir/data"
fi
## Run "real" qutebrowser executable:
#if [ "$(basename "$0")" != qutebrowser ]; then
# exec qutebrowser "$@"
#fi
#spath="$(readlink -f "$0")"
#IFS=:
#for p in $PATH; do
# epath="$p"/qutebrowser
# if [ -x "$epath" ] && [ "$(readlink -f "$epath")" != "$spath" ]; then
# exec "$epath" "$@"
# fi
#done
#echo 'command not found: qutebrowser' >&2
#exit 127
|