Skip to main content

Timetracking tools that provide the data for use with timetrack.slgotting.com

Project description

TimeTrack

Time is tracked by logging the active, focused window of the user every second. The consolidate script is mean to be run on a 5 minute interval on the seconds, and consolidates the raw time log.

You then upload your consolidated time log to https://timetrack.slgotting.com, and you can inspect your time usage with a graphical UI

Compatibility

Right now this script is only usable on Linux. Tested working on Ubuntu 18. It should work on any linux distro if the following commands are available:

  • xdotool
  • wmctrl
  • xprintidle

I may add support for Windows in the future but I wanted to get it out as it is right now.

Getting Started

Install package with

pip install timetrack-slg

Install the easy way

sudo install-timetrack-slg

Install the hard way

This is the hard way, make sure to look over any commands and see that they contain proper variable values

1. Set up systemd to automatically run script (on boot and always restart on fail)

:warning: Make sure to change username to your username
:warning: Also your python file install might be at a location other than /home/username/.local/bin/timetrack-slg. To find location, run whereis timetrack-slg. Update ExecStart as necessary
:information_source: The -s switch is set to .9766 because this is the interval I found gives me close to or exactly 1 run per second. See "Calculate your sleep time" for information on how to calculate what value you should use.
:information_source: Get your DISPLAY variable with env | grep DISPLAY
:information_source: Output file -o /home/username/timetrack-slg/time-log.json must be a json file
:information_source: Run timetrack-slg -h to see all options

:warning: Before running this command make sure you change the necessary variables using the above as guidance to doing so.

In your terminal, run:

echo '[Unit]
Description=Time tracker
After=multi-user.target

[Service]
User=username
Type=simple
Restart=always
Environment="DISPLAY=:0"
ExecStart=/home/username/.local/bin/timetrack-slg \
            --output_filepath /home/username/timetrack-slg/time-log.json \
            --sleep_time 0.9766 \
            --time_til_idle 30 \
            --config_filepath /home/username/.config/slg/time-log.yml

[Install]
WantedBy=multi-user.target' | sudo tee /etc/systemd/system/timetrack-slg.service >/dev/null

Restart systemctl daemon:

sudo systemctl daemon-reload

Then tell systemd to start this up at boot with:

sudo systemctl enable timetrack-slg.service

And start er up with:

sudo systemctl start timetrack-slg.service

2. Set up cron job to automatically consolidate log

Add this line to your crontab (changing username and paths where necessary):

*/5 * * * * /home/username/.local/bin/timetrack-consolidate-slg --input_filepath /home/username/timetrack-slg/time-log.json --config_filepath /home/username/.config/slg/time-log.yml --run_interval 5

This line consolidates the time-log.json file every 5 minutes so that our timelog filesize doesnt grow too big.

3. Success

If you've done everything correctly, you should have a time-log-consolidated.json generated in the input_filepath location (if at least 5 minutes have passed).

More Info

Calculate your sleep time

  1. Make sure timetrack-consolidate-slg is running in crontab every 5 minutes.
  2. Run the script without any -s flag set for a while. 10 minutes to be safe. Shouldn't need to do this more than once so find something else to do while waiting.
  3. Inspect your consolidate file and add up the times of a 5 minute block. The value should be relatively close to 300 (~ 290 - 299). Mine was 293
  4. Divide number by 300. So in my case I had 293 so ( 293 / 300 ) is .9766, hence the value you see above.

Note: Since we will simply overwrite any times that already exist, we can use a number lower than this and run the script more frequently (0.96 or even lower) to guarantee we have 300 data points every 5 minutes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

timetrack-slg-0.1.8.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

timetrack_slg-0.1.8-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file timetrack-slg-0.1.8.tar.gz.

File metadata

  • Download URL: timetrack-slg-0.1.8.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for timetrack-slg-0.1.8.tar.gz
Algorithm Hash digest
SHA256 1c4305fe1f91ab1eb5afc57b2a8e0039572c83cd82516a4a882d4afd53ac404a
MD5 69cb0aedc48ece43a1d9de7fa981dde8
BLAKE2b-256 02555834d2624ef0052e9e9d2fcad59fbafea38e261c53cb7282a8e583e6b5ff

See more details on using hashes here.

File details

Details for the file timetrack_slg-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: timetrack_slg-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for timetrack_slg-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 33c48643bf3189fce7452d45b806704abdb75e69bd737c638fccb27fe1e412ed
MD5 d32299fb65d849af63ae36aa22357a9b
BLAKE2b-256 1b2a64b9f70136b18fe7038e4f400a92a8ef15f12c979e9c24bb0d1b4b63c36e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page