diff --git a/styler/.local/bin/styler b/styler/.local/bin/styler index 24ae60e..912079c 100755 --- a/styler/.local/bin/styler +++ b/styler/.local/bin/styler @@ -5,13 +5,16 @@ readonly BASE_PATH="${STYLER_DATA_PATH:-${XDG_DATA_HOME:-$HOME/.local/share}/sty readonly PACKAGE_PATH="$BASE_PATH/packages" readonly PROCESSOR_PATH="$BASE_PATH/processors" -readonly VERSION="0.2.4" +readonly VERSION="0.3.0" main() { local cmd="" local ret=0 case "$1" in + -t | --theme | theme) + cmd="switch_theme" + ;; -s | --set | set) cmd="set_theme" ;; @@ -46,7 +49,11 @@ usage() { "" \ " Options:" \ "" \ + " -t | theme Temporarily switch theme. Use any valid base16 theme name (without base16- prefix)." \ + " Theme will be lost upon restart, or application restarts." \ + "" \ " -s | set Set the theme. Use any valid base16 theme name (without base16- prefix)." \ + " Same as 'theme' option, but changes will be made permanent." \ "" \ " -d | download Download a base16 template into the package directory or download a processor16" \ " into the processor directory. Use user/repo format to automatically pull from github." \ @@ -105,8 +112,15 @@ get_themes() { echo "$themes" | sed "s/.*\\/base16-//" | sed "s/\\..*//" | sort | uniq } +# temporarily switch theme, same thing as setting, only with permanence flag turned off for processors +switch_theme() { + set_theme "$1" "false" +} + +# call processors for all installed packages set_theme() { local theme="$1" + local permanent="${2:-true}" local packages packages="$(get_packages)" @@ -134,7 +148,7 @@ set_theme() { # Compares application extension with existing processors and runs the appropriate processor if found processor=$(find "$PROCESSOR_PATH" -type f -name "theme_$appext") if [[ -f "$processor" ]]; then - "$processor" "$PACKAGE_PATH" "$pkg" "$theme" + "$processor" "$PACKAGE_PATH" "$pkg" "$theme" "$permanent" else printf "WARN: No processor found for application %s in %s. Make sure you install a processor for the application.\n" "$appext" "$PROCESSOR_PATH/" >&2 fi