Compare commits
No commits in common. "10cfc6b41764c3be40d4a4bb642b42fecd561763" and "668a9776ec7455c0e7e69a7d1b95b7d1e9f15afd" have entirely different histories.
10cfc6b417
...
668a9776ec
5 changed files with 148 additions and 199 deletions
|
@ -1930,19 +1930,3 @@ table#hnmain {
|
|||
#region-main {
|
||||
background-color: inherit;
|
||||
}
|
||||
/* python docs */
|
||||
div.document,
|
||||
div.body {
|
||||
background-color: inherit;
|
||||
color: inherit;
|
||||
}
|
||||
span.highlighted,
|
||||
div.body h1,
|
||||
div.body h2,
|
||||
div.body h3,
|
||||
div.body h4,
|
||||
div.body h5,
|
||||
div.body h6,
|
||||
{
|
||||
background-color: %base02% !important;
|
||||
}
|
||||
|
|
92
theme_dunst
92
theme_dunst
|
@ -2,13 +2,9 @@
|
|||
readonly dependency=("khamer/base16-dunst")
|
||||
readonly app="dunst"
|
||||
#
|
||||
# This configuration requires dunst version at least 1.8.0!
|
||||
#
|
||||
# Dunst now allows drop-in configuration files in a special
|
||||
# `dunstrc.d/` directory in the usual configuration directory.
|
||||
# That means we can drop in a specific `00-colorscheme.conf`
|
||||
# file instead of operating directly on the main dunst
|
||||
# configuration file.
|
||||
# Alacritty does not support including other files into
|
||||
# its configuration yet. As such, this processor needs to
|
||||
# change the user's configuration file *itself*.
|
||||
#
|
||||
# This will generally not be a problem, though it can lead
|
||||
# to corrupted configurations in exceptional circumstances
|
||||
|
@ -17,9 +13,9 @@ readonly app="dunst"
|
|||
#
|
||||
# In general, the processor looks for a specific line in the
|
||||
# following format:
|
||||
# '# Base16 [theme name] - dunst color config'
|
||||
# '# Base16 [theme name] - alacritty color config'
|
||||
# from which it will delete everything until it finds a line:
|
||||
# '# Base16End [theme name] - dunst color config'
|
||||
# '# Base16End [theme name] - alacritty color config'
|
||||
# So, if you don't want to lose anything -
|
||||
# Do NOT put anything important between those two lines.
|
||||
|
||||
|
@ -28,25 +24,28 @@ package="$2"
|
|||
theme="$3"
|
||||
permanent="$4"
|
||||
|
||||
dunst_conf_dir="$HOME/.config/dunst/dunstrc.d"
|
||||
dunst_conf="$dunst_conf_dir/00-colorscheme.conf"
|
||||
dunst_conf="$HOME/.config/dunst/dunstrc"
|
||||
|
||||
## Main Entrypoint
|
||||
#
|
||||
# Finds the right theme template file and starts theme
|
||||
# switching and, if necessary, permanent setting processes.
|
||||
main() {
|
||||
dbg_msg $app "Starting Processor"
|
||||
tfile="$path/$package/themes/base16-$theme.dunstrc"
|
||||
dbg_msg $app "Starting Processor"
|
||||
tfile="$path/$package/themes/base16-$theme.dunstrc"
|
||||
|
||||
if ! file_exists "$tfile"; then
|
||||
dbg_msg $app "error" "Theme template $theme not found in package $package"
|
||||
exit 1
|
||||
fi
|
||||
if ! file_exists "$tfile"; then
|
||||
dbg_msg $app "error" "Theme template $theme not found in package $package"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$permanent" == "true" ]]; then save; fi
|
||||
if [ ! -f "$dunst_conf" ]; then
|
||||
dbg_msg $app "error" "$app config file not found. Please make sure file exists: $dunst_conf"
|
||||
fi
|
||||
|
||||
dbg_msg $app "Processor Done"
|
||||
if [[ "$permanent" == "true" ]]; then save; fi
|
||||
|
||||
dbg_msg $app "Processor Done"
|
||||
}
|
||||
|
||||
## Theme setter
|
||||
|
@ -54,26 +53,51 @@ main() {
|
|||
# Takes care of permanently writing the desired
|
||||
# base16 theme into application settings.
|
||||
save() {
|
||||
dbg_msg $app "Saving theme"
|
||||
dbg_msg $app "Saving theme"
|
||||
|
||||
if [ ! -f "$dunst_conf" ]; then
|
||||
mkdir -p "$dunst_conf_dir"
|
||||
dbg_msg $app "$app colorscheme file not found. Creating new colorscheme file: $dunst_conf"
|
||||
fi
|
||||
startline="$(grep -ne '^# Base16 .*- dunst color config$' "$dunst_conf" | cut -f1 -d:)"
|
||||
endline="$(grep -ne '^# Base16End .*- dunst color config$' "$dunst_conf" | cut -f1 -d:)"
|
||||
|
||||
# fix template theme name key for easier inclusion
|
||||
echo "# Base16 $theme - dunst color config" >"$dunst_conf"
|
||||
cat "$tfile" >>"$dunst_conf" || exit 1
|
||||
echo "# Base16End $theme - dunst color config" >>"$dunst_conf"
|
||||
tmpfile="$dunst_conf.tmp"
|
||||
tmptheme="$dunst_conf.thm.tmp"
|
||||
echo "" >"$tmpfile"
|
||||
echo "" >"$tmptheme"
|
||||
|
||||
dbg_msg $app "Saved theme to $dunst_conf"
|
||||
if [[ -n "$startline" && -z "$endline" ]] || [[ -z "$startline" && -n "$endline" ]] || [[ "$startline" -gt "$endline" ]]; then
|
||||
dbg_msg $app "error" "Base 16 Pattern not correctly recognized in file: $dunst_conf. Please make sure pattern begins with # Base16 and ends with # Base16End and only exists once in the file. No changes to file made."
|
||||
cat "$dunst_conf" >"$tmpfile" || exit 1
|
||||
|
||||
save_post
|
||||
elif [[ -z "$startline" && -z "$endline" ]]; then
|
||||
dbg_msg $app "warn" "No previous Base16 pattern found in file: $dunst_conf. If this is your first time running the processor, ignore this warning."
|
||||
cat "$dunst_conf" >"$tmpfile" || exit 1
|
||||
|
||||
else
|
||||
# remove old lines of any base16 theme
|
||||
sed -e "$startline,$endline d" "$dunst_conf" >"$tmpfile" || exit 1
|
||||
|
||||
fi
|
||||
|
||||
# fix template theme name key for easier inclusion
|
||||
echo "# Base16 $theme - dunst color config" >"$tmptheme"
|
||||
cat "$tfile" >>"$tmptheme" || exit 1
|
||||
echo "# Base16End $theme - dunst color config" >>"$tmptheme"
|
||||
|
||||
# combine both into final config file
|
||||
# replace original file with new colorscheme-added version
|
||||
|
||||
cat "$tmpfile" "$tmptheme" >"$dunst_conf"
|
||||
|
||||
[ -f "$tmptheme" ] && rm "$tmptheme"
|
||||
[ -f "$tmpfile" ] && rm "$tmpfile"
|
||||
|
||||
dbg_msg $app "Saved theme to $dunst_conf"
|
||||
|
||||
save_post
|
||||
}
|
||||
|
||||
save_post() {
|
||||
pkill dunst
|
||||
dunst &
|
||||
pkill dunst
|
||||
dunst &
|
||||
}
|
||||
|
||||
# Safe sourcing: https://stackoverflow.com/a/12694189
|
||||
|
@ -86,7 +110,7 @@ if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
|
|||
# Makes sure the processor is called for the correct
|
||||
# base16 package, or refuses to run if it is not.
|
||||
if printf '%s\n' "${dependency[@]}" | grep -q -P "^$package$"; then
|
||||
main
|
||||
main
|
||||
else
|
||||
dbg_msg $app "error" "Processor does not work for package $package"
|
||||
dbg_msg $app "error" "Processor does not work for package $package"
|
||||
fi
|
||||
|
|
82
theme_kitty
82
theme_kitty
|
@ -1,82 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
readonly dependency=("kdrag0n/base16-kitty")
|
||||
readonly app="kitty"
|
||||
#
|
||||
# Kitty reads its theme from the `current-theme.conf` file
|
||||
# in its .config directory.
|
||||
|
||||
path="$1"
|
||||
package="$2"
|
||||
theme="$3"
|
||||
permanent="$4"
|
||||
|
||||
kitty_conf="$HOME/.config/kitty/kitty.conf"
|
||||
include_conf="$HOME/.config/kitty/current-theme.conf"
|
||||
|
||||
## Main Entrypoint
|
||||
#
|
||||
# Finds the right theme template file and starts theme
|
||||
# switching and, if necessary, permanent setting processes.
|
||||
main() {
|
||||
dbg_msg $app "Starting Processor"
|
||||
tfile="$path/$package/colors/base16-$theme.conf"
|
||||
|
||||
if ! file_exists "$tfile"; then
|
||||
dbg_msg $app "error" "Theme template $theme not found in package $package"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$kitty_conf" ]; then
|
||||
dbg_msg $app "error" "Alacritty config file not found. Please make sure file exists: $kitty_conf"
|
||||
fi
|
||||
|
||||
if [[ $permanent == "true" ]]; then save; fi
|
||||
theme
|
||||
|
||||
dbg_msg $app "Processor Done"
|
||||
}
|
||||
|
||||
## Theme switcher
|
||||
#
|
||||
# Makes sure that if any application instance is
|
||||
# currently running, it switches to new theme.
|
||||
theme() {
|
||||
:
|
||||
# currently needs to be done through ANSI theme processor.
|
||||
# May be doable with some invocation of kitty loading config files.
|
||||
# Probably needs kitty to run with remote execution enabled.
|
||||
}
|
||||
|
||||
## Theme setter
|
||||
#
|
||||
# Takes care of permanently writing the desired
|
||||
# base16 theme into application settings.
|
||||
save() {
|
||||
dbg_msg $app "Saving theme"
|
||||
|
||||
# replace colorscheme.yml content with new one
|
||||
cp "$tfile" "$include_conf"
|
||||
dbg_msg $app "Wrote theme file to $include_conf"
|
||||
|
||||
# find import line in alacritty conf
|
||||
if ! grep -qe "^include ${include_conf##*/}" "${kitty_conf}"; then
|
||||
printf "\ninclude %s\n" "${include_conf##*/}" >>"$kitty_conf"
|
||||
dbg_msg $app "Including theme file in imports"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
# Safe sourcing: https://stackoverflow.com/a/12694189
|
||||
DIR="${BASH_SOURCE%/*}"
|
||||
if [[ ! -d $DIR ]]; then DIR="$PWD"; fi
|
||||
# shellcheck source=utilities.sh
|
||||
. "$DIR/utilities.sh"
|
||||
## Dependency Checker
|
||||
#
|
||||
# Makes sure the processor is called for the correct
|
||||
# base16 package, or refuses to run if it is not.
|
||||
if printf '%s\n' "${dependency[@]}" | grep -q -P "^$package$"; then
|
||||
main
|
||||
else
|
||||
dbg_msg $app "error" "Processor does not work for package $package"
|
||||
fi
|
|
@ -12,18 +12,18 @@ readonly permanent="$4"
|
|||
# Finds the right theme template file and starts theme
|
||||
# switching and, if necessary, permanent setting processes.
|
||||
main() {
|
||||
dbg_msg $app "Starting Processor"
|
||||
tfile="$path/$package/themes/default/base16-$theme.config.py"
|
||||
dbg_msg $app "Starting Processor"
|
||||
tfile="$path/$package/themes/default/base16-$theme.config.py"
|
||||
|
||||
if ! file_exists "$tfile"; then
|
||||
dbg_msg $app "error" "Theme template $theme not found in package $package"
|
||||
exit 1
|
||||
fi
|
||||
if ! file_exists "$tfile"; then
|
||||
dbg_msg $app "error" "Theme template $theme not found in package $package"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $permanent == "true" ]]; then save; fi
|
||||
theme
|
||||
if [[ "$permanent" == "true" ]]; then save; fi
|
||||
theme
|
||||
|
||||
dbg_msg $app "Processor Done"
|
||||
dbg_msg $app "Processor Done"
|
||||
}
|
||||
|
||||
## Theme switcher
|
||||
|
@ -31,14 +31,14 @@ main() {
|
|||
# Makes sure that if any application instance is
|
||||
# currently running, it switches to new theme.
|
||||
theme() {
|
||||
dbg_msg $app "Switching theme"
|
||||
# make sure qutebrowser is running
|
||||
pgrep qutebrowser >/dev/null || {
|
||||
dbg_msg $app "warn" "No instance running, not switching theme"
|
||||
return
|
||||
}
|
||||
qutebrowser --loglevel error ":config-source $tfile"
|
||||
dbg_msg $app "Successfully switched theme"
|
||||
dbg_msg $app "Switching theme"
|
||||
# make sure qutebrowser is running
|
||||
pgrep qutebrowser >/dev/null || {
|
||||
dbg_msg $app "warn" "No instance running, not switching theme"
|
||||
return
|
||||
}
|
||||
qutebrowser --loglevel error ":config-source $tfile"
|
||||
dbg_msg $app "Successfully switched theme"
|
||||
}
|
||||
|
||||
## Theme setter
|
||||
|
@ -46,17 +46,17 @@ theme() {
|
|||
# Takes care of permanently writing the desired
|
||||
# base16 theme into application settings.
|
||||
save() {
|
||||
dbg_msg $app "Saving theme"
|
||||
local qt_dir="${XDG_CONFIG_HOME:-/$HOME/.config}/qutebrowser"
|
||||
dbg_msg $app "Saving theme"
|
||||
local qt_dir="${XDG_CONFIG_HOME:-/$HOME/.config}/qutebrowser"
|
||||
|
||||
if [[ -d $qt_dir ]]; then
|
||||
cat "$tfile" >"$qt_dir/colorscheme.py"
|
||||
dbg_msg $app "Saved theme to $qt_dir/colorscheme.py"
|
||||
if [[ -d "$qt_dir" ]]; then
|
||||
cat "$tfile" >"$qt_dir/colorscheme.py"
|
||||
dbg_msg $app "Saved theme to $qt_dir/colorscheme.py"
|
||||
|
||||
include "$qt_dir"
|
||||
else
|
||||
dbg_msg $app "warn" "No qutebrowser configuration directory found"
|
||||
fi
|
||||
include "$qt_dir"
|
||||
else
|
||||
dbg_msg $app "warn" "No qutebrowser configuration directory found"
|
||||
fi
|
||||
}
|
||||
|
||||
## Theme includer
|
||||
|
@ -66,20 +66,20 @@ save() {
|
|||
# This is the most invasive step of theming since it
|
||||
# rewrites within existing configuration files.
|
||||
include() {
|
||||
local qt_dir="$1"
|
||||
dbg_msg $app "Including theme in configuration"
|
||||
local qt_dir="$1"
|
||||
dbg_msg $app "Including theme in configuration"
|
||||
|
||||
if file_exists "$qt_dir/config.py"; then
|
||||
line_exists_or_append "$qt_dir/config.py" 'config.source("colorscheme.py")'
|
||||
dbg_msg $app "Successfully included theme in configuration"
|
||||
else
|
||||
dbg_msg $app "warn" "No default configuration file found"
|
||||
fi
|
||||
if file_exists "$qt_dir/config.py"; then
|
||||
line_exists_or_append "$qt_dir/config.py" "config.source('colorscheme.py')"
|
||||
dbg_msg $app "Successfully included theme in configuration"
|
||||
else
|
||||
dbg_msg $app "warn" "No default configuration file found"
|
||||
fi
|
||||
}
|
||||
|
||||
# Safe sourcing: https://stackoverflow.com/a/12694189
|
||||
DIR="${BASH_SOURCE%/*}"
|
||||
if [[ ! -d $DIR ]]; then DIR="$PWD"; fi
|
||||
if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
|
||||
# shellcheck source=utilities.sh
|
||||
. "$DIR/utilities.sh"
|
||||
## Dependency Checker
|
||||
|
@ -87,7 +87,7 @@ if [[ ! -d $DIR ]]; then DIR="$PWD"; fi
|
|||
# Makes sure the processor is called for the correct
|
||||
# base16 package, or refuses to run if it is not.
|
||||
if printf '%s\n' "${dependency[@]}" | grep -q -P "^$package$"; then
|
||||
main
|
||||
main
|
||||
else
|
||||
dbg_msg $app "error" "Processor does not work for package $package"
|
||||
dbg_msg $app "error" "Processor does not work for package $package"
|
||||
fi
|
||||
|
|
|
@ -2,11 +2,14 @@
|
|||
readonly dependency=("nicodebo/base16-zathura")
|
||||
readonly app="zathura"
|
||||
#
|
||||
# zathura now allows including other files into its
|
||||
# main configuration file. That means we can be less
|
||||
# intrusive about the colorscheme changes and only insert
|
||||
# the include line, adding any colorscheme options
|
||||
# in a completely different file.
|
||||
# zathura does not support including other files into
|
||||
# its configuration yet. As such, this processor needs to
|
||||
# change the user's configuration file *itself*.
|
||||
#
|
||||
# This will generally not be a problem, though it can lead
|
||||
# to corrupted configurations in exceptional circumstances
|
||||
# (such as every line being preceded by the process control
|
||||
# regex, for whatever reason).
|
||||
#
|
||||
# In general, the processor looks for a specific line in the
|
||||
# following format:
|
||||
|
@ -21,30 +24,28 @@ package="$2"
|
|||
theme="$3"
|
||||
permanent="$4"
|
||||
|
||||
zathura_conf_dir="$HOME/.config/zathura"
|
||||
zathuraconf="$zathura_conf_dir/zathurarc"
|
||||
colorscheme_filename="colorscheme"
|
||||
zathuraconf="$HOME/.config/zathura/zathurarc"
|
||||
|
||||
## Main Entrypoint
|
||||
#
|
||||
# Finds the right theme template file and starts theme
|
||||
# switching and, if necessary, permanent setting processes.
|
||||
main() {
|
||||
dbg_msg $app "Starting Processor"
|
||||
tfile="$path/$package/build_schemes/base16-$theme.config"
|
||||
dbg_msg $app "Starting Processor"
|
||||
tfile="$path/$package/build_schemes/base16-$theme.config"
|
||||
|
||||
if ! file_exists "$tfile"; then
|
||||
dbg_msg $app "error" "Theme template $theme not found in package $package"
|
||||
exit 1
|
||||
fi
|
||||
if ! file_exists "$tfile"; then
|
||||
dbg_msg $app "error" "Theme template $theme not found in package $package"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$zathuraconf" ]; then
|
||||
dbg_msg $app "error" "Zathura config file not found. Please make sure file exists: $zathuraconf"
|
||||
fi
|
||||
if [ ! -f "$zathuraconf" ]; then
|
||||
dbg_msg $app "error" "Zathura config file not found. Please make sure file exists: $zathuraconf"
|
||||
fi
|
||||
|
||||
if [[ "$permanent" == "true" ]]; then save; fi
|
||||
if [[ "$permanent" == "true" ]]; then save; fi
|
||||
|
||||
dbg_msg $app "Processor Done"
|
||||
dbg_msg $app "Processor Done"
|
||||
}
|
||||
|
||||
## Theme setter
|
||||
|
@ -52,18 +53,40 @@ main() {
|
|||
# Takes care of permanently writing the desired
|
||||
# base16 theme into application settings.
|
||||
save() {
|
||||
dbg_msg $app "Saving theme"
|
||||
dbg_msg $app "Saving theme"
|
||||
|
||||
if ! $(grep -qe "^include $colorscheme_filename" "$zathuraconf"); then
|
||||
dbg_msg $app "No include directive for colorscheme file found in configuration file. Adding it now."
|
||||
printf "\ninclude %s\n" "$colorscheme_filename" >>"$zathuraconf"
|
||||
else
|
||||
dbg_msg $app "Found include directive for colorscheme file. No operation necessary."
|
||||
fi
|
||||
# following format:
|
||||
# '# Base16 [theme name] - zathura color config'
|
||||
# from which it will delete everything until it finds a line:
|
||||
# '# Base16End [theme name] - zathura color config'
|
||||
startline="$(grep -ne '^# Base16 .*$' "$zathuraconf" | cut -f1 -d:)"
|
||||
endline="$(grep -ne '^# Base16End .*- zathura color config$' "$zathuraconf" | cut -f1 -d:)"
|
||||
|
||||
cat "$tfile" >"${zathura_conf_dir}/${colorscheme_filename}" || exit 1
|
||||
tmpfile="$zathuraconf.tmp"
|
||||
tmptheme="$zathuraconf.thm.tmp"
|
||||
|
||||
dbg_msg $app "Saved theme to ${zathura_conf_dir}/${colorscheme_filename}"
|
||||
if [[ -n "$startline" && -z "$endline" ]] || [[ -z "$startline" && -n "$endline" ]] || [[ "$startline" -gt "$endline" ]]; then
|
||||
dbg_msg $app "error" "Base 16 Pattern not correctly recognized in file: $zathuraconf. Please make sure pattern begins with # Base 16 and ends with # Base 16end and only exists once in the file. No changes to file made."
|
||||
|
||||
elif [[ -z "$startline" && -z "$endline" ]]; then
|
||||
cat "$zathuraconf" >"$tmpfile" || exit 1
|
||||
else
|
||||
# remove old lines of any base16 theme
|
||||
sed -e "$startline,$endline d" "$zathuraconf" >"$tmpfile" || exit 1
|
||||
|
||||
fi
|
||||
|
||||
# fix template theme name key for easier inclusion
|
||||
sed -e "s/^colors:/$theme: \&colorscheme/" "$tfile" >"$tmptheme" || exit 1
|
||||
echo "# Base16End $theme - zathura color config" >>"$tmptheme"
|
||||
|
||||
# combine both into final config file
|
||||
# replace original file with new colorscheme-added version
|
||||
cat "$tmptheme" "$tmpfile" >"$zathuraconf"
|
||||
|
||||
rm "$tmptheme" "$tmpfile"
|
||||
|
||||
dbg_msg $app "Saved theme to $zathuraconf"
|
||||
}
|
||||
|
||||
# Safe sourcing: https://stackoverflow.com/a/12694189
|
||||
|
@ -76,7 +99,7 @@ if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
|
|||
# Makes sure the processor is called for the correct
|
||||
# base16 package, or refuses to run if it is not.
|
||||
if printf '%s\n' "${dependency[@]}" | grep -q -P "^$package$"; then
|
||||
main
|
||||
main
|
||||
else
|
||||
dbg_msg $app "error" "Processor does not work for package $package"
|
||||
dbg_msg $app "error" "Processor does not work for package $package"
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue