2

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?

3

https://stackoverflow.com/questions/119031/how-to-set-my-applications-desktop-icon-for-linux-kde-gnome-etc

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

8
  • 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. Dec 2 '09 at 17:20
  • 1
    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
  • 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? Dec 11 '09 at 19:17
  • 1
    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
  • Thanks, I got it to work using the $SUDO_USER environment variable. For some reason, xdg-desktop-icon insisted on installing the .desktop file to /root/Desktop all of a sudden. I copy the .desktop file manually now to the Desktop of $SUDO_USER, and adjust its permissions accordingly. Dec 20 '09 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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