Skip to main content

pTock

A digital clock for the terminal, inspired by tty-clock and tock. The main difference with this version is that it is written in Python, and my goal was primarily to learn as much as possible about the language itself.

Note: emulating all the features of tty-clock and tock is not a goal of this project.

Features

  • Efficient bitmap and diff-based drawing.
  • Timezone fetched fro mthe system using the timedatectl command 2.
  • Military time and second display toggling.
  • Color customization.
  • Positioned or centered clock.
  • Adjustable display size.
  • Synchronization with system clock seconds.
  • Do not require any particular Python library, only standard Python libs.
  • If the terminal size changed, it will adjusts the clock position automatically.

Installation and Dependencies

  1. The only requirement is to have Python 3 installed and the basic core libraries.

  2. It is already available in PyPi, so you only need to run pip to intall and ptock to start the clock, as below:

pip install python3-ptock
ptock -h

Usage

Usage: ptock [OPTIONS]

A digital clock for the terminal.

Options:
  -h, --help             show this help message and exit.
  -x, --x <X>            Horizontal 0-indexed position of top-left corner [default: 0].
  -y, --y <Y>            Vertical 0-indexed position of top-left corner [default: 0].
  -W, --width <WIDTH>    Font width in characters per tile [default: 2].
  -H, --height <HEIGHT>  Font height in characters per tile [default: 1].
  -s, --second           Display seconds.
  -m, --military         Display military (24-hour) time.
  -c, --center           Center the clock in the terminal. Overrides manual positioning.
  -C, --color <COLOR>    Change the color of the time [If none is given, random from 1 to 7].
  -v, --version          Show program's version number and exit.

Available commands with this feature flag set are:

  • q or Q or <ESC>: Exit.
  • s: Toggle second display.
  • m: Toggle military (24H) time.
  • c: Center the clock in the terminal.
  • 0..=7: Change to corresponding ANSI color.

References

Release files for python3-ptock 1.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python3-ptock 1.3.1
File Size Uploaded
python3_ptock-1.3.1.tar.gz 12.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python3-ptock 1.3.1
File Interpreter ABI Platform
python3_ptock-1.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 24.7 kB

Release files / python3_ptock-1.3.1.tar.gz

Download URL python3_ptock-1.3.1.tar.gz
Size 12.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3914b3b417f5366abc6f4ba2bdf7cf23b1b8bb79d6f0e3da95a18b4ed70ec0bd
BLAKE2b-256 checksum
How to use checksums
2228a4ec729a8f9606901dcf9485a38cc637f3e450f4296a41d537339dabda76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Release files / python3_ptock-1.3.1-py3-none-any.whl

Download URL python3_ptock-1.3.1-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ed2c444c353c41e7429174c2822e3ab5d1a9aa0872198eb1676cc91d924af178
BLAKE2b-256 checksum
How to use checksums
66d6e0833b52e5dfe622b5e9629f4954ade4f419f197a95eb6c88f28a1c0eebc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Release history Release notifications | RSS feed

This release

1.3.1 This release

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page