It was a long time since the last working in Fedora Linux. Today, I get back to work with it. So I decided to install LAMPP to quickly depart again. You can found it here: https://www.apachefriends.org/download.html.
But, it’s weird if every time I need to start the LAMPP Manager, I need to open the terminal and type the command sudo /opt/lampp/manager-linux-x64.run
like that.
After a while, I’ve successfully created a desktop icon to quickly start this manager. The main problems when creating this icon is:
- LAMPP Manager only works with root privilege.
- Program run with
sudo
command can not connect to XHost display.
Thanks to my best friend, Google Search, after 15 minutes of Googling, I found a way to solve those problems: the xhost
command and the pkexec
command. The problem can be solved in 03 steps:
- Allow root account to connect to xhost display:
xhost si:localuser:root
- Use pkexec command to run manager with root privilege:
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /opt/lampp/manager-linux-x64.run
- Reverse XHost config, disallow root account to connect to XHost display:
xhost -si:localuser:root
You can create new .desktop file in your user folder at path ~/.local/share/applications/lampp.desktop with this content:
[Desktop Entry]
Type=Application
Name=LAMPP Manager
Icon=/opt/lampp/htdocs/dashboard/images/xampp-logo.svg
Exec=bash -c "xhost si:localuser:root; pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /opt/lampp/manager-linux-x64.run; xhost -si:localuser:root;"
Comment=LAMPP Manager
Categories=Development;
Terminal=false
Or open the terminal and paste the command below:
tee ~/.local/share/applications/lampp.desktop << EOF
[Desktop Entry]
Type=Application
Name=LAMPP Manager
Icon=/opt/lampp/htdocs/dashboard/images/xampp-logo.svg
Exec=bash -c "xhost si:localuser:root; pkexec env DISPLAY=\$DISPLAY XAUTHORITY=\$XAUTHORITY /opt/lampp/manager-linux-x64.run; xhost -si:localuser:root;"
Comment=LAMPP Manager
Categories=Development;
Terminal=false
EOF
And this is the result:
Okay, that’s all for this post. Thank you for reading and hope you can enjoy this tip.