I'm writing a script for XFCE Spin Fedora 25 that configures the system and uses xfconf-query to modify configuration of the XFCE desktop enviroment.
This script needs to be executed with sudo because it has to modify the system and install packages.
The problems comes from xfconf-query itself. It doesn't work when I launch the script with sudo, but it works when I use it as
bash script.sh. I decided to pass $USER as an argument to the script and try to use the xfconf-query commands with
su <user> -c "commands here", but it doesn't work.
Now I have to use 2 separated scripts, one for general tasks and the other for all the xfconf-query commands.
Edit: when I type
sudo xfconf-query -c xsettings -p /Net/ThemeName -s "Greybird" in the terminal it works, but when I use the same command with sudo it doesn't work. That command may need to be used by the user demanding the change but it's weird that with
su <user> -c "command here" launched in a bash interpreter with privileges it doesn't work.