Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 364  / 3 Years ago, sun, august 1, 2021, 2:34:22

I've written an Upstart job to automatically change display gamma according to change in display brightness:



start on (backlight-device-changed)
exec /usr/bin/gammach


And this is "gammach":



#! /bin/bash
Br=`cat /sys/class/backlight/acpi_video0/actual_brightness` # Display brightness
Gm=.$((((Br+76)%100))) # Corrected gamma according to brightness
xrandr --output LVDS --gamma $Gm:$Gm:$Gm


But every time i change brightness i receive this error in the log file:



Can't open display


I have tried xgamma, but received a similar error.

Any help appreciated. Thank you.


More From » brightness

 Answers
5

I finally found the answer.

Apparently it was with permission and authorization to access Xserver and stuff like that.

The xgamma version of my script that works like a charm is:



#! /bin/bash
export XAUTHORITY=/home/<username>/.Xauthority # This give permission to access Xserver
Br=`cat /sys/class/backlight/acpi_video0/actual_brightness` # Display brightness
Gm=.$((((Br+76)%100))) # Corrected gamma according to brightness
xgamma -d :0 -gamma $Gm

[#23730] Sunday, August 1, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
variark

Total Points: 82
Total Questions: 114
Total Answers: 122

Location: Sweden
Member since Mon, May 8, 2023
1 Year ago
variark questions
Wed, Nov 3, 21, 13:30, 3 Years ago
Sun, Jan 8, 23, 16:05, 1 Year ago
Thu, Dec 15, 22, 02:10, 1 Year ago
Sun, Jun 26, 22, 12:20, 2 Years ago
Tue, Dec 14, 21, 15:40, 2 Years ago
;