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

Message
Author
User avatar
abhidesh128
Posts: 83
Joined: Sun Nov 08, 2020 6:03 am

Use of mx-pkexec for launching non-mx programs

#1 Post 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.
Loving Linux...Since ages...!

User avatar
fehlix
Developer
Posts: 12740
Joined: Wed Apr 11, 2018 5:09 pm

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

#2 Post 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:

User avatar
abhidesh128
Posts: 83
Joined: Sun Nov 08, 2020 6:03 am

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

#3 Post 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..!
Loving Linux...Since ages...!

kapnook68
Posts: 4
Joined: Wed Jun 09, 2021 11:41 am

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

#4 Post by kapnook68 »

Cheers @fehlix, much appreciated

User avatar
imingame
Posts: 9
Joined: Tue Sep 14, 2021 7:08 am

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

#5 Post 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 ?

User avatar
abhidesh128
Posts: 83
Joined: Sun Nov 08, 2020 6:03 am

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

#6 Post 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.
Loving Linux...Since ages...!

Post Reply

Return to “Software / Configuration”