1

Ubuntu 20.04 on Hyper-V VM

I have tried following this but having no luck. The file shows in the app drawer but nothing happens when I click it. Here is what I have in my jmol.desktop file.

[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Jmol
Comment=Jmol-14.31.0
Exec=/home/adamch/Downloads/Jmol-14.31.0-binary/jmol-14.31.0/Jmol.jar
Icon=/home/adamch/Downloads/Jmol_icon_win.ico
Terminal=false
StartupWMClass=Jmol

The app works in the terminal by using java -jar Jmol.jar so is there a way to put that in the .desktop file and make it work?

3 Answers 3

1

Use the Path key to change the working directory and run java -jar Jmol.jar:

[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Jmol
Comment=Jmol-14.31.0
Exec=java -jar Jmol.jar
Terminal=false
StartupWMClass=Jmol
Path=/home/adamch/Downloads/Jmol-14.31.0-binary/jmol-14.31.0/
Hidden=false
3
  • I have just tried that and still nothing is happening when I click on it, any other ideas?
    – Adam Ch
    Jun 8, 2020 at 14:49
  • What do you get if you run the command python3 -c 'from gi.repository import Gio; Gio.DesktopAppInfo.new_from_filename("jmol.desktop").launch(None, None)' (one long line) in the folder where you saved the jmol.desktop file? Jun 8, 2020 at 15:03
  • Ok sorry it did actually work, but only after I rebooted for some reason. But I still can't add it to favourites, even though the app shows in the app drawer and opens from there. Edit: ok I can add it to favourites, just only in the app drawer, not after I've opened it. Also clicking the app on the taskbar opens another instance but its fine as long as I can open the app quickly.
    – Adam Ch
    Jun 9, 2020 at 16:09
0

Why don't you write a short script that just executes the file properly, and add THAT to the app drawer? Open a text editor, write java -jar /home/adamch/Downloads/Jmol-14.31.0-binary/jmol-14.31.0/Jmol.jar As the script, then save it as Jmol.sh.

[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Jmol
Comment=Jmol-14.31.0
Exec=/home/adamch/Downloads/Jmol-14.31.0-binary/jmol-14.31.0/Jmol.sh
Terminal=false
StartupWMClass=Jmol
Hidden=false
0

Safer to first check the full path of the java application launcher command -v java or command -pv java to avoid aliases. It will return the full path, in my case /usr/bin/java. Also icons must be in one of these formats: PNG, XPM and SVG.

[Desktop Entry]
Version=1.1
Type=Application
Name=Jmol
GenericName=3D Chemical Structure Viewer
Comment=Jmol-14.31.0
Exec=/usr/bin/java -jar jmol.jar
Path=/home/adamch/Downloads/Jmol-14.31.0-binary/jmol-14.31.0/
Icon=/home/adamch/Downloads/Jmol_icon_win.png
Terminal=false
StartupWMClass=Jmol
StartupNotify=true

https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s06.html

Once the file is correct (appears on the programs list, overview etc.), to put on favourites, if you're using Ubuntu with Gnome, you can press the Meta key to open the Overview and type the name of the program you want, after just move it to the dock.

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.