Skip to content

backlight is a POSIX shell script that allows you to get and set the brightness of the screen via /sys/backlight if supported by your system.

Notifications You must be signed in to change notification settings

fraxflax/backlight

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 

Repository files navigation

backlight

backlight is a POSIX shell script that allows you to get and set the brightness of the screen via /sys/backlight if supported by your system. It also helps you set the permissions allowing a specific group to set the brightness.

See the examples folders for an example on how to use it to dim the screen when locking it, restoring the brightness when the screen is unlocked.

SYNOPSIS:

backlight [ OPTIONS ] [ -g | --get | -get ]
Get the current brightness value in percent of MAX brightness.

backlight [ OPTIONS ] [ -s | --set | -set ] percent
Set the brightness to 'percent' of max brightness. 'percent' is an integer (anything trailing the first consecutive digits is ignored (e.g. a %-sign), allowing you to use the --get output as --set input without modification).

backlight [ OPTIONS ] { -i | --increase | -inc } step
backlight +step
Increase the brightness by step percent units of max brightnes.

backlight [ OPTIONS ] { -d | --decrease | -dec } step
backlight -step
Decrease the brightness by step percent units of max brightnes.

backlight [ OPTIONS ] { -o | --off }
Set the brightness to 0 (turn the backlight off).
-s and -d will never completely turn the brightness off, as it might have the consequence that when running xset dpms force on the brightness will unexpectedly be increased.

backlight --install [ groupname ]
Allow the specified group (or the video group if none specified) to set the brighness forth on.

If systemd is in use 'backlight --install' will also install, enable and run a systemd service making 'brightness' writeable by the specified group at system startup.

'backlight --install' will replace the /etc/systemd/system/backlightgroup.service if it already exists.

'backlight --install' must be executed with effective user-id 0 (run as root / with sudo).

OPTIONS: --sysfs [ first | /sys/class/backlight/device | all ]

backlight --sysfs first ...
Use the first device found in /sys/class/backlight/ . (This is the default.)

backlight --sysfs /sys/class/backlight/intel_backlight ...
Use the specified backlight device, e.g. intel_backlight.

backlight --sysfs all ...
Do the operation for all backlight devices found in /sys/class/backlight/ .

EXAMPLES:

Get current backlight brightness:
backlight --get

Set backlight brightness to 75%:
backlight 75

Increase backlight brightness with 5%-units:
backlight +5%

Decrease backlight brightness with 5%-units:
backlight -d 5

Turn screen off (set brightness to 0) for all backlight devices.
backlight --sysfs all --off

Flash the screen, restoring the backlight brightness afterwards:
B=$(backlight); backlight 0 ; sleep 0.5 ; backlight 100 ; sleep 0.5 ; backlight 0 ; sleep 0.5 ; backlight $B

About

backlight is a POSIX shell script that allows you to get and set the brightness of the screen via /sys/backlight if supported by your system.

Resources

Stars

Watchers

Forks

Languages