Skip to content

Latest commit

 

History

History
164 lines (135 loc) · 3.47 KB

README.md

File metadata and controls

164 lines (135 loc) · 3.47 KB

unixy_time_tracker

inspired by upwork's time tracker app. python. postgresql. cron. mplayer. xprintidle.

alternatives

https://github.com/meetmangukiya/bth-py

setup

dependencies

sudo apt install xprintidle postgresql mplayer python3-psycopg2 libnotify-bin

make sure notifications work:

./notify.sh --expire-time=3000  Test "Hello World"

if necessary, try running:

xfce4-notifyd-config
/usr/lib/x86_64-linux-gnu/xfce4/notifyd/xfce4-notifyd

install cron job

crontab cron/unixy_time_tracker

add this directory to your PATH (fish)

set -U fish_user_paths $fish_user_paths ~/unixy_time_tracker/

setup postgres

sudo --login --user=postgres psql -c "create user hours;"
sudo --login --user=postgres psql -c "alter user hours with password 'hours';"
sudo --login --user=postgres psql -c "create database 'hours';"
sudo --login --user=postgres pg_restore -c -C -s -v -d hours < hours_db
sudo --login --user=postgres psql -c "grant all privileges on database hours to hours;"

set up keyboard shortcuts:

"ctrl + alt + [" to "~/unixy_time_tracker/tt on"
"ctrl + alt + ]" to "~/unixy_time_tracker/tt off"

sample interaction

koom@dev ~/unixy_time_tracker (master) [1]> tt on "boring task 1"
db updated.
0:00:35.435037 xbrl
7:49:22.200187 pyco3
4:20:07.766982 semantics
1:36:57.089243 modules
db updated.
on
MPlayer 1.3.0 (Debian), built with gcc-7 (C) 2000-2016 MPlayer Team
[mplayer output ommited..]
Exiting... (End of file)

koom@dev ~/unixy_time_tracker (master)> tt on "boring task 2"
db updated.
0:00:35.435037 xbrl
7:49:22.200187 pyco3
4:20:07.766982 semantics
1:36:57.089243 modules
0:00:15.851025 boring task 1
0:00:00.017912 boring task 2
db updated.
on
MPlayer 1.3.0 (Debian), built with gcc-7 (C) 2000-2016 MPlayer Team
[mplayer output ommited..]
Exiting... (End of file)

koom@dev ~/unixy_time_tracker (master)> tt on "boring task 1"
db updated.
0:00:35.435037 xbrl
7:49:22.200187 pyco3
4:20:07.766982 semantics
1:36:57.089243 modules
0:00:15.851025 boring task 1
0:00:10.980661 boring task 2
0:00:00.048821 boring task 1
db updated.
on
MPlayer 1.3.0 (Debian), built with gcc-7 (C) 2000-2016 MPlayer Team
[mplayer output ommited..]
Exiting... (End of file)

koom@dev ~/unixy_time_tracker (master) [1]> tt info
0:00:35.435037 xbrl
7:49:22.200187 pyco3
4:20:07.766982 semantics
1:36:57.089243 modules
0:00:48.215652 boring task 1
0:00:10.980661 boring task 2
running.

koom@dev ~/unixy_time_tracker (master)> tt csv
#hours;task
xbrl;0.0
pyco3;7.8
semantics;4.3
modules;1.6
boring task 1;0.0
boring task 2;0.0

useful queries

PGPASSWORD='hours' psql -h localhost -U hours -d hours # -c "query"
delete from hours where ts < '2020-06-01 00:00:14.05933+01';

merge multiple databases

(create a working directory)

 md ~/hours/(date --iso)
 mkdir (hostname)
 mkdir other

(backup local really thoroughly)

sudo -u postgres pg_dump -d hours > (hostname)/dump
PGPASSWORD='hours' psql -h localhost -U hours -d hours -c "select * from hours order by ts;" > (hostname)/select
tt csv > (hostname)/csv
tt info > (hostname)/info

(dump on remote)

sudo -u postgres pg_dump -d hours > (hostname)/dump

(mount or copy the remote directory to other)

(load the dump)

PGPASSWORD='hours' psql -h localhost -U hours -d hours -f other/dump

general usage

(run the report)

tt csv > (hostname)/csv

(purge the hours table))

PGPASSWORD='hours' psql -h localhost -U hours -d hours -c "delete from hours"