The /sys directory is a bit like the /proc virtual file system which I discussed in my last post.
Continuing the "everything is a file" approach, the /sys directory gives you access to many system components and their parameters.
My prime consideration is whether I can control the display backlight on my laptop.
The ASUS X401A Backlight
Running Lubuntu on my ASUS laptop, I find the display backlight always starts up at full brightness. I've looked at this issue a couple of times to see if there is a config value that I can set to start at (say) half brightness. Well if there is, I still haven't found it.
But I started poking around the /sys directory and found:-
/sys/class/backlight/intel_backight
Now because there are a number of symbolic links involved in the path as shown by the file manager, hitting F4 (which opens the current path in terminal) reveals the real path to be:-
/sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-LVDS-1/intel_backlight
In this directory there are a few text files with promising names like "actual_brightness" and "max_brightness"
The Max_brightness file just contains the value: 4296
And after setting the display brightness to minimum using the fn+F5 key combo, I can see that the operating range is: 471-4296
Back in the terminal window I find I can set the display brightness via the file "brightness" by using the "echo" command to send it a new value like this:-
sudo echo 1000 > /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-LVDS-1/intel_backlight/brightness
And it turns out that "1000" is a pretty comfortable level for normal indoor use. But I still haven't found the source of the setting. The brightness level still changes each time I log-in.
So my solution is to create a very simple script that runs after log-in. I've called mine SetBacklight.sh and it looks like this:-
#!/bin/bash
echo 1000 > /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-LVDS-1/intel_backlight/brightness
This has to be run as root after log-in (not during boot) so I make it executable (via file manager > Properties > Permissions) and save it in: /usr/bin
Lubuntu uses the X display manager LightDM, so I can add this line to the end of /etc/lightdm/lightdm.conf:-
session-setup-script=/usr/bin/SetBacklight.sh
...and now, each time I log-in, the script is run with root permissions and the display is dimmed.
Other stuff in /sys
Here are some other /sys locations that may be of interest:-
- Bios, board, chassis & product data: /sys/devices/virtual/dmi/id
- cpu temperatures, limits & critical alarms: /sys/class/hwmon/hwmon0
- Real-time clock: /sys/class/rtc
- Power supply (mains/battery): /sys/class/power_supply
No comments:
Post a Comment