2

I am creating Xampp desktop launcher on my Linux Mint 19 and I have very interesting problem.

When I run this from terminal:

pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /opt/lampp/manager-linux-x64.run &

everything works correctly, XAMPP control panel opens.

But when I have launcher (I want to create icon for desktop) with code:

#!/usr/bin/env xdg-open
[Desktop Entry]
Comment=Start or Stop XAMPP
Name=XAMPP Control Panel
Exec=pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY sudo /opt/lampp/manager-linux-x64.run 
Icon[en_US]=/usr/share/icons/Humanity/devices/24/network-wired.svg
Encoding=UTF-8
Terminal=false
Name[en_US]=XAMPP Control Panel
Comment[en_US]=Start or Stop XAMPP
Type=Application
Icon=/opt/lampp/htdocs/favicon.ico

It prompts me for password but the window never opens. I tried various scripts and this one works in launcher:

#!/usr/bin/env xdg-open
[Desktop Entry]
Comment=Start or Stop XAMPP
Name=XAMPP Control Panel
Exec=**sudo /opt/lampp/manager-linux-x64.run**
Icon[en_US]=/usr/share/icons/Humanity/devices/24/network-wired.svg
Encoding=UTF-8
Terminal=**true**
Name[en_US]=XAMPP Control Panel
Comment[en_US]=Start or Stop XAMPP
Type=Application
Icon=/opt/lampp/htdocs/favicon.ico 

XAMPP control panel window opens but also the terminal that started it.

How can I create launcher that only opens the XAMPP control panel window without additional terminal?

  • Does your .desktop file work as expected if you remove the & from the command? Like this: Exec=pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY sudo /opt/lampp/manager-linux-x64.run – terdon Nov 9 '18 at 10:21
  • no it only prompts window for password (as the command with & included) and after typing password nothing happens. I am using Linux Mint 19 – user3585918 Nov 9 '18 at 10:23
  • Exec= defines an executable, it's not a shell interpreter. Use sh -c "blabla", if you wanna use shell. – Ipor Sircer Nov 9 '18 at 10:25
  • great it works now! I kind of knew that the problem will not be in the command but in the way how linux processes it Correct code to the desktop launcher is: sh -c "pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY sudo /opt/lampp/manager-linux-x64.run" – user3585918 Nov 9 '18 at 10:28
2

Correct code to the desktop launcher:

#!/usr/bin/env xdg-open
[Desktop Entry]
Comment=Start or Stop XAMPP
Name=XAMPP Control Panel
Exec=sh -c "pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY sudo /opt/lampp/manager-linux-x64.run"
Icon[en_US]=/usr/share/icons/Humanity/devices/24/network-wired.svg
Encoding=UTF-8
Terminal=false
Name[en_US]=XAMPP Control Panel
Comment[en_US]=Start or Stop XAMPP
Type=Application
Icon=/opt/lampp/htdocs/favicon.ico
  • out of all these questions/answers, i found you, the answer. – R T Jun 21 at 6:14

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.