0

I am trying to start qbittorrent after OpenVPN connects via the --up script. The problem is that the script is ran via the root profile, so starting an application was a bit of a problem. After fixing that, the next issue is that the application opens but without any of the user profile theme & style customizations done in the system settings (Kubuntu 20.04 and KDE Plasma)

Script (USER_NAME is the user):

#!/bin/bash

xhost +
export DISPLAY=:0
sudo -u USER_NAME qbittorrent & disown
xhost -

What do I have to do to run the application with the correct themes & styles?

EDIT: with the help of waltinator's answer and by looking at users environmental variables using env I managed to give the program the correct theme & styles the following way:

#!/bin/bash

sudo -i -u USER_NAME DISPLAY=:0 KDE_FULL_SESSION=true qbittorrent & disown

preserving these two environmental variables (three in case you would also like to set XDG_RUNTIME_DIR so that the program doesn't default to /tmp) via visudo does not keep them when the --up script is ran by OpenVPN, so I have to manually set them every time I want to run the program. I have also removed the xhost calls as it seems to work without them now, which I am guessing is because of the -i option.

0

Read man sudo, and add the -i option to your sudo command. Read man sudoers, too.

BTW, using xhost +localhost and xhost -localhost doesn't open your X server to other systems on the network. Read man xhost.

1
  • I have to read quite a bit more of the documentation, but by just glancing over the -i option in man sudo and looking at the way it works inside man sudoers, I am pretty certain that the option will not fix my issue as the script itself has to be executed with the -i option, which I cannot control because the openvpn service executes the scripts. From my understanding by using -i inside of the script when its already executed as root by the openvpn service will just transfer over the environmental variables that the root user has rather than the variables of the -u user. – Terrails Mar 30 at 23:46

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.