GithubHelp home page GithubHelp logo

patrickjwhite / backlight Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 3.0 392 KB

Tool to control screen brightness below lowest level offered by Ubuntu interface.

License: GNU General Public License v3.0

Go 97.89% Shell 2.11%

backlight's Introduction

backlight

As of now, this is a crude tool built on Qt 5.2 to provide a simple slider for controlling my system's LED backlight.

screenshot

Why?

My purpose is to have finer control over the backlight than what the native Ubuntu slider can offer. I have a MacBook Pro turned into a TuxBook and the minimum screen brightness that I can set is still too bright when I'm working at night but the hardware does allow a less bright screen, since on OS X I can have this, so this is barely an user interface limitation.

How it works?

I have found that controlling the backlight brightness is quite simple, I just have to fill in a number under /sys/class/backlight/intel_backlight/brightness, and the maximum brightness can be read from /sys/class/backlight/intel_backlight/max_brightness. Notice that these are system specific configuration files. I have an intel based MacBook Pro, with no dedicated graphics card. The slider just fill in a value in the brightness file from 0 up to the value read from max_brightness. The brightness file is created by the system at each boot, and its permissions prevent changes from non-privileged users. So, by default to change it one must alter it under root. To avoid always have to run the tool under root I instead created a simple script to run on each boot that relax the permissions for the brightness file so any user can make changes.

Requiriments

  • Qt (>=5.2.0)

  • If Go QML is not already installed, a prior proper Qt 5 environment for building the dependency is necessary. For Ubuntu I use the following:

      QT5PATH=<Qt 5 install location>
      QT5VERSION=<Qt 5 Version Number, e.g., 5.2.0>
      export PKG_CONFIG_PATH=$QT5PATH/lib/pkgconfig
      export CGO_CPPFLAGS=-I$QT5PATH/include/QtCore/$QT5VERSION/QtCore
    

    more instructions in the Go QML repository.

Installation

go get github.com/oblitum/backlight

I don't provide an install package, so, the installation is sparse currently.

  • the tool is the single generated executable installed under $GOPATH/bin.
  • There's a .desktop file that should be copied to ~/.local/share/applications/ and a corresponding svg icon that should be copied to ~/.local/share/icons/backlight/. Please, edit the .desktop file with a text editor for setting the correct icon path. This must be a fully expanded path.
  • There's a backlight.sh script to relax file permissions of the backlight system files. It should be copied to /etc/init.d/ and after that the command sudo update-rc.d -f backlight.sh defaults 99 should be executed for registering the script to execute on boot.

Usage

The tool is a simple slider, to close it press space or escape. If you install the .desktop and icon you can find the tool in the Dash by typing backlight and it can be dragged to the Launcher.

Other tidbits

For my machine I've altered boot parameters to avoid the system having two places for backlight changes. If I didn't do that, backlight could be set both from /sys/class/backlight/intel_backlight/brightness and from /sys/class/backlight/acpi_video0/brightness. Having two sources of modification cause the system brightness control not be in sync with this tool. To make the system use only the single real source of backlight modification I change the /etd/default/grub boot parameter line to the following, adding the acpi_backlight=vendor to the end:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_backlight=vendor"

After changing I run sudo update-grub for it to take effect.

By the way, I changed my Ubuntu to boot with EFI boot, which is much faster.

Notice

This is the Go port of the original C++ project. For the C++ version check the cpp branch.

backlight's People

Watchers

James Cloos avatar Patrick White 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.