Desktop icon for linux users

Hello everyone,

I have been using the 3dSlicer software for almost a year now and I got tired of launching the application from the command line. I would like to be able to contribute to create a desktop shortcut according to the freedesktop.org specifications used by most GNU/Linux distributions.

As the file should reference the location of the ‘Slicer’ binary and the icon to represent the program on the desktop, I would like to know where you usually leave the download folder for Slicer.

A valid example would be the following for org.slicer.desktop:

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Name=3DSlicer
GenericName=DICOMM file slicer
Comment=DICOMM file viewer
Exec=/absolute/path/to/folder/apps/3dslicer/Slicer-latest/Slicer
Icon=/absolute/path/to/folder/.local/share/icons/3dslicer.png

Perhaps a bash script could be prepared to facilitate copying the org.slicer.desktop file to the common folders where desktop managers check for the presence of *.desktop files such as /usr/share/applications/, $HOME/.local/share/applications for direct access from the desktop.

4 Likes

Sounds like a good idea. I have typically done this manually or as part of an install script, but in general I use the command line.

I would suggest we consider making this a core feature of Slicer. On startup the application could offer to install the shortcut if it doesn’t already exist. The dialog could have a “don’t ask again” option for users who don’t ever want the shortcut. This would be a fairly simple python script (probably easiest to manage in a hidden module that triggers with the onStartupCompleted signal).

1 Like

It would be great as i also create the desktop icon manually.

Ok, I agree.
Apologies for not thinking of Microsoft Windows or MacOS users. I thought these operating systems had a shortcut to launch the application.

I was thinking only of Linux because for each distribution when changing the desktop environment or window manager the most common item was *.desktop files.

So an option should be added to accept in the first session whether to create a shortcut or not. I also see important to be able to manage the different versions of Slicer in the system.

For example, when a new version is to be installed, even if there is the previous one, this shortcut would have to refer to the latest version and delete the previous one? Should the user manually delete the previous version of Slicer? I think these are issues to be clarified.

For Windows I have open work that I will be finishing soon for having the option to create a desktop icon during the install process. This is common for installers on Windows. I’m not sure about other platforms. It would be good for other platforms to create desktop shortcuts in whatever manner is standard behavior for that platform.

Since multiple versions of Slicer can be installed at the same time, maintaining previous versions is desired. It is common for people to have various Slicer stable and preview versions installed. Therefore my PR for Windows creates desktop shortcuts with the name and version so it is “Slicer 5.2.1” on the desktop.

In the case of using a framework such as flatpak to package the application, it would be necessary to see how to manage the installer with multiple versions. As indicated in issue #6761 the case of using a framework such as flatpak to package the application, it would be necessary to see how to manage the installer with multiple versions. As indicated in issue #6761 it could be activated or deactivated with a flag in CMake it could be activated or deactivated with a flag in CMake.

For the Linux part it would be simple if it was to generate a *.desktop file that would have the reference to run the ‘Slicer’ binary depending on the folder that would have the version. It could be a template *.desktop file with some parameters changed such as the execution path and version identifier. There would have to be an image file as an icon in the resources to use it. It does not need more. Then that file would be stored in one of the paths known to the desktop managers and so it could be accessible from anywhere as an executable shortcut. Converting it to an icon on the desktop is as easy as copying the *.desktop file into the Desktop folder of the file system.

I have been going through a couple of resources on how to generate desktop shortcuts with python on Windows. It is possible and therefore everything could be contained within that hidden module, as @pieper pointed out.

Although I think it would be wise to see if this issue can be addressed at Project Week as it is something that affects the actual use of the application itself.

Next would be to familiarize myself with Slicer modules and prepare a test. The available options could be:

  • Create a desktop shortcut
  • Create a system wide shortcut
  • Do not ask again

I have to familiarize with the hide modules and prepare a test example.

KDE has 2 desktop modes :

  • Folder mode (default) : anything in the $HOME/Desktop/ directory shows on the desktop
  • Desktop mode : contrary to what the name suggests, the $HOME/Desktop/ content is ignored. Desktop icons are found in $HOME/.local/share/plasma_icons/

This introduces some complications. The second ‘Desktop’ mode can also be left aside as it is an outlier case.

For Windows, I would suggest we stick with the creation of the desktop shortcut as a selection when running through the installer as this is familiar behavior on this platform. I’ll address this for Windows when I finalize my PR mentioned in my previous post. For Linux Desktop shortcut creation feel free to do whatever is standard in the Linux community.