Files
waybar_time_track/README.md
T

2.2 KiB

Waybar Time Tracker

A small, dependency-free Python time tracker for Waybar with a start/stop button and timesheet generation.

Features

  • Start / stop button in Waybar: click the module to toggle tracking.
  • Live elapsed time shown in the bar while running.
  • Persistent JSON storage in ~/.local/share/time_track/data.json (override with TIME_TRACK_DIR).
  • Timesheet generation in Markdown, grouped by project and by day.

Files

File Purpose
time_track.py Main CLI and Waybar interface
waybar-config.json Example Waybar custom module configuration
waybar-config.jsonc Same example, with comments (for Waybar JSONC configs)
style.css Example CSS for the running/idle states

Installation

  1. Make sure time_track.py is executable:

    chmod +x /path/to/time_track/time_track.py
    
  2. Add the custom module from waybar-config.json (or waybar-config.jsonc) to your Waybar config (~/.config/waybar/config or ~/.config/waybar/config.jsonc).

  3. Add the CSS from style.css to your Waybar stylesheet (~/.config/waybar/style.css).

  4. Update the paths in the config to point to wherever you placed time_track.py.

Why the module might not show

If the Waybar module appears but has no text, check that "format" is not empty. When return-type is "json", Waybar replaces "{}" with the text field emitted by the script. An empty format ("") makes the module invisible. Use "format": "{}" or omit the field entirely.

CLI usage

# Toggle tracking for the default project
./time_track.py toggle

# Toggle tracking for a specific project
./time_track.py toggle "client-a"

# Emit Waybar JSON (used by the module)
./time_track.py status

# Show the active session
./time_track.py current

# Stop the active session
./time_track.py stop

# Show recent entries
./time_track.py log
./time_track.py log 25

# Generate a Markdown timesheet
./time_track.py timesheet week
./time_track.py timesheet month

Waybar behavior

  • Left click: start or stop the current session.
  • Right click: print the current week's Markdown timesheet to stdout (useful bound to a notification or terminal).
  • The module updates every 5 seconds while running.