Skip to main content

Basically tty-clock but rewritten in Python

Project description

ttyclock-py

A Python implementation of the classic tty-clock, a digital clock for your terminal.

Python License Version

Buy Me a Coffee Traktir Saya Kopi

What's new in v2.0.0 ?!

Major rewrite. Here's what changed:

Tooling:

  • Poetry → uv
  • Python 3.8+ → 3.10+
  • Added mypy (strict type checking)
  • Added ruff (linter)
  • Reorganized from src/clock/py/ to src/ttyclock/

Code:

  • Split into modules instead of one big file
  • Full type hints
  • Better architecture

Features:

  • 5 fonts (was 1)
  • Screensaver mode
  • Random colors
  • Better date format (now shows day of week)
  • Terminal resize handling
  • Centered error messages

Breaking:

  • Needs Python 3.10+
  • Module path changed (but CLI is same)

All CLI arguments work the same. Config format is backwards compatible.

Install

pip install ttyclock-py

Build from source:

git clone https://github.com/elliottophellia/clock.py
cd clock.py
uv build
pipx install dist/ttyclock_py-2.0.0-py3-none-any.whl

Usage

ttyclock-py              # basic
ttyclock-py -c -s        # centered with seconds
ttyclock-py -t -P -d     # 12-hour + AM/PM + date
ttyclock-py -r -R        # screensaver mode with random colors

Options

-c, --center          center it
-s, --seconds         show seconds
-b, --bold            bold text
-t, --twelve          12-hour format
-P, --ampm            show AM/PM (needs -t)
-k, --blink           blink the colon
-u, --utc             use UTC
-d, --date            show date
-r, --screensaver     bouncing screensaver (like DVD logo)
-R, --random-color    random colors when bouncing
-C N                  color (0-7): black/red/green/yellow/blue/magenta/cyan/white
-f FONT               font: block/slim/dot/bold/mini
-x X, -y Y            position
-D DELAY              update delay in seconds (default 0.1)
-S, --save-config     save settings

Quit with q, Q, or ESC.

Fonts

5 fonts available:

  • block - default
  • slim - narrower
  • dot - retro LED look
  • bold - thick
  • mini - compact

Try them: ttyclock-py -f dot -c

Screensaver

-r makes it bounce around. Add -R for color changes.

ttyclock-py -r -R -s -d

Config

Config location:

  • Linux/macOS: ~/.config/ttyclock-py/config.json
  • Windows: %LOCALAPPDATA%\ttyclock-py\config.json
{
  "color": "GREEN",
  "font": "block",
  "delay": 0.1,
  "options": {
    "twelve_hour": false,
    "show_seconds": true,
    "bold": false,
    "center": true,
    "blink_colon": false,
    "utc": false,
    "show_date": true,
    "show_ampm": false,
    "screensaver": false,
    "random_color": false
  },
  "position": {"x": 0, "y": 0}
}

Use -S to save current settings or edit the file directly.

Dev

git clone https://github.com/elliottophellia/clock.py
cd clock.py
uv sync
uv run ttyclock-py

# checks
uv run ruff check src/ttyclock
uv run mypy src/ttyclock

# build
uv build

Code is in src/ttyclock/:

  • types.py - enums/dataclasses
  • fonts.py - font data
  • digits.py - pattern lookup
  • time_formatter.py - time/date strings
  • clock.py - state
  • renderer.py - drawing
  • screensaver.py - bouncing
  • config.py - file I/O
  • __main__.py - CLI

License

This project is licensed under the Creative Commons Attribution Share Alike 4.0 International (CC-BY-SA-4.0). For more information, please refer to the LICENSE file included in this repository.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Write your amazing code
  4. Make sure pass ruff check and mypy first
  5. Commit your changes (git commit -m 'Add some AmazingFeature')
  6. Push to the branch (git push origin feature/AmazingFeature)
  7. Open a Pull Request

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

ttyclock_py-2.0.0.tar.gz (31.6 kB view details)

Uploaded Source

Built Distribution

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

ttyclock_py-2.0.0-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file ttyclock_py-2.0.0.tar.gz.

File metadata

  • Download URL: ttyclock_py-2.0.0.tar.gz
  • Upload date:
  • Size: 31.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for ttyclock_py-2.0.0.tar.gz
Algorithm Hash digest
SHA256 d2d3537a1f17162e0f632c2f7cd9021f8bc0e8205623a9fea9f9cc1b6dd7a175
MD5 789adb184d1a8515e9f4f316bca99bc3
BLAKE2b-256 d2668bdf002294f82eb64851226a6d1bdff1614573cd6a74898bfece01404d4d

See more details on using hashes here.

File details

Details for the file ttyclock_py-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: ttyclock_py-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for ttyclock_py-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 23c7d9b6f7006077e6decd69bd4d68bf2481cce5cc958e69c865e8d76d1400f9
MD5 32846baed6fccfc43191fa8a5627d2f7
BLAKE2b-256 c9072407f9be3482cd69031a134b86f103adbaa6cb541b76d979c7565081feff

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