Out of the Darkness Comes Light

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.

  1. 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.
  2. Move the NirCmd files to C:\Program Files\nircmd.
  3. In that folder, create a new text file and name it DimScreenToggle.bat.
  4. 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.

  1. Save the file.
  2. Launch your Event Viewer (Windows Key + R, then type in eventvwr, and click OK.).
  3. On the left of the Event Viewer window, expand Windows Logs and then System.
  4. Next, unplug your laptop. Wait for a second or two, and plug it back in.
  5. From the menu, select Action -> Refresh. You should see two new events at the top. Note the Event ID.
  6. Right click on one of the two events, and then on Attach Task To This Event.
  7. 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.
  8. Click Next again on the following screen (When an event is Logged).
  9. In Action, keep the selection on Start a program. Click Next.
  10. Click Browse, then find the DimScreenToggle.bat file you created earlier. Select it and click Open.
  11. Leave the rest as is, and click Next.
  12. Tick the Open the Properties dialog for this task when I click Finish checkbox. Click Finish.
  13. In the properties window that opened, go to the Triggers tab.
  14. Click on New… to add a new trigger.
  15. In the Begin the task dropdown, select At startup.
  16. Tick Delay task for, and set the time to 5 seconds.
  17. Click OK to dismiss the new trigger window.
  18. Under Conditions, make sure Start the task only if the computer is on AC power is unticked.
  19. 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!

Take My Money! (Part 2 of 2)

In my previous post, I mentioned figuring out what I want to buy early helped. In short, it let me wait longer for the right price. There is another reason why figuring it out early helps. It also means I may be able to order it for much less directly from China.

It’s surprising how many products on sale you can find for a fraction the price on AliExpress.com. AliExpress is kind of like a Chinese Amazon. You can find virtually anything there. And it’s CHEAP. The catch? You often have to wait for about a month before you get your order.

Since 2013, we have another alternative. You probably encountered it already. It’s called Wish, and it is American. Similarly to AliExpress, you can find almost anything you can think of there (and something you would never think of!). And similarly, it’s dirt cheap and takes up to a month to ship. If you use my link above, both you and I will receive money in credit.

At some point I’ll highlight some of the more useful products I found on AliExpress. So stay tuned! Oh, and feel free to share your finds in the comments section.

I may get commissions for purchases made through links in this post.

Take My Money! (Part 1 of 2)

Well, actually… Don’t. I’d rather keep as much of it as I can to myself, if you don’t mind. This time, I’m talking about buying stuff online.

I’ve learned one important thing about shopping online. Prices fluctuate – sometimes quite drastically. So, it seems the best strategy is to figure out what you want to buy as soon as possible. Ideally, figure out what you want to buy long before you actually need it. The sooner you figure it out, the longer you can wait for the price to drop.

Naturally, as my list of things I want to buy grows longer, I can’t keep checking Amazon every day for their price. Along come a few websites that actually help you keep track of price drops.

The first, and my personal favourite, is camelcamelcamel.com. This website offers a free service of tracking prices for you. You simply paste in a link to the product you’re interested in. You then set your target price and start tracking. You can even see how the price of the product fluctuated over time.

Another helpful service here in the UK and in some of Europe is pricespy.co.uk. PriceSpy is another free service. It tracks products for you, just like camelcamelcamel. But it also compares prices between different stores. So even if you can’t wait with your buy, PriceSpy is there to help you find the best price.

I’m sure you get the idea by now. If we use a free service to track products, we can get them when the price drops. This can actually save us a lot of money.

Away With the Boilerplate!

About a year and a half ago, I audited an Android project for a client. One of the glaring observations was that the test coverage was quite poor.

To improve the test coverage, I had to write a lot of code. A lot. Since I’ve written plenty of unit tests before, and knew I’d be writing a lot more after, I made a decision. Given how every unit test followed the same pattern, I decided to automate the process. TestIt was born. I’ve never looked back since.

TestIt is a unit test boilerplate generator for Kotlin. It analyses the code for you, finds testable code and generates a set of Given/When/Then test templates for it. All you have to do is fill in the logic of the underlying code.

The project is open sourced, so feel free to contribute to it. Maybe it will inspire you to develop a similar one for another language. If it does, let me know!

Untangling My Cables

I spent more time than I’d like to admit choosing the topic I’d share with you first.

There is a broad range of topics I’d like to cover in this blog. But A journey of a thousand miles begins with a single step and yada yada. So here we are. The first step.

Let’s start with something too technical. I’ll share with you a small optimisation that keeps giving me great satisfaction. I’m talking, of course, of not having to deal with tangled cables in my backpack.

As a developer, specifically a mobile developer, I end up with quite a few cables in my bag. USB to USB-C, USB-C to USB-C, earphones (I don’t always want the hassle of pairing my wireless headphones. Sometimes plugging in a cable is quicker and simpler). So, what happens is, the cables become a tangled mess. They used to, anyway. Then I discovered the magic of cable organisers.

The one I’ve used right up until the pandemic was the GiBot Cable Organiser. I cannot recommend this organiser enough. It has plenty of space for all your cables and even a portable charger. My backpack has never been tidier. I must say, using it at the office and taking out the cables I needed has drawn quite a lot of positive attention. I’ve already recommended it to a few of my colleagues.

Now, I’m not crazy about it not being more rigid. But, that does mean it’s easier to stick in the backpack, and it is really quite slim.

The BUBM Traveler Case. I have recently replaced the GiBot for another, somewhat similar organiser. Since I’ve been home from early in the pandemic, I never had the opportunity to try it out. I do like how it’s got compartments for everything, and the BUBM is rigid, unlike the GiBot. On the flip side, it also takes up more space. So I’m definitely not parting with my GiBot just yet. I got it after a lot of online research, so I expect it won’t let me down. I’ll update this post when I formed an opinion.

I may get commissions for purchases made through links in this post.


Hi. My name is Eran and I’m a software consultant since I can remember myself. But this blog is not about me. It’s about something I care deeply about and want to share my experience of with you.

This blog is about how I’m endeavouring to optimise my life. Hopefully some of my experiences will apply to your life as well.

So, what do I mean by optimising my life? Quite a few things, really. I mean automating menial tasks so that I don’t have to spend time and the cognitive drain that ensues. I mean improving my experience when menial tasks are unavoidable. I also mean improving myself so that I can do things better, both at work and at home.

Now, these will be my personal experiences I’ll be sharing with you. I don’t believe there’s a one-fits-all solution to our daily problems. I’m hopeful some of my advice will be relevant to yours. If any of it is – I’ve achieved my goal.

Enjoy your read!

Want to reach out? You can find me on LinkedIn.