2

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.

0

Current solution: Since the command works when run in the terminal, simply have the Desktop Entry run the command with a terminal:

Exec=lxterminal -e "pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /usr/bin/java -jar -Dswing.systemlaf=javax.swing.plaf.nimbus.NimbusLookAndFeel /home/me/.minecraft/tlauncher.jar"

Notes:

I think I could build off of this to make sure that when the launcher is closed, it is actually closed as I noticed through ps aux that processes aren't actually being killed the way I expect causing strange behavior the next time I open the launcher.

| improve this answer | |

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.