Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am currently packaging an application in a Ubuntu .deb file. The package will not be distributed publicly.

Currently, I package a .desktop file which is installed to /usr/share/applications. After installing the package, the .desktop file gets picked up correctly, and a new entry for my application is added to the Applications menu. So far, so good.

Besides the Applications menu entry however, I also want to install an application launcher on the user's desktop. The problem is that I do not know beforehand the directory of the user's Desktop. How should I install a launcher on the user's desktop?

share|improve this question
up vote 2 down vote accepted

EDIT: see comments for info on using xdg-desktop-icon command in postinst/postrm scripts.

share|improve this answer
I already have a .desktop file, the challenge is how to get it installed on the user's desktop. I'm not using Cmake, I'm using Ubuntu's packaging tools, dh_make and debuild. – Ton van den Heuvel Dec 2 '09 at 17:20
I don't know if there is a better way, but you can install it calling xdg-desktop-icon install .../program.desktop from the post installation script debian/postinst, and remove it calling xdg-desktop-icon uninstall ... from the post removal script debian/postrm – alfplayer Dec 2 '09 at 23:52
Thanks, I'll try that. – Ton van den Heuvel Dec 4 '09 at 16:48
I have tried Using xdg-desktop-icon install. The desktop icon is installed to the user's desktop, but is read-only for root. How to ensure that the desktop icon is usable by the user? – Ton van den Heuvel Dec 11 '09 at 19:17
The environment variables $SUDO_USER and $HOME (I believe that both are present on postinst) are useful to do this, they both refer to the user that executed the installer. After installing the file, you can change its file ownership to $SUDO_USER and file permissions to 755. – alfplayer Dec 11 '09 at 20:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.