Skip to content

Instantly share code, notes, and snippets.

@specter119
Last active July 2, 2025 03:35
Show Gist options
  • Save specter119/4e84059f2f9cc9e515a9865d82a07d5c to your computer and use it in GitHub Desktop.
Save specter119/4e84059f2f9cc9e515a9865d82a07d5c to your computer and use it in GitHub Desktop.
/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
[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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment