[SOLVED] How to enable automatic lower brightness on charger disconnected?
FedoraForum.org - Fedora Support Forums and Community
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2019
    Location
    Romania
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How to enable automatic lower brightness on charger disconnected?

    How would it be possible to have the brightness go down to say 25% when the charger is disconnected and than having it gone up to 75% when the charger is reconnected?

  2. #2
    Join Date
    Feb 2005
    Location
    London, UK
    Posts
    886
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to enable automatic lower brightness on charger disconnected?

    Your window manager (Gnome, KDE etc) might provide a way to do this through the config settings. If not then you'd have to script it, I'm not on on a laptop right now to help with that but you'll probably want to do a "while inotifywait" loop on the "/sys/class/power_supply/BAT0/status" file, inside the loop check that file to see if the laptop is plugged in (egrep 'Full|Charging') or not and then run the command for changing the brightness (xbacklight may work if you're not on Wayland yet).

    Writing the code without testing and from memory, so it probably won't work exactly as is:

    Code:
    while inotifywait -e modify /sys/class/power_supply/BAT0/status; do
      egrep -q 'Full|Charging' /sys/class/power_supply/BAT0/status && xbacklight -set 75 || xbacklight -set 25
    done
    Last edited by HaydnH; 12th April 2019 at 03:36 PM.

  3. #3
    Join Date
    Apr 2019
    Location
    Romania
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to enable automatic lower brightness on charger disconnected?

    Thanks for your response, I should have provided more information regarding the Fedora version:
    I am using Fedora 29 with GNOME 3.30.2 (Linux kernel 5.0.6) and it is running on Wayland (and the package xbacklight is not installed on the system)

  4. #4
    Join Date
    Feb 2005
    Location
    London, UK
    Posts
    886
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to enable automatic lower brightness on charger disconnected?

    I believe brightnessctl works on Wayland and is available in the repos to install with dnf, try install it and run "brightnessctl set 75%" to see if it works and then change the xbacklight commands above appropriately.

  5. #5
    Join Date
    Apr 2019
    Location
    Romania
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to enable automatic lower brightness on charger disconnected?

    Yes, brightnessctl does the trick, thank you!

Similar Threads

  1. Replies: 0
    Last Post: 2nd December 2017, 09:19 PM
  2. How to enable automatic login for init3?
    By mpajoh in forum Using Fedora
    Replies: 3
    Last Post: 4th February 2014, 11:09 PM
  3. Enable automatic DHCP through command line on Fedora15
    By JCatFedora15 in forum Servers & Networking
    Replies: 1
    Last Post: 15th July 2011, 08:11 AM
  4. How to enable lower display modes?
    By boh in forum Using Fedora
    Replies: 11
    Last Post: 18th June 2009, 07:24 PM
  5. Enable Automatic Update Check
    By Manaburner in forum Using Fedora
    Replies: 3
    Last Post: 2nd May 2006, 10:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •