Add theme-set/switching logic, and minor nvim, tmux, obsidian changes
This commit is contained in:
34
src_files/.local/scripts/theme-set
Executable file
34
src_files/.local/scripts/theme-set
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/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
|
||||
|
||||
##########################################################################################
|
||||
|
||||
[[ ! -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 -sF "$target_theme" $DIR_THEME_SETTINGS/.current-theme
|
||||
|
||||
theme-update-terminal
|
||||
theme-update-tmux
|
||||
theme-update-neovim &
|
||||
# theme-update-obsidian # TODO: implement
|
||||
# theme-update-browser # TODO: implement
|
||||
# theme-update-reaper # TODO: implement
|
||||
theme-update-system-monitor # TODO: do i actually want this? or just use htop monochrome mode and let it use terminal colors
|
||||
# theme-update-gimp # TODO: possible and actually desired? my main use case is just a blackboard, maybe let it be
|
||||
# theme-update-mutt # TODO: possible and actually desired?
|
||||
# theme-update-irc # TODO: possible and actually desired?
|
||||
|
||||
theme-update-wallpaper &
|
||||
10
src_files/.local/scripts/theme-update-neovim
Executable file
10
src_files/.local/scripts/theme-update-neovim
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/zsh
|
||||
|
||||
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
|
||||
|
||||
7
src_files/.local/scripts/theme-update-system-monitor
Executable file
7
src_files/.local/scripts/theme-update-system-monitor
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/zsh
|
||||
|
||||
# TODO: htop even possible? maybe can change what colors it sees from terminal itself
|
||||
# pkill -SIGUSR1 htop
|
||||
# pkill -SIGUSR2 htop
|
||||
|
||||
pkill -SIGUSR2 btop
|
||||
18
src_files/.local/scripts/theme-update-terminal
Executable file
18
src_files/.local/scripts/theme-update-terminal
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/zsh
|
||||
|
||||
theme_update_havoc() {
|
||||
echo "TODO: theme_update_havoc not yet implemented"
|
||||
}
|
||||
|
||||
theme_update_kitty() {
|
||||
killall -SIGUSR1 kitty
|
||||
}
|
||||
|
||||
case "$TERMINAL" in
|
||||
("havoc")
|
||||
theme_update_havoc
|
||||
;;
|
||||
("kitty")
|
||||
theme_update_kitty
|
||||
;;
|
||||
esac
|
||||
3
src_files/.local/scripts/theme-update-tmux
Executable file
3
src_files/.local/scripts/theme-update-tmux
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/zsh
|
||||
|
||||
tmux source-file $DIR_THEME_SETTINGS/.current-theme/tmux.conf
|
||||
26
src_files/.local/scripts/theme-update-wallpaper
Executable file
26
src_files/.local/scripts/theme-update-wallpaper
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/zsh
|
||||
|
||||
|
||||
set_wallpaper_linux() {
|
||||
echo "TODO: theme_update_wallpaper_linux not yet implemented"
|
||||
}
|
||||
|
||||
set_wallpaper_macos() {
|
||||
# after back and forth with gpt and failing approaches, landing on this swift snippet
|
||||
swift <(cat << NESTED_SWIFT_BLOCK
|
||||
import AppKit
|
||||
let url = URL(fileURLWithPath: "$1")
|
||||
try NSWorkspace.shared.setDesktopImageURL(url, for: NSScreen.main!, options: [:])
|
||||
NESTED_SWIFT_BLOCK
|
||||
)
|
||||
}
|
||||
|
||||
# TODO: decide if and how to make this work for cycling through wallpapers per theme
|
||||
|
||||
wallpaper_dir=$DIR_THEME_SETTINGS/.current-theme/wallpaper
|
||||
image_paths=($(find $wallpaper_dir -type f | sort)) 2> /dev/null
|
||||
target_wallpaper=${image_paths[@]:0:1}
|
||||
[[ -z $target_wallpaper ]] && exit 0
|
||||
|
||||
[[ "$OSTYPE" = *"darwin"* ]] && set_wallpaper_macos $target_wallpaper ||
|
||||
set_wallpaper_linux $target_wallpaper
|
||||
Reference in New Issue
Block a user