feat: add Alacritty light and dark themes + synchronization scripts ✨
This commit is contained in:
parent
d35b908001
commit
bd9cd434d4
9 changed files with 504 additions and 1 deletions
55
scripts/monitor-theme-changes.sh
Executable file
55
scripts/monitor-theme-changes.sh
Executable file
|
|
@ -0,0 +1,55 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Monitor system theme changes and sync Alacritty theme
|
||||
# This script runs continuously and only updates Alacritty when the theme changes
|
||||
|
||||
set -e
|
||||
|
||||
# Get the directory where this script is located
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SYNC_SCRIPT="$SCRIPT_DIR/sync-alacritty-theme.sh"
|
||||
|
||||
# State file to track the last known theme
|
||||
STATE_FILE="/tmp/alacritty-theme-state"
|
||||
|
||||
# Function to get current theme
|
||||
get_current_theme() {
|
||||
"$SCRIPT_DIR/detect-system-theme.sh"
|
||||
}
|
||||
|
||||
# Function to get last known theme
|
||||
get_last_theme() {
|
||||
if [ -f "$STATE_FILE" ]; then
|
||||
cat "$STATE_FILE"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to save current theme
|
||||
save_theme() {
|
||||
echo "$1" > "$STATE_FILE"
|
||||
}
|
||||
|
||||
# Initial sync
|
||||
echo "Starting Alacritty theme monitor..."
|
||||
CURRENT_THEME=$(get_current_theme)
|
||||
echo "Current theme: $CURRENT_THEME"
|
||||
|
||||
# Run initial sync
|
||||
"$SYNC_SCRIPT"
|
||||
save_theme "$CURRENT_THEME"
|
||||
|
||||
# Monitor for changes
|
||||
while true; do
|
||||
sleep 5 # Check every 5 seconds
|
||||
|
||||
NEW_THEME=$(get_current_theme)
|
||||
LAST_THEME=$(get_last_theme)
|
||||
|
||||
if [ "$NEW_THEME" != "$LAST_THEME" ]; then
|
||||
echo "Theme changed from '$LAST_THEME' to '$NEW_THEME'"
|
||||
"$SYNC_SCRIPT"
|
||||
save_theme "$NEW_THEME"
|
||||
fi
|
||||
done
|
||||
Loading…
Add table
Add a link
Reference in a new issue