This is a continuation of a series:
- Introduction
- Questions I want to answer
- Questions part 2
- Processing part 1 (this post)
I’ve made some tiny changes to the logging output of my window tracking script (repository on GitHub):
- Added a tab between the timestamp and window title so I can treat it as a TSV file
- Split out each day’s logs into a new file
I’m starting with basic command line tools and will work my way up to adding on my own scripts when appropriate.
First basic question: for the first two weeks of the year, how many minutes were spent in front of the computer?
Using ripgrep with the -u
flag because my log files are ignored by my .gitignore
file to keep them from being committed to the repository:
cd logs/
rg -u 'no active window' | wc -l
> 14621
rg -uv 'no active window' | wc -l # -v for inverse, lines that don't match
> 5320
5320 minutes is almost 89 hours.
I can also easily find my most frequently seen window titles:
cd logs/
cat * | cut -f 2 | sort | uniq -c | sort -rn | head -30
Explaining these commands:
cat *
prints all the contents of all the files in the directorycut -f 2
prints only the second “field” of each line, with tab being the default separatorsort
sorts alphabetically, important here withuniq -c
uniq -c
removes repeated adjacent lines, printing the total count of the line printed plus the number of removed lines. Thanks tosort
, I know that the count here is global to all the files examined as identical lines will all have been sorted alphabetically adjacentsort -rn
sorts numerically “reversed” or in descending order high-to-lowhead -30
shows only the first 30 lines
I’m not going to publish all of the output here, but these two lines at the top stand out to me:
215 [Slack] Unread Messages - GitHub-grid - Slack
182 [zoom.us] Zoom Meeting
^ 3.5 hours over the last two weeks just looking at my “All Unread Messages” view in Slack.
Personal goal: cut that in half over the next two weeks.