Compare commits

...

1 Commits

Author SHA1 Message Date
bd11ec4837 add icon sync for flatpaks 2023-08-04 00:24:40 +02:00

View File

@ -1,14 +1,31 @@
#!/bin/bash
# Set the directory paths
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; }
shared_icons_dir=/usr/share/icons/
home_local_icons_dir="$HOME/.local/share/icons/"
source_icon_dirs=("$shared_icons_dir" "$home_local_icons_dir")
target_icons_dir="$HOME/.icons"
echo "Set watch for" "${source_theme_dirs[@]}" "directories ..."
inotifywait -qmr -e 'modify,attrib,move,move_self,create,delete,delete_self,unmount' "${source_theme_dirs[@]}" | while read -r events; do
rsync -av --delete --progress "${source_theme_dirs[@]}" "$target_themes_dir"
echo "Directory $target_themes_dir is synchronized with" "${source_theme_dirs[@]}"
# Function to synchronize themes and icons from source to target directory
sync_themes_and_icons() {
rsync -av --delete --progress "${source_theme_dirs[@]}" "$target_themes_dir"
rsync -av --delete --progress "${source_icon_dirs[@]}" "$target_icons_dir"
echo "Directories $target_themes_dir and $target_icons_dir are synchronized with source directories"
}
# Create the target and local directories if they don't exist
mkdir -p "$target_themes_dir" "$home_local_themes_dir" "$target_icons_dir" "$home_local_icons_dir" ||
{ echo "failed to make directories $target_themes_dir & $home_local_themes_dir & $target_icons_dir & $home_local_icons_dir"; exit 1; }
echo "Set watch for theme directories: ${source_theme_dirs[@]}, and icon directories: ${source_icon_dirs[@]}"
# Start watching for file changes in the source theme and icon directories
inotifywait -qmr -e 'modify,attrib,move,move_self,create,delete,delete_self,unmount' "${source_theme_dirs[@]}" "${source_icon_dirs[@]}" |
while read -r events; do
sync_themes_and_icons
done