This script provides information for the time spent at your Mac with the screen actively turned on. The inspiration for this came from the Android (AOSP) OS with its built-in functionality to provide users with the time they spend looking at the screen in a given charge cycle.
- Use the Clone option above to copy the Git URL.
- Open up a terminal on your Mac and navigate to whatever directory you want to place the script in, eg
$ cd ~/path/to/directory
- Use
git clone https://github.com/rehmanh/Mac-Battery-Stats.git
- Add the screen_time script to your $PATH to be able to access it anywhere system-wide. In your
.*shrc
file add the following line before existing exports:export PATH="$PATH:$HOME/path/to/cloned/repository"
- Use the download link above to download a zipped version of the repository.
- Copy and paste the zip file into any directory you wish, then unzip the file to reveal its contents.
- Use the script from the directory by referring the usage options below, or
- Add the
screen_time
script to your $PATH to be able to access it anywhere system-wide. In your.*shrc
file add the following line before existing exports:export PATH="$PATH:$HOME/path/to/cloned/repository"
./screen_time <options>
from the repo directory, or
screen_time <options>
from any directory if the PATH is exported (see installation instructions above).
-r
: to get screen-time since most recent wake / boot-d
: to get screen-time of current date-A
: to get scree-time since device was last fully charged (for Macs with batteries)
- All options are working.
- Need to test all options for when user keeps machine on into the next day, more to come.
- Refactored some code, refactor more if possible.
- Apple defines "Charged" status as being anything over 95%.
screen_time
defines fully charged as a device reaching 100% charge. - reported time is inaccurate by mere seconds because of the fact that conversions from
Time
class are parsed to integers first. - Does not account for time-zone changes, or Daylight savings.