Xfce Forum

Sub domains

You are not logged in.

#1 2016-05-12 09:37:12

Registered: 2016-05-12
Posts: 1

Xfconf-query with sudo

Hi, I have a script which runs as root (it cannot be changed), and need to set some xfconf options for specific user.

Consider this:

> xfconf-query -c thunar -p /last-view

I'm doing this:

> sudo -u user xfconf-query -c thunar -p /last-view -s ThunarCompactView

Unfortunately this doesn't change the option for that user:

> xfconf-query -c thunar -p /last-view


> sudo -u user xfconf-query -c thunar -p /last-view

I don't unserstand where ThunarCompactView option value is stored, it's neither in .config/xfce4/xfconf/xfce-perchannel-xml/thunar.xml nor in roots folder.

How to make it work?



#2 2016-05-12 12:27:47

From: Canada
Registered: 2011-06-02
Posts: 4,262

Re: Xfconf-query with sudo

Hello and welcome.

It would appear that using the sudo command doesn't allow xfconf-query to properly connect to the xfconfd daemon to track the change. Most probably because sudo doesn't properly create access to your X environment. On my system, using your sudo command, I notice the entry change in my .config/xfce4/xfconf/xfce-perchannel-xml/thunar.xml file (after about a 2-3 second delay), but not in the settings editor. On logout, xfconfd will write the settings it has in memory and overwrite the change made to the xml file.

However, using gksudo (or pkexec if you're trying to keep up with the Jonses) allows xfconf-query to connect to xfconfd and make the correct settings change:

gksudo -u toz "xfconf-query -c thunar -p /last-view -s ThunarCompactView"

How To Ask For Help           Xfce FAQ                            Xfce Release Information
The Xfce Community          Xfce Tips and Tricks


#3 2017-04-02 00:54:09

Registered: 2017-04-02
Posts: 1

Re: Xfconf-query with sudo

Sorry for posting in an old thread but this is the first result in the search of "xfconf-query sudo" and I wanted to share how did I solve this without gksudo (you can't dowload it in the Fedora's official repository).
I have a configuration script which requires sudo and uses xfconf-query.

I launch the script as:

sudo -E bash xfce.sh $USER

That way I can have the user and the enviroment variables.

The script is something like this:

#! /bin/bash

# install stuff here
# modify system here 

su $1 -m -c 'xfconf-query -c xfce4-session -p /general/SaveOnExit -s false -n
    xfconf-query -c xsettings -p /Net/ThemeName -s "Arc-Dark"
    xfconf-query -c xsettings -p /Net/IconThemeName -s "Paper"
    xfconf-query -c xsettings -p /Gtk/ButtonImages -s false
    # more xfconf-query commands...

$1 contains the user and -m keeps intact the enviroment context.

You can have a look at my script here: https://github.com/lupoDharkael/FedoraX … er/xfce.sh
Your suggestions are welcome!

Last edited by Dharkael (2017-04-02 01:14:25)


#4 2017-04-04 23:55:26

From: Where Mr. Bankruptcy is Prez
Registered: 2013-03-24
Posts: 925

Re: Xfconf-query with sudo

Dharkael wrote:

without gksudo (you can't dowload it in the Fedora's official repository).

Doesn't pkexec serve substantially the same purpose in Fedora as gksudo does in (some) other distros? I do not use Fedora, so I have no personal knowledge. But I saw this:


I've also seen the command (pkexec) mentioned numerous times in this forum, in regards to Fedora, when such things were being discussed.


Mountain Dew Maniac

How to Ask for Help <=== Click on this link


Board footer

Powered by FluxBB