You are not logged in.

#1 2021-10-25 08:01:00

Corona
Member
Registered: 2021-10-01
Posts: 1

Recover brightness after waking up.

Everytime my machine waking up from sleeping, it's brightness will be reset to 100%. I tried to follow  https://wiki.archlinux.org/title/Power_ … stem-sleep, and wrote following script in /lib/systemd/system-sleep:

#!/bin/sh
case $1 in
    pre)  ;;
    post)
	bright=`cat /home/corona/.brightness`
	echo "`date`:Brightness is ${bright}."
	sleep 3
	xbacklight -set $bright
	if test $? -eq 0; then 
            echo "Brightness Successfully Recoverd."
	else
            echo "Brightness Failed to Recover."
	fi
    ;;
esac

File .brightness contains brightness since i last change it.

But it doesn't work. Using

 journalctl -b -u systemd-suspend.service 

it tells me:

Oct 25 15:34:04 corona systemd-sleep[16557]: Entering sleep state 'suspend'...
Oct 25 15:34:13 corona systemd-sleep[16557]: System returned from sleep state.
Oct 25 15:34:13 corona systemd-sleep[16768]: Mon Oct 25 03:34:13 PM CST 2021:Brightness is 19.733525.
Oct 25 15:34:13 corona systemd-sleep[16775]: RANDR Query Version returned error -1
Oct 25 15:34:13 corona systemd-sleep[16768]: Brightness Failed to Recover.
Oct 25 15:34:14 corona systemd[1]: systemd-suspend.service: Deactivated successfully.
Oct 25 15:34:14 corona systemd[1]: Finished System Suspend.
Oct 25 15:35:53 corona systemd[1]: Starting System Suspend...
Oct 25 15:35:53 corona systemd-sleep[17440]: Entering sleep state 'suspend'...
Oct 25 15:35:59 corona systemd-sleep[17440]: System returned from sleep state.
Oct 25 15:35:59 corona systemd-sleep[17600]: Mon Oct 25 03:35:59 PM CST 2021:Brightness is 19.733525.
Oct 25 15:36:02 corona systemd-sleep[17770]: RANDR Query Version returned error -1
Oct 25 15:36:02 corona systemd-sleep[17600]: Brightness Failed to Recover.
Oct 25 15:36:02 corona systemd[1]: systemd-suspend.service: Deactivated successfully.
Oct 25 15:36:02 corona systemd[1]: Finished System Suspend.

I don't know what's wrong with "RANDR Query Version returned error -1"

My laptop is MacBookAir 2017, Intel i5 5350U

Offline

Board footer

Powered by FluxBB