Skip to content
Paras Gupta

Feb 12 - Daily Programming Diary

Diary, Programming1 min read

16:30

Heya! I'm back here. At least for today. Since I am using i3wm, and there is no notification for when the battery is low, I think I need to do something about it. I just got my battery replaced, and it's imperative that I fix my charging habits.

So I'm making a script to notify me when the battery is low and I can work without thinking about it, or having my laptop plugged in 24/7.

17:30

Done! Okay, it is working but I just realized that I need some mechanism to shut it up just in case I'm sharing screen or giving a presentation somewhere. So there needs to be a flag somewhere.

The issue is that since the process will most probably be running at system startup, there is no way for the user to actually interact with the background process that it will become. So I am making another script that will be a multipurpose util script to manage flags in separate files.

18:00

Now whenever you plug in the charger, the notification will reset so that you don't have to toggle it manually again and again. The user can just run gotcha power and system will not show any notification related to battery being low, except at 5% when I think it's critically low. :p

The script can be found here.

19:00

Completed today's Leetcode Challenge

number-of-steps.cpp
1int numberOfSteps(int num) {
2 int ans = 0;
3 while (num != 0) {
4 ans++;
5 if (num & 1) {
6 num--;
7 } else {
8 num = num >> 1;
9 }
10 }
11 return ans;
12}

Good night!

EOD Checklist

  • Leetcode February Challenge
  • This blog
© 2022 by Paras Gupta. All rights reserved.
Theme by LekoArts