Fix qutebrowser quoting and formatting
This commit is contained in:
parent
3d45d759d8
commit
12474e85dd
1 changed files with 37 additions and 37 deletions
|
@ -12,18 +12,18 @@ readonly permanent="$4"
|
||||||
# Finds the right theme template file and starts theme
|
# Finds the right theme template file and starts theme
|
||||||
# switching and, if necessary, permanent setting processes.
|
# switching and, if necessary, permanent setting processes.
|
||||||
main() {
|
main() {
|
||||||
dbg_msg $app "Starting Processor"
|
dbg_msg $app "Starting Processor"
|
||||||
tfile="$path/$package/themes/default/base16-$theme.config.py"
|
tfile="$path/$package/themes/default/base16-$theme.config.py"
|
||||||
|
|
||||||
if ! file_exists "$tfile"; then
|
if ! file_exists "$tfile"; then
|
||||||
dbg_msg $app "error" "Theme template $theme not found in package $package"
|
dbg_msg $app "error" "Theme template $theme not found in package $package"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$permanent" == "true" ]]; then save; fi
|
if [[ $permanent == "true" ]]; then save; fi
|
||||||
theme
|
theme
|
||||||
|
|
||||||
dbg_msg $app "Processor Done"
|
dbg_msg $app "Processor Done"
|
||||||
}
|
}
|
||||||
|
|
||||||
## Theme switcher
|
## Theme switcher
|
||||||
|
@ -31,14 +31,14 @@ main() {
|
||||||
# Makes sure that if any application instance is
|
# Makes sure that if any application instance is
|
||||||
# currently running, it switches to new theme.
|
# currently running, it switches to new theme.
|
||||||
theme() {
|
theme() {
|
||||||
dbg_msg $app "Switching theme"
|
dbg_msg $app "Switching theme"
|
||||||
# make sure qutebrowser is running
|
# make sure qutebrowser is running
|
||||||
pgrep qutebrowser >/dev/null || {
|
pgrep qutebrowser >/dev/null || {
|
||||||
dbg_msg $app "warn" "No instance running, not switching theme"
|
dbg_msg $app "warn" "No instance running, not switching theme"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
qutebrowser --loglevel error ":config-source $tfile"
|
qutebrowser --loglevel error ":config-source $tfile"
|
||||||
dbg_msg $app "Successfully switched theme"
|
dbg_msg $app "Successfully switched theme"
|
||||||
}
|
}
|
||||||
|
|
||||||
## Theme setter
|
## Theme setter
|
||||||
|
@ -46,17 +46,17 @@ theme() {
|
||||||
# Takes care of permanently writing the desired
|
# Takes care of permanently writing the desired
|
||||||
# base16 theme into application settings.
|
# base16 theme into application settings.
|
||||||
save() {
|
save() {
|
||||||
dbg_msg $app "Saving theme"
|
dbg_msg $app "Saving theme"
|
||||||
local qt_dir="${XDG_CONFIG_HOME:-/$HOME/.config}/qutebrowser"
|
local qt_dir="${XDG_CONFIG_HOME:-/$HOME/.config}/qutebrowser"
|
||||||
|
|
||||||
if [[ -d "$qt_dir" ]]; then
|
if [[ -d $qt_dir ]]; then
|
||||||
cat "$tfile" >"$qt_dir/colorscheme.py"
|
cat "$tfile" >"$qt_dir/colorscheme.py"
|
||||||
dbg_msg $app "Saved theme to $qt_dir/colorscheme.py"
|
dbg_msg $app "Saved theme to $qt_dir/colorscheme.py"
|
||||||
|
|
||||||
include "$qt_dir"
|
include "$qt_dir"
|
||||||
else
|
else
|
||||||
dbg_msg $app "warn" "No qutebrowser configuration directory found"
|
dbg_msg $app "warn" "No qutebrowser configuration directory found"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
## Theme includer
|
## Theme includer
|
||||||
|
@ -66,20 +66,20 @@ save() {
|
||||||
# This is the most invasive step of theming since it
|
# This is the most invasive step of theming since it
|
||||||
# rewrites within existing configuration files.
|
# rewrites within existing configuration files.
|
||||||
include() {
|
include() {
|
||||||
local qt_dir="$1"
|
local qt_dir="$1"
|
||||||
dbg_msg $app "Including theme in configuration"
|
dbg_msg $app "Including theme in configuration"
|
||||||
|
|
||||||
if file_exists "$qt_dir/config.py"; then
|
if file_exists "$qt_dir/config.py"; then
|
||||||
line_exists_or_append "$qt_dir/config.py" "config.source('colorscheme.py')"
|
line_exists_or_append "$qt_dir/config.py" 'config.source("colorscheme.py")'
|
||||||
dbg_msg $app "Successfully included theme in configuration"
|
dbg_msg $app "Successfully included theme in configuration"
|
||||||
else
|
else
|
||||||
dbg_msg $app "warn" "No default configuration file found"
|
dbg_msg $app "warn" "No default configuration file found"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Safe sourcing: https://stackoverflow.com/a/12694189
|
# Safe sourcing: https://stackoverflow.com/a/12694189
|
||||||
DIR="${BASH_SOURCE%/*}"
|
DIR="${BASH_SOURCE%/*}"
|
||||||
if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
|
if [[ ! -d $DIR ]]; then DIR="$PWD"; fi
|
||||||
# shellcheck source=utilities.sh
|
# shellcheck source=utilities.sh
|
||||||
. "$DIR/utilities.sh"
|
. "$DIR/utilities.sh"
|
||||||
## Dependency Checker
|
## Dependency Checker
|
||||||
|
@ -87,7 +87,7 @@ if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
|
||||||
# Makes sure the processor is called for the correct
|
# Makes sure the processor is called for the correct
|
||||||
# base16 package, or refuses to run if it is not.
|
# base16 package, or refuses to run if it is not.
|
||||||
if printf '%s\n' "${dependency[@]}" | grep -q -P "^$package$"; then
|
if printf '%s\n' "${dependency[@]}" | grep -q -P "^$package$"; then
|
||||||
main
|
main
|
||||||
else
|
else
|
||||||
dbg_msg $app "error" "Processor does not work for package $package"
|
dbg_msg $app "error" "Processor does not work for package $package"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue