tweakradje
New member
- Local time
- 7:43 AM
- Messages
- 31
Hi,
I couldn't find a good tool for adjusting my laptop backlight automatically based on the time of day.
So I decided to give it a shot and created this CMD file. It is very rough calculus but it kinda works.
Still need to do the maths for latitude/month correction (perhaps someone has a bright idea?)
I couldn't find a good tool for adjusting my laptop backlight automatically based on the time of day.
So I decided to give it a shot and created this CMD file. It is very rough calculus but it kinda works.
Still need to do the maths for latitude/month correction (perhaps someone has a bright idea?)
Code:
@echo off
REM ### Tweakradje 2014
REM ### Calculating sunrise/set and adjust backlight (very rough!)
REM ### Run it with windows scheduler e.g. every hour
REM BACKLMAX 12:00
REM /\
REM / \ 6:00
REM -/--18:00--/-- MONTH/LAT LINE UP/DOWN (HORIZON)
REM 6:00 \ /
REM \/
REM BACKLMIN 24:00
title Adjusting Backlight based on Time of day...
SET LATITUDE=52
SET MONTH=
SET HOUR=
REM BACKLDIM=10 minimal in steps of 5 upwards
REM BACKLMIN=20 minimal in steps of 5 upwards
REM BACKLMAX=100 maximal
REM DIMTIMEOUT=60 minimal in seconds
SET BACKLMAX=80
SET BACKLMIN=30
SET BACKLDIM=10
SET DIMTIMEOUT=120
SET /A BACKLDIF=%BACKLMAX%-%BACKLMIN%
SET BACKLEVEL=
REM Get the month, %DATE% like wo 15-10-2014
Set MONTH=%date:~6,2%
REM Get the Hour, %TIME% like 23:12:38,60
Set HOUR=%time:~,2%
REM For 24 hour Simulation REM next "Goto SKIP_SIMULATE" line
Goto SKIP_SIMULATE
FOR /L %%H IN (0,1,24) DO Set HOUR=%%H & Call :SKIP_SIMULATE
rem Pause
Exit /b
:SKIP_SIMULATE
REM ### BACKLEVEL goes from 0 > BACKLDIF/2 > BACKLDIF > BACKLDIF/2 > 0 by the HOUR
If %HOUR% LEQ 24 Set /A BACKLEVEL=2*%BACKLDIF%-%BACKLDIF%/12*%HOUR%
If %HOUR% LEQ 12 Set /A BACKLEVEL=%BACKLDIF%/12*%HOUR%
Set /A BACKLEVEL=%BACKLMIN%+%BACKLEVEL%
Echo Backlight Level at %HOUR%h: %BACKLEVEL%
Powercfg.exe -SetAcValueIndex SCHEME_CURRENT SUB_VIDEO VIDEODIM %DIMTIMEOUT%
Powercfg.exe -SetDcValueIndex SCHEME_CURRENT SUB_VIDEO VIDEODIM %DIMTIMEOUT%
Powercfg.exe -SetAcValueIndex SCHEME_CURRENT SUB_VIDEO VIDEODIMLEVEL %BACKLDIM%
Powercfg.exe -SetDcValueIndex SCHEME_CURRENT SUB_VIDEO VIDEODIMLEVEL %BACKLDIM%
Powercfg.exe -SetAcValueIndex SCHEME_CURRENT SUB_VIDEO VIDEONORMALLEVEL %BACKLEVEL%
Powercfg.exe -SetDcValueIndex SCHEME_CURRENT SUB_VIDEO VIDEONORMALLEVEL %BACKLEVEL%
Powercfg.exe /s SCHEME_CURRENT
Exit /b
Last edited:
My Computer
- OS
- win7