Git Product home page Git Product logo

clock's Introduction

Clock

This is a work timing script for tracking hours.

Setup

D-Bus

Clock uses dbus-python, which requires you have dbus installed.

Install dbus

Debian:

apt install dbus

Fedora:

dnf install dbus

macOS:

brew install dbus

General

Clone the repo and install the requirements.

git clone https://github.com/macuyler/clock.git
cd clock
python3 -m pip install --user -r requirements.txt

Checkout gitbin for quickly adding scripts to your path.

Configuration

The clock configuration is located in the ~/.config/clock/clock.conf file. You can setup work profiles there with the following format:

profile_name:/absolute/path/to/log-file.txt

Note: The log file must exist prior to using the profile.

Notifications

You can also set up timed notifications in the config file. These can be a reminder to take a break, or that you are still clocked in. You can set the notification interval with the following format:

_notify_me:60.0

Where 60.0 is the number of minutes in-between notifications.

Usage

Running the clock script will start an infinite loop that prompts you for input.

The idea is that you can run the script and then minimize the window or something.

$ clock [-h] [-n NOTIFY_ME] [profile]
┏━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ You are clocked in!     ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ Enter [t] to show time. ┃
┃ Enter [q] to quit.      ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━┛
 >

You have the option to pass in the name of a profile that you want to use.

If you don't specify a profile, it will attempt to find a profile named default.

clock school

Incase of an invalid config file or profile, clock will print the number of hours you just clocked to stdout. All other clock output including UI elements are printed over stderr. This will allow you to redirect stdout to a log file if needed.

clock > log.txt

You can also set a temporary notification interval using the --notify-me flag.

clock --notify-me 15

Testing

Run all the tests:

python3 -m unittest

Run an individual test:

python3 -m tests.test_config

clock's People

Contributors

macuyler avatar

Stargazers

 avatar

Watchers

 avatar  avatar

clock's Issues

Multiple Log Files

About

I think it would be nice to be able to quickly switch between different log files. This could be done by expanding the functionality of the config file to include multiple log file listings. These files would be associated with a keyword that could be passed as an argument to select a log file.

Example Config

work /home/user/documents/work-hours.txt
school /home/user/documents/school-hours.txt
default /home/user/documents/misc-hours.txt

In this example the default keyword would be used to indicate the log file used when a valid keyword is not provided as an argument. This could also be accomplished by simply defining a file path without a keyword. Which would allow existing config files to continue working like normal without any changes.

Add Catchup Feature

Add a feature that recursively checks for gaps in the log file and then fills in the missing days with a log of 0:00HR.

Timed Notifications

About

It would be cool if this script could send notifications every n minutes.
You could then call the script with some -n 00 flag, and that would setup a timer.

The use case for this being, you want to take a break every 45 minutes.
So you run ./clock -n 45, and 45 minutes later you get a notification telling you to take a break.

Implementation

After a quick search, I was able to find a medium article on python notifications.
In the article they use a library called plyer.
It includes support for all kinds of features, and looks like it might be a little over kill.
But it does support notifications on Windows, macOS, and Linux!

Keyboard Interrupt Handling

About

I have accidentally Ctrl-C'd my way out of this script so many times.
The current behavior is that the script just dies, and whatever hours you had are lost.
There have been times where I accidentally left the script running, and this actually came in handy.
Because of this, I don't want to just save the current hours before dying.
Instead, I think the script should simply print out whatever the current hours are and end.
That way the user has control over what to do with those hours.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.