GithubHelp home page GithubHelp logo

stormc / brightnessd Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 20 KB

Daemon regulating screen brightness depending on user input (in)activity

License: MIT License

Makefile 2.50% C 96.78% Shell 0.73%
screen-brightness c xrandr brightness-daemon sysfs

brightnessd's Introduction

brightnessd

brightnessd regulates screen brightness depending on user input (in)activity: When inactive for a certain period of time, brightnessd darkens the screen in two consecutive stages, without freezing screen content. Upon user input activity, the screen's previous brightness is restored.

brightnessd is most useful in combination with window managers such as awesome since Desktop Environments mostly provide such a functionality via their power management utilities.

Features

  • dims the screen brightness in two stages
  • supports XRandR as well as sysfs backend
    • when using the XRandR backend for brightness adjustment, no (root) write permissions to /sys/class/backlight/<backlight>/* are required
    • if XrandR is not supported by the video card driver, the sysfs backend can be enabled via compile-time switch
  • uses the X11 Screen Saver Extension to determine user (in)activity, i.e., no polling of input devices or idle times
  • no screen content freeze when dimmed, i.e., you can continue watching videos -- albeit a bit darkened

Installation & Configuration

First, install the following libraries and their development headers:

Then checkout, make, and run brightnessd

git clone https://github.com/stormc/brightnessd.git
cd ./brightnessd
make
./brightnessd
# press CTRL+C to abort

To install brightnessd to /usr/bin/brightnessd, run as root

make PREFIX=/usr install

The default compiler is set to clang. If gcc should be used instead, provide the CC=gcc option to make, e.g.,

make CC=gcc

The make target sysfs uses the sysfs backend while the default xrandr target uses the XRandR backend. When using the sysfs backend, the path to the directory containing the files brightness, max_brightness, and actual_brightness should be specified via the SYSFS_BACKLIGHT_PATH="/sys/class/backlight/<directory>" option to make. It defaults to /sys/class/backlight/intel_backlight/.

make sysfs CC=gcc SYSFS_BACKLIGHT_PATH="/sys/class/backlight/intel_backlight"

brightnessd dims the screen in two stages corresponding to X11 Screen Saver Extension's timeout and cycle values. Upon timeout seconds of user input inactivity, it dims the screen to DIM_PERCENT_TIMEOUT% of its maximal brightness. Upon further inactivity for cycle seconds, it dims the screen to DIM_PERCENT_INTERVAL% of its maximal brightness. Both values can be defined by providing DIM_PERCENT_TIMEOUT=<value> and DIM_PERCENT_INTERVAL=<value> options to make, e.g,

make sysfs CC=gcc SYSFS_BACKLIGHT_PATH="/sys/class/backlight/intel_backlight" DIM_PERCENT_TIMEOUT=40 DIM_PERCENT_INTERVAL=20

DIM_PERCENT_TIMEOUT defaults to 40% and DIM_PERCENT_INTERVAL defaults to 20% of the maximal screen brightness.

Use xset s 240 60 to set timeout to 240 seconds and cycle to 60 seconds, respectively. See man 1 xset for further options to set with respect to the screensaver.

Q&A

Come on, yet another brightness daemon? There are brightd, ...

True. brightnessd was done just for fun and to code some application in C using xcb.

brightnessd behaves strangely, what can I do?

Please recompile brightnessd with the debug or debug_sysfs make target, respectively, to get more information on what's going on while brightnessd runs. The resulting log is usually helpful in identifying problems or bugs.

I found a bug! I'm missing a feature!

Pull Requests are very welcome, feel encouraged to provide a patch!

License

Copyright © 2015 Christian Storm

Released under the MIT License, see LICENSE for details.

brightnessd's People

Contributors

stormc avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.