Quantcast
Channel: Active questions tagged desktop-environment - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 87

Opening .jar files with `pkexec` and using Desktop Entries to run commands

$
0
0

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-8Exec=pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /usr/bin/java -jar -Dswing.systemlaf=javax.swing.plaf.nimbus.NimbusLookAndFeel ~/.minecraft/tlauncher.jarIcon=~/.minecraft/icons/default.pngType=ApplicationTerminal=falseName=MinecraftGenericName=minecraftStartupNotify=falseCategories=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/bashpkexec 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.


Viewing all articles
Browse latest Browse all 87

Trending Articles