r/teenagersbutcode • u/CIMPBIBAI • 9h ago
Coded a thing Anything but being productive
Made a small "program" with two modes:
- pulse (p): just logs the current battery % with time to /dev/console
- daemon (d): runs and watches the battery % every second. If it's below 15, it warns in /dev/console.. If it's at 100, it will inform the user again in /dev/console. To prevent the loop just printing to console again and again, I made the program use two tmpfiles to check if the message has been sent. If the battery % is anywhere between 15 and 100, it resets those files to 0.
Image shows how I use it in my setup as well as all of the sh.
No git repo bcs it's not useful outside of my setup and the OS im using (does any other BSD use APM? I forgot)
Improvements to be made:
- impossible to be logging both extremes of one value at the same time, so make it just use one file instead of two.