From a15086f7a6a01a39419adeb4596ce0bd4157df37 Mon Sep 17 00:00:00 2001
From: eSh <mr.eshua@gmail.com>
Date: Sun, 18 Sep 2022 23:44:59 +0200
Subject: [PATCH] watch for the changes in themes directories

---
 bin/periodic/fix-flatpaks-theming | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/bin/periodic/fix-flatpaks-theming b/bin/periodic/fix-flatpaks-theming
index 0611477..d87dad6 100755
--- a/bin/periodic/fix-flatpaks-theming
+++ b/bin/periodic/fix-flatpaks-theming
@@ -1,5 +1,16 @@
 #!/bin/sh
-while inotifywait -r /usr/share/themes/ "$HOME/.local/share/themes/"; do
-    rsync -av --progress /usr/share/themes/* ~/.themes/ --exclude Windowck
-    rsync -av --progress "$HOME/.local/share/themes/*" ~/.themes/ --exclude Windowck-dark
-done
\ No newline at end of file
+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"
+
+if [ ! -e $home_local_themes_dir ]; then
+    mkdir -p $home_local_themes_dir
+    echo "Directory $home_local_themes_dir is created."
+fi
+
+echo "Set watch for $source_theme_dirs directories ..."
+while inotifywait -r $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."
+done
-- 
2.39.5