/usr/share/libalpm/hooks/90-wsl-shortcuts-control.hook for proventing wsl add too much desktop entry into host windows, /etc/wsl.d/desktop_whitelist is the file list, without .desktop suffix

Kyle
2025-07-02T03:34:21Z

90-wsl-shortcuts-control.hook

| [Trigger]
| Type = Path
| Operation = Install
| Operation = Upgrade
| Target = usr/share/applications/*.desktop
|
| [Action]
| Description = Control WSL application shortcuts by setting Terminal=true
| When = PostTransaction
| Exec = /bin/bash -c 'for f in /usr/share/applications/*.desktop; do app=$(basename "$f" .desktop); while read -r w; do [ "$w" = "$app" ] && continue 2; done < /etc/wsl.d/desktop_whitelist 2>/dev/null; sed -i "/^Terminal=false$/ s//Terminal=true/" "$f"; done'
| Depends = bash