Xfce Forum

Sub domains
 

You are not logged in.

#1 2026-07-11 15:40:13

jakfish
Member
Registered: 2019-12-23
Posts: 85
Windows 10Chrome 150.0

Script Help for Max Brightness on Resume from Suspend

Mageia 10/panel ver 4.21.1/Sony VGN-P588E

Should all software issues be this small, but max brightness is always the default when resuming from a lid-close suspend (time-out suspends do not have this issue).

So I was wondering where I'm going wrong with this script in /lib/systemd/system-sleep/xfce-resume-script.sh:

#!/bin/bash

if [ "$1" = "post" ]; then

    sleep 8 && xrandr --output LVDS-1 --brightness 0.6
    echo "System Woke Up" >> /tmp/resume.log

fi

It runs in terminal complaint-free but won't use the /tmp directory and it won't execute the xrandr command. Just to see if I've somehow blocked /tmp, I ran a ToZ weather script:

#!/bin/sh

sleep 20

wxcache=${HOME}/tmp/wxdata-cached

curl -o ${wxcache} -s http://rss.accuweather.com/rss/liveweather_rss.asp\?metric\=${METRIC}\&locCode\=$1
sed -n '/Currently:/ s/.*: \(.*\): \([0-9]*\)\([CF]\).*/\2°\3 \1/p' ${wxcache}

which does create /tmp/wxdata-cached. So the directory works.

Edit: one more variable--because of crashes, I use s2idle in grub.

Any pointers?

Last edited by jakfish (2026-07-11 15:52:57)

Offline

#2 2026-07-11 16:59:42

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 12,644
LinuxFirefox 152.0

Re: Script Help for Max Brightness on Resume from Suspend

A couple of problems there. First, your first if command should use the comparison "==" symbol instead of the assignment "=" symbol. But more importantly, scripts that run in systemd/system-sleep are run by a privileged account and not your user account, meaning it won't have access to your x display or authority to act upon it. Try something like this which is more standard:

#!/usr/bin/env sh

case "$1/$2" in
    post/*)
        # Add a short delay
        sleep 8
        
        # Export required X11 graphical session environment variables
        export DISPLAY=:0
        export XAUTHORITY=/home/USERNAME/.Xauthority
        
        # adjust brightness
        xrandr --output LVDS-1 --brightness 0.6
        ;;
esac

...replace USERNAME with your actual account username.


Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2026-07-11 17:39:10

jakfish
Member
Registered: 2019-12-23
Posts: 85
Windows 10Chrome 150.0

Re: Script Help for Max Brightness on Resume from Suspend

Many thanks, ToZ, for weighing in, and with a much different approach than AI can generate.

The script does execute itself but it does not employ the xrandr command. Just to test, I put another 8 seconds of sleep after

export XAUTHORITY=/home/jake/.Xauthority

but no joy.

I wonder if this is a Sony GMA500 video driver issue. The  Poulsbo stuff has always been a pain. I'm assuming the xfce-power-manager uses

systemctl suspend

upon sensing a lid close, and I'm using the same command in my own timed suspend without problem.

Thanks again for your assistance.

Edit: FWIW, I had to create /home/jake/.Xauthority and ran

ls -l ~/.Xauthority

and

echo $XAUTHORITY

and the file is rw and in its proper place. But it is always empty.

Last edited by jakfish (2026-07-11 18:03:34)

Offline

#4 2026-07-11 19:16:44

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 12,644
LinuxFirefox 152.0

Re: Script Help for Max Brightness on Resume from Suspend

Actually, xfce4-power-manager doesn't use systemd/logind by default, but you can allow it to do so. See: https://docs.xfce.org/xfce/xfce4-power- … er-manager.

How did you create the .Xauthority file? What are its permissions?


Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#5 2026-07-12 14:46:26

jakfish
Member
Registered: 2019-12-23
Posts: 85
Windows 10Chrome 150.0

Re: Script Help for Max Brightness on Resume from Suspend

I simply created a file called .Xauthority in /home/jake

ls -l ~/.Xauthority
-rw-rw-r-- 1 jake jake 0 Jul 11 13:41 /home/jake/.Xauthority

Is that what we're looking for?

Edit: just to experiment: I removed /lib/systemd/system-sleep/xfce-resume-script.sh and ran

xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/logind-handle-suspend-key -n -t bool -s true

then

HandleLidSwitch=suspend

and

sudo systemctl restart systemd-logind

Upon resume, the initial brightness is the correct one, but after a second, it goes to maximum.

Last edited by jakfish (2026-07-12 15:56:01)

Offline

#6 2026-07-12 20:32:28

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 12,644
LinuxFirefox 152.0

Re: Script Help for Max Brightness on Resume from Suspend

I simply created a file called .Xauthority in /home/jake

The .Xauthority file should be created automatically. Do you have the xauth or xorg-xauth package installed?

To manually create the file, you should:

touch .Xauthority
chmod 0600 .Xauthority
xauth generate :0 . trusted

...from your home directory.

If that completes successfully, try the new system-sleep script again.


Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#7 2026-07-12 22:29:30

jakfish
Member
Registered: 2019-12-23
Posts: 85
Windows 10Chrome 150.0

Re: Script Help for Max Brightness on Resume from Suspend

Hi, ToZ. I did track down those steps earlier today--I deleted my original .Xauthority and created one properly. No dice, though. Script will execute the sleep command but not the xrandr.

It is interesting that my original install did not have ~/.Xauthority. Might be a Mageia thing, but not sure. I'm using Mageia 10 b/c it's one of the few 32-bit OSs that has a current xfce, etc. Until now, the Os has not missed the absence of .Xauthority, so perhaps it's lurking in another directory outside of /home.

Offline

#8 2026-07-13 00:06:35

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 12,644
LinuxFirefox 152.0

Re: Script Help for Max Brightness on Resume from Suspend

It looks like Mageia might save the file somewhere in /var/run - the live system shows /var/run/lightdm/live and its called "xauthority". If you run "xauth" on its own it will show the location (Ctrl-C to break out afterwards).

Use the path and location of this file in the script.


Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#9 2026-07-13 14:22:26

jakfish
Member
Registered: 2019-12-23
Posts: 85
Windows 10Chrome 150.0

Re: Script Help for Max Brightness on Resume from Suspend

export XAUTHORITY=/var/run/lightdm/jake/xauthority

only executes the sleep, not the xrandr command after reboot/suspend/resume.

Really appreciate you sticking with this, Toz, but please feel free to lose interest smile

Last edited by jakfish (2026-07-13 14:22:55)

Offline

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

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.019 seconds, 8 queries executed - Memory usage: 567.48 KiB (Peak: 584.46 KiB) ]