fegger 2b33045e3f Replace project tracking with task-based tracking and interactive prompting
Change the time tracker concept from "project" to "task". When starting a
session without an explicit task argument, the user is now prompted with
their previous tasks via available launchers (wofi, rofi, bemenu, dmenu,
zenity, or terminal fallback). Empty tasks are allowed. Update README,
CLI output, Waybar tooltips, and timesheet generation accordingly.
2026-09-02 13:26:45 +02:00
2026-09-02 13:09:22 +02:00

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 task 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

# Start a session (will prompt for a task; empty is allowed)
./time_track.py toggle

# Start a session without a prompt, using a specific task
./time_track.py toggle "client-a"

# Stop the active session (same as ./time_track.py stop)
./time_track.py toggle

# 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 a session.
    • When starting, a task prompt appears. The launcher order is wofi, rofi, bemenu, dmenu, then zenity, then a terminal fallback.
    • Existing tasks are shown as a dropdown/list. Type a new task or pick an existing one.
    • Press Enter with no input to start with an empty task.
    • Press Escape / Cancel to abort starting.
  • 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.

Task prompting requirements

For the click-to-start prompt to work from Waybar you need one of these installed:

Launcher Notes
wofi Best for Wayland; shows previous tasks as a dropdown and allows typing new ones
rofi Works on X11 and Wayland
bemenu Wayland/X11 dmenu alternative
dmenu Classic suckless dmenu
zenity GTK entry dialog (no dropdown, but supports empty input)

If none are installed, the script falls back to a terminal prompt when run from a TTY.

S
Description
No description provided
Readme 53 KiB
Languages
Python 97.9%
CSS 2.1%