One topic I’ll probably be writing about a lot is batteries. I believe I may be a bit obsessed about the matter. I keep my devices charged whenever possible. I’m constantly aware they are living on borrowed time.
I recently switched back from using MacBook Pros to Windows 10 on a Dell XPS. I found out Microsoft removed the option to automatically dim your screen on battery. Since I haven’t used Windows in a while, this was a surprise to me.
I started dimming the screen manually every time I unplugged my laptop. Then setting the brightness back up when plugging in. This did not always work for me. Sometimes I forgot to do it. The rest of the times just felt… Repetitive.
So I thought to myself – surely this could be automated. I did a little bit of digging. Guess what – it CAN be. I’ll save you the trouble of investigating this yourself. You will need a little (very little, I promise) technical knowledge.
- Download NirCmd. You probably want the 64 bit version. You can use another command line tool that can toggle the screen brightness if you prefer.
- Move the NirCmd files to C:\Program Files\nircmd.
- In that folder, create a new text file and name it DimScreenToggle.bat.
- Open the new file in NotePad or your favorite editor, and paste the following into it:
@echo off set DimScreen=""c:\Program Files\nircmd\nircmd.exe" setbrightness 0" set UndimScreen=""c:\Program Files\nircmd\nircmd.exe" setbrightness 100" set Scr="%temp%\DimScreenToggler.vbs" set VB=echo^>^>%Scr% if exist %Scr% del %Scr% %VB% Set oWMIService = GetObject("winmgmts:\\.\root\CIMV2") %VB% Set cItems = oWMIService.ExecQuery("SELECT * FROM Win32_Battery") %VB% For Each oItem In cItems %VB% iStatus = oItem.BatteryStatus %VB% if iStatus = 1 then WScript.echo "On battery" Else WScript.Echo "Mains operation" %VB% WScript.quit iStatus %VB% Next cscript //nologo %Scr% IF %ErrorLevel% EQU 1 (start /b "Dim Screen" "%DimScreen%") ELSE (start /b "Undim Screen" "%UndimScreen%")
The above creates a script that checks the power source and sets the screen brightness accordingly: to 0 if on battery, or to 100 if plugged in. You can adjust these numbers to fit your preference.
- Save the file.
- Launch your Event Viewer (Windows Key + R, then type in eventvwr, and click OK.).
- On the left of the Event Viewer window, expand Windows Logs and then System.
- Next, unplug your laptop. Wait for a second or two, and plug it back in.
- From the menu, select Action -> Refresh. You should see two new events at the top. Note the Event ID.
- Right click on one of the two events, and then on Attach Task To This Event.
- In the new Create Basic Task Wizard window, fill in a name for your task (Toggle screen brightness by power source would work). Click Next.
- Click Next again on the following screen (When an event is Logged).
- In Action, keep the selection on Start a program. Click Next.
- Click Browse, then find the DimScreenToggle.bat file you created earlier. Select it and click Open.
- Leave the rest as is, and click Next.
- Tick the Open the Properties dialog for this task when I click Finish checkbox. Click Finish.
- In the properties window that opened, go to the Triggers tab.
- Click on New… to add a new trigger.
- In the Begin the task dropdown, select At startup.
- Tick Delay task for, and set the time to 5 seconds.
- Click OK to dismiss the new trigger window.
- Under Conditions, make sure Start the task only if the computer is on AC power is unticked.
- Click OK to dismiss the properties window. You’re done!
To test your new setup, try unplugging your laptop. It should dim the screen almost immediately. Plug it back in to see the screen brighten up.
With this setup, expect a significant boost to your battery life. Let there be light!