Desktop entry (.desktop) files in /usr/share/applications would be overwritten on package upgrade. To override the file without losing changes, place a copy in ~/.local/share/applications and make your changes here.
Updated for selective, automated override of original desktop file on detecting changes
Goal: monitor for changes to desktop file and execute script to effect desired changes.
- Create script
/usr/local/bin/update-myapp-desktop-file.shto make desired changes to desktop file:
#!/usr/bin/env bash
sed -i 's/^NoDisplay=true/NoDisplay=false/' /usr/share/applications/MyApplication.desktop
Mark script as executable: chmod 755 /usr/local/bin/update-myapp-desktop-file.sh
- Create systemd service file
/etc/systemd/system/myapp-desktop-file.serviceto run script:
[Unit]
Description=Update MyApp desktop file
[Service]
ExecStart=/usr/local/bin/update-myapp-desktop-file.sh
- Create corresponding systemd path file
/etc/systemd/system/myapp-desktop-file.pathto monitor for changes to desktop file:
[Unit]
Description=Monitor for changes to MyApp desktop file
[Path]
PathModified=/usr/share/applications/MyApplication.desktop
Unit=myapp-desktop-file.service
[Install]
WantedBy=multi-user.target
- Verify, enable, and start systemd path file:
systemd-analyze verify /etc/systemd/system/myapp-desktop-file.*
systemctl enable myapp-desktop-file.path
systemctl start myapp-desktop-file.path