Skip to content

Instantly share code, notes, and snippets.

@holmboe
Last active January 10, 2019 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save holmboe/0c4150c4bad5c386c513611e2f72912f to your computer and use it in GitHub Desktop.
Save holmboe/0c4150c4bad5c386c513611e2f72912f to your computer and use it in GitHub Desktop.
#!/bin/sh
# -*- coding: utf-8; mode: sh -*-
current_time=$(date -d 'now' +%s)
lid_opened=$(date -d "$(journalctl -t systemd-logind -b | grep 'Lid opened' | tail -n1 | awk '{print $1, $2, $3}')" +%s)
worked_hours=$(echo 'scale=2;(' $current_time - $lid_opened ')' / 3600 | bc)
echo 'You have worked:' $worked_hours 'hours'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment