install.fairie/home/.chezmoiscripts/universal/run_onchange_after_85-remove-shortcuts.sh.tmpl
2023-11-05 05:33:23 +00:00

31 lines
1.2 KiB
Cheetah

{{- if (eq .host.distro.family "linux") -}}
#!/usr/bin/env bash
# @file Linux Shortcut Removal
# @brief Cleans up desktop shortcuts that are out of place or unwanted on Linux devices
# @description
# This script loops through the `.removeLinuxShortcuts` value in `home/.chezmoidata.yaml` and removes
# desktop shortcuts that have been deemed to be unnecessary or obtrusive.
{{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }}
{{ $removeShortcuts := join " " .removeLinuxShortcuts }}
# shortcuts to remove: {{ $removeShortcuts }}
logg info 'Processing remove shortcuts step for Linux machines'
### Remove unnecessary desktop shortcuts
for DESKTOP_ICON in {{ $removeShortcuts }}; do
for SHORTCUT_FOLDER in {{ .host.home }}/.local/share/applications {{ .host.home }}/.local/share/applications/wine/Programs; do
if [ -f "$SHORTCUT_FOLDER/$DESKTOP_ICON" ]; then
rm -f "$SHORTCUT_FOLDER/$DESKTOP_ICON"
fi
done
for SHORTCUT_FOLDER in /usr/share/applications /usr/local/share/applications /var/lib/snapd/desktop/applications; do
if [ -f "$SHORTCUT_FOLDER/$DESKTOP_ICON" ]; then
sudo rm -f "$SHORTCUT_FOLDER/$DESKTOP_ICON"
fi
done
done
{{ end -}}