2022-09-19 12:09:49 +00:00
|
|
|
#!/bin/bash
|
2023-08-03 16:50:55 +00:00
|
|
|
|
|
|
|
# Set the directories
|
2022-09-18 21:44:59 +00:00
|
|
|
shared_themes_dir=/usr/share/themes/
|
2023-08-03 16:50:55 +00:00
|
|
|
local_themes_dir="$HOME/.themes/"
|
|
|
|
|
|
|
|
# Function to synchronize themes from shared to local directory
|
|
|
|
sync_themes() {
|
|
|
|
rsync -av --delete --progress "$shared_themes_dir" "$local_themes_dir"
|
|
|
|
echo "Directory $local_themes_dir is synchronized with $shared_themes_dir"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Initial synchronization
|
|
|
|
sync_themes
|
|
|
|
|
|
|
|
# Function to monitor shared themes directory
|
|
|
|
monitor_shared_themes() {
|
|
|
|
inotifywait -m -r -e 'modify,attrib,move,move_self,create,delete,delete_self,unmount' "$shared_themes_dir" > /dev/null 2>&1 &
|
|
|
|
}
|
|
|
|
|
|
|
|
# Function to monitor local themes directory
|
|
|
|
monitor_local_themes() {
|
|
|
|
inotifywait -m -r -e 'modify,attrib,move,move_self,create,delete,delete_self,unmount' "$local_themes_dir" > /dev/null 2>&1 &
|
|
|
|
}
|
|
|
|
|
|
|
|
# Start monitoring in the background
|
|
|
|
monitor_shared_themes
|
|
|
|
monitor_local_themes
|
2022-09-18 21:44:59 +00:00
|
|
|
|
2023-08-03 16:50:55 +00:00
|
|
|
# Monitor changes and sync periodically
|
|
|
|
while true; do
|
|
|
|
# Wait for a short period (e.g., 5 seconds) before syncing again
|
|
|
|
sleep 5
|
2022-09-30 23:46:59 +00:00
|
|
|
|
2023-08-03 16:50:55 +00:00
|
|
|
# Synchronize if there were changes in either directory
|
|
|
|
sync_themes
|
2022-10-01 16:30:00 +00:00
|
|
|
done
|