ready for 2021.11.16
This commit is contained in:
56
tromjaro/xfce/desktop-overlay/etc/skel/.local/bin/fix-tweaked-desktop-files
Executable file
56
tromjaro/xfce/desktop-overlay/etc/skel/.local/bin/fix-tweaked-desktop-files
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/bin/bash
|
||||
data="$HOME"/.local/share/applications/tweaked-desktop-files
|
||||
detectfiles() {
|
||||
for file in "$HOME"/.local/share/applications/*.desktop; do
|
||||
[ -d "$file" ] || grep -xq "$file" "$data" && continue
|
||||
name=$(basename "$file") || continue
|
||||
[ -f /usr/share/applications/"$name" ] ||
|
||||
ls /var/lib/flatpak/app/*/current/active/files/share/applications/"$name" >/dev/null 2>&1 ||
|
||||
[ -f /var/lib/snapd/desktop/applications/"$name" ] &&
|
||||
echo "$file" >> "$data"
|
||||
done
|
||||
}
|
||||
|
||||
fixfiles() {
|
||||
lastmod=$(stat -c "%Y" "$data")
|
||||
tmp="$(mktemp -u)"
|
||||
[ -f "$data" ] && cp "$data" "$tmp" && copied='true'
|
||||
[ "$copied" = 'true' ] && while IFS= read -r file; do
|
||||
[ -f "$file" ] || { sed -i "/^$file$/d" "$tmp" ; continue; }
|
||||
name=$(basename "$file") || continue
|
||||
[ -f /usr/share/applications/"$name" ] ||
|
||||
ls /var/lib/flatpak/app/*/current/active/files/share/applications/"$name" >/dev/null 2>&1 ||
|
||||
[ -f /var/lib/snapd/desktop/applications/"$name" ] ||
|
||||
mv "$file" "$file.bak"
|
||||
done < "$data"
|
||||
|
||||
[ "$copied" = 'true' ] && [ "$(stat -c '%Y' "$data")" = "$lastmod" ] && mv "$tmp" "$data"
|
||||
|
||||
for bakfile in "$HOME"/.local/share/applications/*.desktop.bak; do
|
||||
origfile="${bakfile/%.bak}"
|
||||
[ -f "$origfile" ] && continue
|
||||
name=$(basename "$origfile") || continue
|
||||
[ -f /usr/share/applications/"$name" ] ||
|
||||
ls /var/lib/flatpak/app/*/current/active/files/share/applications/"$name" >/dev/null 2>&1 ||
|
||||
[ -f /var/lib/snapd/desktop/applications/"$name" ] &&
|
||||
mv "$bakfile" "$origfile"
|
||||
done
|
||||
}
|
||||
|
||||
pidof -q -o %PPID -x fix-tweaked-desktop-files && exit
|
||||
|
||||
while :; do
|
||||
local_new=$(ls -ad "$HOME"/.local/share/applications/*.desktop 2>/dev/null)
|
||||
pacman_new=$(ls -ad /usr/share/applications/*.desktop 2>/dev/null)
|
||||
flatpak_new=$(ls -ad /var/lib/flatpak/app/*/current/active/files/share/applications/*.desktop 2>/dev/null)
|
||||
snap_new=$(ls -ad /var/lib/snapd/desktop/applications/*.desktop 2>/dev/null)
|
||||
[ "$local_new" != "$local_old" ] && detectfiles
|
||||
[ "$pacman_new" != "$pacman_old" ] ||
|
||||
[ "$flatpak_new" != "$flatpak_old" ] ||
|
||||
[ "$snap_new" != "$snap_old" ] && fixfiles
|
||||
local_old=$local_new
|
||||
pacman_old=$pacman_new
|
||||
flatpak_old=$flatpak_new
|
||||
snap_old=$snap_new
|
||||
sleep 5
|
||||
done
|
Reference in New Issue
Block a user