4

I need to change my monitor's gamma settings permanently to the value of 0.7. I've tried using xgamma for this, but the thing is I have to execute this command everytime I start my laptop. Also, the gamma settings seem to revert to their original values (1.0) if something significant happens - when I copy/delete something, when I play media from my external hard disk, etc.
I tried making a custom script which reads like:

#!/bin/bash
xgamma -gamma 0.7

Saved it as gammasettings.sh, put it up into my list of start-up applications; but it fails to work for some reason.

Changing these settings again and again is a really cumbersome. Is there a way to make these changes permanent (edit any .conf file or something)?

Tarun Verma
  • 43
  • 1
  • 5

4 Answers4

1

Redshift applies additional gamma correction, so it may not play nicely with xgamma (i.e. together they may over-correct).

My solution is:

  1. Put xgamma -quiet -gamma 0.7 in session/Application Autostart
  2. Put redshift-gtk (without gamma setting, but you can use -l LAT:LONG parameter for if location service fails) in session/Application Autostart
  3. Have a link to run xgamma -gamma 0.7 in case something deactivates the correction

Then you can deactivate Redshift temporarily, say for watching a video, and it will not affect the gamma.

1
  1. Install redshift, sudo apt-get install redshift
  2. In terminal, gnome-session-properties
  3. Add redshift -t 6500k:6500k -g .7:.7:.7 (the first 6500k is temp color for day, the second for night, - 6500k is default temp color- you can change the values) (.7 is my gamma setting)
  4. Install dconf-editor sudo apt-get install dconf-editor
  5. Open dconf-editor, org->gnome ->gnome-session and check "auto-save-session"
  6. Reboot
Juan
  • 26
0

I had a similar problem. For me this interesting approach works well, using custom systemd service that periodically checks/set correct gamma level. This can also be used to maintain correct screen resolution, etc.
Also important step is to create a timer that triggers above service in periodic intervals. Service and its timer should have the same names.

There are 2 locations in which systemd services can be kept
/etc/systemd/system/ # system-wide location
/home/username/.config/systemd/user/ # user-specific location

For example create a gamma_corrector.service with below content in this folder /etc/systemd/system/
sudo nano /etc/systemd/system/gamma_corrector.service

[Unit]
Description=Gamma Level 2.0 Corrector

[Service] Type=simple User=username # write your username here
#ExecStart=/home/username/Desktop/gamma_corrector.sh # script can be used instead of single line command ExecStart=/usr/bin/xrandr --output HDMI-1 --gamma 2.0:2.0:2.0 # or /usr/bin/xgamma -gamma 2.0 #Restart=always Restart=on-failure Environment=DISPLAY=:0 # you can check your display environment value this way echo $DISPLAY and set it here #RemainAfterExit=yes RemainAfterExit=no TimeoutStartSec=10 StandardOutput=syslog StandardError=syslog

[Install] WantedBy=multi-user.target

create a gamma_corrector.timer to trigger above gamma correction service every 1 minute with below content in this folder /etc/systemd/system/
sudo nano /etc/systemd/system/gamma_corrector.timer

[Unit]
Description=Run Gamma Level Corrector every minute

[Timer] OnCalendar=--* ::00 # trigger the service every minute 01:00 - 59:00, etc. Persistent=true OnActiveSec=1min OnUnitActiveSec=1min AccuracySec=1s

[Install] WantedBy=timers.target

then run this command to make systemd incorporate this new service and its timer
sudo systemctl daemon-reload
then
xhost +SI:localuser:$(whoami) # to allow current user to access the X server:
sudo systemctl enable gamma_corrector.service
sudo systemctl enable gamma_corrector.timer
sudo systemctl start gamma_corrector.service
sudo systemctl start gamma_corrector.timer

then you can check if this gamma corrector timer works correctly and specified intervals
sudo systemctl list-timers

0

Make executable gammasettings.sh

chmod +x gammasettings.sh

Then modify the script like this

#!/bin/bash
sleep 1
xgamma -gamma 0.7

On my VAIO with Ubuntu 14.04 works like a charm :)

CFW
  • 1