DEV Community

Mark Lambe
Mark Lambe

Posted on

I wrote a python script to output your Mac's total (and Daily Average) uptime since you bought it!

So I was curious about how much value my MacBook Pro was in a money-per-hour kinda way and decided to find out how many hours I'd used it for since I bought it.

This turned out to be relatively straightforward as some commands can be run to get the info we need.

The first thing we need to do is find the age of the /private/var/db/.AppleSetupDone file which gets created when the Apple setup is... done (🔝 name for a file tbh).

Then we get the number of hours the OS hard drive reports being used for. This limits things if you've replaced your hard drive but I'm not aware of a way around this.

From there it's some pretty simple maths and we have the answer!

The code is here on Github

I haven't spent a huge amount of time working on this so there could be better ways to do any of it, PR's welcome 😊

Top comments (0)