Xfce Forum

Sub domains
 

You are not logged in.

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

uiii
Member
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
ThunarIconView

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
ThunarIconView

but

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

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?

Thanks

Offline

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

ToZ
Moderator
From: Toronto, Canada
Registered: 2011-06-02
Posts: 3,589

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

Offline

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

Dharkael
Member
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)

Offline

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

MountainDewManiac
Member
From: USA police-state welfare-state
Registered: 2013-03-24
Posts: 797

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:

https://ask.fedoraproject.org/en/question/7185/no-gksudo-so-just-su-or-sudo-then/

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

Regards,
MDM


Mountain Dew Maniac

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

Offline

Board footer

Powered by FluxBB