8

I am having problems preventing my laptop, running Ubuntu 14.04, from dimming its screen when on battery power. I have tried everything that is out there on the internet to prevent this happening, but in vain. Most people solved their issue by unchecking the tick box beside "Dim screen to save power" in the "Brightness and lock" settings. I have tried that as well.

So is there any way to do this from the terminal?

user2574723
  • 195
  • 1
  • 11

2 Answers2

10

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
αғsнιη
  • 35,660
  • Instead of giving a tutorial on editing in vim, do: VISUAL=gedit crontab -e, or EDITOR=gedit crontab -e. – muru Dec 27 '14 at 09:56
  • This is a very contrived workaround. Marc nailed the problem in the other answer to a known bug in 14.04. Let's fix bugs instead of messing up with the system. – Johan Boulé Jun 19 '16 at 13:47
4

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.

αғsнιη
  • 35,660
user2574723
  • 195
  • 1
  • 11
  • 1
    There is a bug in 14.04 causing the "idle-dim" value to be ignored. Hence making KasiyA's answer inadequate (and indeed overcomplicated).

    Your solution can be slightly improved: I noticed that if the "idle-brightness" setting is higher than the brightness at the moment the screen would dim, it just doesn't dim. So a workaround to disable dimming is to set "idle-brightness" to 100 which won't cause the screen to go brighter (or darker) no matter what your actual brightness setting is.

    – Marc Oct 20 '15 at 15:22
  • @Marc It's 2022 now, I'm on 22.04 LTS, and this is still true. Sheesh. – Radu C May 11 '22 at 23:00