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?

terdon
  • 234,489
  • 66
  • 447
  • 667
user3585918
  • 41
  • 1
  • 4
  • 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 09 '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 09 '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 09 '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 09 '18 at 10:28

2 Answers2

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
user3585918
  • 41
  • 1
  • 4
0

I have used JQL/com.ubuntu.pkexec.xampp.policy on my Ubuntu 19.04 and it works 100%. And of course for Ubuntu Menu Editor use Ubuntu Alacarte Menu Editor.

Paulo Tomé
  • 3,754
  • 6
  • 26
  • 38
Imeksbank
  • 1
  • 1