another gpt with inotifywait addition
seems to work....
This commit is contained in:
parent
17237c513b
commit
a2c0ce3ec1
@ -1,14 +1,30 @@
|
||||
#!/bin/bash
|
||||
shared_themes_dir=/usr/share/themes/
|
||||
home_local_themes_dir="$HOME/.local/share/themes/"
|
||||
source_theme_dirs=("$shared_themes_dir" "$home_local_themes_dir")
|
||||
target_themes_dir="$HOME/.themes"
|
||||
|
||||
mkdir -p "$target_themes_dir" "$home_local_themes_dir" ||
|
||||
{ echo "failed to make directoris $target_themes_dir & $home_local_themes_dir"; exit 1; }
|
||||
# Set the directories
|
||||
|
||||
echo "Set watch for" "${source_theme_dirs[@]}" "directories ..."
|
||||
while inotifywait -qr -e 'modify,attrib,move,move_self,create,delete,delete_self,unmount' "${source_theme_dirs[@]}"; do
|
||||
rsync -av --delete --progress "${source_theme_dirs[@]}" "$target_themes_dir"
|
||||
echo "Directory $target_themes_dir is synchronized with" "${source_theme_dirs[@]}"
|
||||
shared\_themes\_dir=/usr/share/themes/
|
||||
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 both shared and local themes directories
|
||||
|
||||
monitor\_themes() {
|
||||
inotifywait -m -r -e modify,attrib,move,move\_self,create,delete,delete\_self,unmount "$shared\_themes\_dir" "$local\_themes\_dir" |
|
||||
while read -r events; do
|
||||
sync\_themes
|
||||
done
|
||||
}
|
||||
|
||||
# Start monitoring in the background
|
||||
|
||||
monitor\_themes
|
||||
|
Loading…
Reference in New Issue
Block a user