Terminal command for checking/unchecking "Dim screen to save power"?

You can get its status by using gsettings command as following:

gsettings get org.gnome.settings-daemon.plugins.power idle-dim

This will return "true" or "false". So if you want change its value use set option instead of get and type "true" to enable it or "false" to disable:

gsettings set org.gnome.settings-daemon.plugins.power idle-dim true

Now if you don't want to dim the screen when you are on battery power you need some scripting, because that setting doesn't detect or watch the state that if you are on ac-power or on battery mode.

This can be done by using on_ac_power command inside a while-loop to checking whether the system is running on AC power as following:

#!/bin/bash
while true
do
    if on_ac_power; then
        gsettings set org.gnome.settings-daemon.plugins.power idle-dim true
    else
        gsettings set org.gnome.settings-daemon.plugins.power idle-dim false
    fi
    sleep 60   # check the state in each 60 seconds
done

Save the script.ex: dimscreen.sh and run it by typing sh /path/to/dimscreen.sh in Terminal.


Also you can make it as a cron job in your crontab file.

#!/bin/bash
if on_ac_power; then
    gsettings set org.gnome.settings-daemon.plugins.power idle-dim true
else
    gsettings set org.gnome.settings-daemon.plugins.power idle-dim false
fi
  1. Saving the script (example dimscreen.sh)
  2. Make it executable chmod +x /path/to/dimscreen.sh
  3. open the crontab file by VISUAL=gedit crontab -e or EDITOR=gedit crontab -e

  4. Now copy and paste * * * * * /path/to/dimscreen.sh at end of it and save the file. This will run your command/script every minute

    .---------------- minute (0 - 59)
    |  .------------- hour (0 - 23)
    |  |  .---------- day of month (1 - 31)
    |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
    |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
    |  |  |  |  |
    *  *  *  *  * command to be executed

The unchecking is not working for some reason even in terminal. Thanks for another elaborate answer. Unfortunately I am a novice. So, I won't bang my head to understand your method. But I think I have found a workaround. The problem I was facing was that the screen would dim to certain brightness when on battery power and when idle. If you do this in the terminal:

gsettings get org.gnome.settings-daemon.plugins.power idle-brightness

you get the idle brightness. So I set this equal to my actual brightness of the screen. using:

gsettings set org.gnome.settings-daemon.plugins.power idle-brightness 70

Problem solved.