Opening .jar files with `pkexec` and using Desktop Entries to run commands
2
votes
1
answer
394
views
I am writing a bash script that automates installation of TLauncher (Minecraft launcher) and basic dependency management on USBs running Lubuntu 18.04.
Part of the bash script creates a desktop entry under
/usr/share/applications
for easy launch from the Lubuntu menu.
Here is the entry I am using:
[Desktop Entry]
Encoding=UTF-8
Exec=pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /usr/bin/java -jar -Dswing.systemlaf=javax.swing.plaf.nimbus.NimbusLookAndFeel ~/.minecraft/tlauncher.jar
Icon=~/.minecraft/icons/default.png
Type=Application
Terminal=false
Name=Minecraft
GenericName=minecraft
StartupNotify=false
Categories=Game
The command pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /usr/bin/java -jar -Dswing.systemlaf=javax.swing.plaf.nimbus.NimbusLookAndFeel ~/.minecraft/tlauncher.jar
works and does launch TLauncher if run in the terminal. However, I feel I am missing something when I put the command in the Desktop Entry.
When I try to open the entry from the Lubuntu menu, the cursor shows that something is loading, but then nothing happens no matter how long I wait. I am also not sure how to debug the Desktop entry. I tried toxdg-open
the entry, but I got no output in the terminal and nothing happened either -i.e, TLauncher did not launch.
I tried putting the command in a separate bash file that looks like:
#!/bin/bash
pkexec env DISPLAY=:0 XAUTHORITY=/home/me/.Xauthority /usr/bin/java -jar -Dswing.systemlaf=javax.swing.plaf.nimbus.NimbusLookAndFeel ~/.minecraft/tlauncher.jar
Running that in the terminal bash testscript.sh
works and does launch TLauncher.
But when I put it in the desktop entry replacing the exec
from the entry above like so:
Exec=/bin/bash /path/to/testscript.sh
It does not work.
The shell scripts have the proper permissions.
I feel like either I'm writing the Desktop Entry's exec
value wrong or that pkexec
isn't supposed to work from a Desktop Entry the way I am trying to make it work.
I would like to be able to launch TLauncher from a desktop entry via the menu and have a gui popup asking for the password in order to have the command run as root
.
**Edit:**
Using full paths instead of ~
also yields the same result -i.e, it does not work and the above issues remain.
Setting Terminal=true
does not solve this for me.
Asked by solidwaffle
(21 rep)
Sep 17, 2019, 07:59 PM
Last activity: Dec 13, 2024, 10:57 AM
Last activity: Dec 13, 2024, 10:57 AM