From 8106c87633df027a5deaf4487fc7b0603d40b253 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 31 Jan 2020 12:21:41 +0100 Subject: [PATCH] Add example template for processor --- example_template | 75 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 example_template diff --git a/example_template b/example_template new file mode 100644 index 0000000..277b592 --- /dev/null +++ b/example_template @@ -0,0 +1,75 @@ +#!/usr/bin/env bash +readonly dependency=("username/base16-package") +readonly app="qutebrowser" + +path="$1" +package="$2" +theme="$3" +permanent="$4" + +## 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/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 [[ "$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() { + dbg_msg $app "Switching theme" + # switcheroo + dbg_msg $app "Successfully switched theme" +} + +## Theme setter +# +# Takes care of permanently writing the desired +# base16 theme into application settings. +save() { + dbg_msg $app "Saving theme" + # saveroo + dbg_msg $app "Sucessfully Saved theme" +} + +## Theme includer +# +# Makes sure that theme is actually included in +# default application startup routine. +# This is the most invasive step of theming since it +# rewrites within existing configuration files. +include() { + dbg_msg $app "Including theme in configuration" + # includeroo + dbg_msg $app "Sucessfully included theme" +} + +## 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 + # Safe sourcing: https://stackoverflow.com/a/12694189 + DIR="${BASH_SOURCE%/*}" + if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi + # shellcheck source=utilities.sh + . "$DIR/utilities.sh" + + theme_qutebrowser +else + dbg_msg $app "error" "Processor does not work for package $package" +fi