Sunspot Home. . . . . . Joggler menu
Change screen brightness on mouse activity
Objective
Have the screen LED backlight dim after a period of mouse inactivity
- then have it brighten when the screen is touched or the mouse moved
I found a small python script that could detect mouse activity by observing /dev/input/mice
I made it write "mouse_moved" to a file mouse_moved.txt in /var/www/ramdisk
#! /usr/bin/python fh = file('/dev/input/mice') |
I have a Blassic basic "watchdog" program that loops continuously and monitors files in the ramdisk and then takes action as needed.
I made it watch the file
/var/www/ramdisk/mouse_moved.txt
On mouse activity it brightens the screen then starts a count that counts down as the watchdog loops.
At the end of the count the screen is dimmed to minimum brightness.
#! /usr/sbin/blassic ' startup values LABEL DoItAgain IF (back_light_count = 0) THEN GOTO IgnoreBacklight OPEN "/var/www/ramdisk/mouse_moved.txt" FOR INPUT AS #1 : INPUT #1,mouse$ : CLOSE #1 OPEN "/var/www/ramdisk/command.txt" FOR INPUT AS #1 : INPUT #1,command$ : CLOSE #1 GOTO DoItAgain LABEL Command_wait_loop ' just loop and wait for a command LABEL Command_David
LABEL Command_Stephen
LABEL BrightBackLight LABEL DimBackLight SYSTEM |
Footnote
You can set the screen to black after a chosen delay as below - but this does not actually turn off the LED backlight
- it just blacks the LCD screen.
turn screen "off" Thanks to - - - this post # Following lines disable screen blanking in /etc/X11/xorg.conf to this:- (Change 2 to the time in minutes you want it to be idle before the display sleeps). Much better for the bedroom! |
in
etc/environment
add
DISPLAY=:0.0
as a new line
To turn the backlight off
xset dpms force off
(DPMS is display power management)
If you touch the screen/move the mouse it comes on again
turn it on by script
xset dpms force on
turn off after 100 seconds
xset dpms 100 101
(100 seconds to standby, 101 to all display power off - standby turns the LEDs off on this display)
Type xset alone to see the other options
Comments? email me