Page 1 of 1

Use of mx-pkexec for launching non-mx programs

Posted: Tue Aug 03, 2021 2:11 am
by abhidesh128
Can I use mx-pkexec to launch apps other than the MX's ones ? Or is it specifically written for MX apps ?
I am actually creating a .desktop file to launch XAMPP linux manager program. The contents are :

Code: Select all

[Desktop Entry]
Name=LAMPP Manager 
Exec=mx-pkexec '/opt/lampp/manager-linux-x64.run'
Comment=Manage the local server stack
Icon=/home/abhishek/Downloads/1200px-XAMPP_logo.svg.png
Terminal=false
Type=Application
Categories=Development;
Path=
StartupNotify=false
Should I use pkexec or mx-pkexec in this case ? Because when I use pkexec, nothing happens.

Re: Use of mx-pkexec for launching non-mx programs  [Solved]

Posted: Tue Aug 03, 2021 6:16 am
by fehlix
abhidesh128 wrote: Tue Aug 03, 2021 2:11 am Can I use mx-pkexec to launch apps other than the MX's ones ? Or is it specifically written for MX apps ?
Should I use pkexec or mx-pkexec in this case ? Because when I use pkexec, nothing happens.
pkexec without any adjustment would prohibit to launch GUI apps as root (for a good reason.)
The mx-pkexec helper tool provides a way to circumvent this restriction needed for some GUI apps made by MX Linux. But I would not recommend to always use it this way for 3rd party apps in general.
The way I would do it would be to launch such non-MX Linux APP through the terminal using sudo.
So in your example this way:
Change the Exec line of the desktop-starter to

Code: Select all

Exec=x-terminal-emulator -e sh -c "cd /opt/lampp; sudo -k; sudo -H ./manager-linux-x64.run" 
:puppy:

Re: Use of mx-pkexec for launching non-mx programs

Posted: Tue Aug 03, 2021 10:58 am
by abhidesh128
Thank you @fehlix for your reply..! That helped me a lot. Also, I learnt about safely launching third party apps as sudo from .desktop files.

Thanks for this excellent Linux distribution and support..!

Re: Use of mx-pkexec for launching non-mx programs

Posted: Wed Aug 25, 2021 6:41 am
by kapnook68
Cheers @fehlix, much appreciated

Re: Use of mx-pkexec for launching non-mx programs

Posted: Thu Oct 28, 2021 10:51 pm
by imingame
fehlix wrote: Tue Aug 03, 2021 6:16 am
abhidesh128 wrote: Tue Aug 03, 2021 2:11 am Can I use mx-pkexec to launch apps other than the MX's ones ? Or is it specifically written for MX apps ?
Should I use pkexec or mx-pkexec in this case ? Because when I use pkexec, nothing happens.
pkexec without any adjustment would prohibit to launch GUI apps as root (for a good reason.)
The mx-pkexec helper tool provides a way to circumvent this restriction needed for some GUI apps made by MX Linux. But I would not recommend to always use it this way for 3rd party apps in general.
The way I would do it would be to launch such non-MX Linux APP through the terminal using sudo.
So in your example this way:
Change the Exec line of the desktop-starter to

Code: Select all

Exec=x-terminal-emulator -e sh -c "cd /opt/lampp; sudo -k; sudo -H ./manager-linux-x64.run" 
:puppy:
when i try this, on terminal something like this came up

$ sudo Exec=x-terminal-emulator -e sh -c "cd /opt/lampp; sudo -k; sudo -H ./manager-linux-x64.run"
sudo: you may not specify environment variables in edit mode
usage: sudo -h | -K | -k | -V
usage: sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user]
usage: sudo -l [-AknS] [-g group] [-h host] [-p prompt] [-U user] [-u user] [command]
usage: sudo [-AbEHknPS] [-r role] [-t type] [-C num] [-D directory] [-g group] [-h host] [-p prompt] [-R directory] [-T timeout] [-u user]
[VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-r role] [-t type] [-C num] [-D directory] [-g group] [-h host] [-p prompt] [-R directory] [-T timeout] [-u user] file ...

Maybe I did something wrong or I missing something ?

Re: Use of mx-pkexec for launching non-mx programs

Posted: Thu Oct 28, 2021 11:06 pm
by abhidesh128
Hii @imingame, the line you executed in terminal is actually the line to be entered in the Exec= section of the .desktop file. You can find the code of whole .desktop file in the OP.