#!/bin/zsh # This script is modeled after Omarchy's omarchy-theme-set script and my theme-switching # approach is modeled after Omarchy's theme-switching approach. # (See: https://github.com/basecamp/omarchy) # Omarchy is licensed under the MIT License. See the original LICENSE file for details at: # https://github.com/basecamp/omarchy/blob/master/LICENSE # Copyright (c) David Heinemeier Hansson ########################################################################################## theme_update_terminal() { case "$TERMINAL" in ("havoc" | "foot") echo "TODO: theme update for havoc or foot not yet implemented" ;; ("kitty") killall -SIGUSR1 kitty ;; esac } theme_update_tmux() { tmux source-file $DIR_THEME_SETTINGS/.current-theme/tmux.conf } theme_update_neovim() { nvim_stdpath_run=$(dirname $( nvim -l <(echo "vim.cmd.echo('stdpath(\"run\")')") > /dev/stdout 2>&1 )) find "$nvim_stdpath_run" -type s -name "nvim*" 2> /dev/null | while IFS= read -r nvim_server; do timeout 2s nvim --server "$nvim_server" \ --remote-expr "execute('lua ThemeUpdate()')" \ > /dev/null 2>&1 done } theme_update_browser() { policy='BrowserThemeColor' color_hex=$( printf '#%02x%02x%02x' $( cat $DIR_THEME_SETTINGS/.current-theme/brave.theme | tr ',' ' ' ) ) [[ "$OSTYPE" != *"darwin"* ]] && { echo "{\"$policy\": \"$color_hex\"}" > "/etc/brave/policies/managed/color.json" } || { # currently not working, property is set and seen by brave, but colors are not # actually applied, leaving here as is for now; TODO: fix or just remove defaults write com.brave.browser $policy -string "$color_hex" } brave --refresh-platform-policy --no-startup-window > /dev/null } [[ ! -z $1 ]] && raw_target="$1" || raw_target=$( find $DIR_THEME_SETTINGS -mindepth 1 -maxdepth 1 -type d -exec basename -- {} \; | fzf ) target_theme="$DIR_THEME_SETTINGS/$(echo $raw_target | tr ' ' '-' | tr '[:upper:]' '[:lower:]')" [[ ! -d "$target_theme" ]] && echo "theme not found: $target_theme" && exit 1 ln -snf "$target_theme" $DIR_THEME_SETTINGS/.current-theme theme_update_terminal theme_update_tmux theme_update_neovim & theme_update_browser # theme_update_obsidian # TODO: decide if theming beyond transparency is worth it, if so, implement # theme_update_reaper # TODO: implement # theme_update_mutt # TODO: possible and actually desired? theme-update-wallpaper "zz-default-for-theme" &