Xfce Forum

Sub domains
 

You are not logged in.

#1 2024-05-22 02:09:12

Pheeble
Member
Registered: 2015-06-22
Posts: 27

[SOLVED] Power Manager gui failure after xfconf-query property change

I'm writing a shell script to automate the configuration of new installations of Linux Mint 21.3 XFCE.

I've got almost everything working, including configuring some of the XFCE properties via xfconf-query (eg. Thunar, desktop theme, window theme, icon theme)

I can use xfconf-query to get the current properties of xfce4-power-manager, so I've been able to work out which types and values are required for which settings.
For example, if the gui is set to 'When power button is pressed: Ask':

xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/power-button-action
3

and when the gui is set to 'When power button is pressed: Shutdown':

xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/power-button-action
4

When I try to change the property values, however, the changes are not displayed in the Power Manager gui. Subsequent calls to xfconf-query do return the new values, but the Power Manager gui doesn't reflect the changes.

I've narrowed the problem down to the syntax for 'xfconf-query' command as detailed at https://docs.xfce.org/xfce/xfconf/xfconf-query.

According to the document, it should be ok to include the '--create' and related '--type' options for existing properties:

-n, --create
    Create a new property if it does not already exist

I included those options in xfconf-query calls to successfully change the properties of other xfconf channels.

So this should be ok even if the ' /xfce4-power-manager/power-button-action' property already exists, and checking the property value via xfconf-query indicates the change has worked without a problem:

xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/power-button-action
4
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/power-button-action  --create --type int --set 3
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/power-button-action
3

Unfortunately the Power Manager gui now shows 'Power button action: Do nothing' instead of 'Ask', so perhaps the Power Manager gui has reverted to the default value.

I tried running

xfce4-power-manager -q
xfce4-power-manager --no-daemon --debug

in another terminal, but it didn't produce any new output when I ran an xfconf-query command.

Through trial and error I have found that including the xfconf-query '--create' and '--type' options when setting an existing xfce4-power-manager property causes the Power Manager gui to become unresponsive to any further changes. I have to manually change the value in the Power Manager gui before I can subsequently change an existing property value via xfconf-query (without the --create and --type options).

If I then use the command without the '--create' and '--type' options the Power Manager gui updates correctly.

It seems that to set xfce-power-manager properties I first need to establish whether the property already exists.
So I have to run:

xfconf-query -c xfce4-power-manager -l
/xfce4-power-manager/blank-on-ac
/xfce4-power-manager/dpms-enabled
/xfce4-power-manager/dpms-on-ac-off
/xfce4-power-manager/dpms-on-ac-sleep
/xfce4-power-manager/lid-action-on-battery
/xfce4-power-manager/lock-screen-suspend-hibernate
/xfce4-power-manager/power-button-action
/xfce4-power-manager/show-panel-label
/xfce4-power-manager/show-tray-icon

and parse the output to check if the property exists, and only use the '--create' and '--type' options if the property does not yet exist.

For example:

#!/usr/bin/dash

# Get a list of existing xfce4-power-manager properties
exist="$(xfconf-query -c xfce4-power-manager -l)"

# Check if each property is present in the list of existing properties and process accordingly.

# Need exact matching if a property name is a substring of another property name, so regex support is required
# Eg. '/xfce4-power-manager/brightness-switch' and '/xfce4-power-manager/brightness-switch-restore-on-exit'

# Set power button action to 'Ask'
if printf '%s' "$exist" | grep -w '^/xfce4-power-manager/power-button-action$'
then
    # Property already exists
    xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/power-button-action --set 3
else
    # Property does not exist
    xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/power-button-action --create --type int --set 3
fi

# ... and repeat this for every xfce4-power-manager property that I want to set.

This appears to be contrary to the xfconf-query syntax information mentioned previously.

Is this a bug, or have I (once again) misunderstood something?

Last edited by Pheeble (2024-05-22 20:46:35)

Offline

#2 2024-05-22 06:31:00

Tamaranch
Member
Registered: 2020-12-31
Posts: 321

Re: [SOLVED] Power Manager gui failure after xfconf-query property change

It's the same as https://gitlab.xfce.org/xfce/xfce4-powe … issues/178 I think. The correct type is uint, not int.

Offline

#3 2024-05-22 07:08:03

Pheeble
Member
Registered: 2015-06-22
Posts: 27

Re: [SOLVED] Power Manager gui failure after xfconf-query property change

Tamaranch wrote:

It's the same as https://gitlab.xfce.org/xfce/xfce4-powe … issues/178 I think. The correct type is uint, not int.

Brilliant! It looks like exactly the same issue.

Using a uint type does work with an existing xfce4-power-manager property, and the Power Manager gui updates correctly:

xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/power-button-action --create --type uint --set 3

So that means there is a documentation error. I was following the examples on the document at https://docs.xfce.org/xfce/xfconf/xfconf-query.

That document uses type int in all examples in the 'Creating Properties' section:

Create a new property /test1 in the channel test, holding an integer value 1:

xfconf-query -c test -p /test1 -n -t int -s 1

If it's a known issue, does that mean there's no point in filing a bug report about the incorrect documentation?

Thanks for your help. Hopefully my hair can start growing back now.

Offline

#4 2024-05-22 07:15:21

Tamaranch
Member
Registered: 2020-12-31
Posts: 321

Re: [SOLVED] Power Manager gui failure after xfconf-query property change

> So that means there is a documentation error.

These are just examples, so we can't really talk about error. However, as said in https://gitlab.xfce.org/xfce/xfce4-powe … note_89185 , I think xfce4-power-manager, or maybe xfconf, should warn of a problem in this case, I'll look into that. So no need to open a report no smile

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.006 seconds, 7 queries executed - Memory usage: 542.85 KiB (Peak: 544.13 KiB) ]