Compare commits

...

2 Commits

Author SHA1 Message Date
391aba7869 Merge pull request 'Listen for more specific events using inotifywait' (#8) from rokosun-patch-1 into main
Reviewed-on: #8
2022-09-20 02:10:43 +02:00
275a4eebe7 Listen for more specific events using inotifywait
Also implemented some changes suggested by [Shellcheck](https://github.com/koalaman/shellcheck)
2022-09-19 14:09:49 +02:00

View File

@ -1,16 +1,16 @@
#!/bin/sh #!/bin/bash
shared_themes_dir=/usr/share/themes/ shared_themes_dir=/usr/share/themes/
home_local_themes_dir="$HOME/.local/share/themes/" home_local_themes_dir="$HOME/.local/share/themes/"
source_theme_dirs="$shared_themes_dir $home_local_themes_dir" source_theme_dirs=("$shared_themes_dir" "$home_local_themes_dir")
target_themes_dir="$HOME/.themes" target_themes_dir="$HOME/.themes"
if [ ! -e $home_local_themes_dir ]; then if [ ! -e "$home_local_themes_dir" ]; then
mkdir -p $home_local_themes_dir mkdir -p "$home_local_themes_dir"
echo "Directory $home_local_themes_dir is created." echo "Directory $home_local_themes_dir is created."
fi fi
echo "Set watch for $source_theme_dirs directories ..." echo "Set watch for" "${source_theme_dirs[@]}" "directories ..."
while inotifywait -r $source_theme_dirs; do 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 rsync -av --delete --progress "${source_theme_dirs[@]}" "$target_themes_dir"
echo "Directory $target_themes_dir is synchronized with $source_theme_dirs." echo "Directory $target_themes_dir is synchronized with" "${source_theme_dirs[@]}"
done done