Skip to main content

A lightweight CLI stopwatch and timer in Python

Project description

PSW - Python Stop Watch

psw is a lightweight, intuitive Command Line Interface (CLI) stopwatch and timer utility written in Python. It features live console rendering, interactive real-time controls, and built-in repeat functionalities without requiring any complex external audio dependencies.

Install

You can install psw via pip:

pip install psw

Usage

1. Stopwatch Mode

Measure elapsed time directly in your terminal.

Start the Stopwatch

To start the stopwatch, run:

psw start

The live clock will be displayed in the console:

00 h 00 m 00.000 s

Options

  • -p, --precision: Specifies the number of decimal places for seconds.
  • Default: 3 (millisecond precision)
  • Example: psw start -p 2 will display 00 h 00 m 00.00 s

Interactive Controls (While Running)

While the stopwatch is active, you can control it in real-time using the following keys:

  • s: Pause / Resume the stopwatch.
  • l: Record a lap time. The current lap time will be printed below the running clock without stopping the main timer.
  • q (or Ctrl+C): Quit the stopwatch and display the final summary.

2. Timer Mode

Count down from a specified duration with advanced repeat and notification options.

Start the Timer

To start a countdown, use the timer command followed by the duration. You can specify hours (h), minutes (m), and seconds (s).

# Set a timer for 5 minutes and 30 seconds
psw timer 5m 30s

# Set a timer for 1 hour
psw timer 1h

The countdown will be displayed in the console:

00 h 05 m 30.000 s

Options

  • -p, --precision: Same as the stopwatch mode, specifies the decimal places for seconds (Default: 3).
  • -r, --repeat [<integer>]: Restarts the timer when it reaches zero.
    • Use without arguments for an infinite loop.
      • Example: psw timer 1m -r
    • Specify an integer to repeat a specific number of times.
      • Example: psw timer 1m -r 3 (Runs a 1-minute timer 3 times)
  • -m, --mute: Disables the system alert sound (terminal bell) when the timer ends.

Interactive Controls (While Running)

  • s: Pause / Resume the countdown.
  • q (or Ctrl+C): Cancel and exit the timer.

[!NOTE] When the timer reaches 00 h 00 m 00.000 s, the application plays a platform-appropriate alert notification (using winsound.MessageBeep() on Windows, and emitting a standard terminal bell sound \a on other platforms or as a fallback). No special OS-level audio permissions or external audio library imports are required, making it lightweight and cross-platform compatible.

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

psw-0.1.4.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

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

psw-0.1.4-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file psw-0.1.4.tar.gz.

File metadata

  • Download URL: psw-0.1.4.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for psw-0.1.4.tar.gz
Algorithm Hash digest
SHA256 5999da0cfb75331daecd2c55f4b76f38b16090da14bcb82bdcf451fd25028329
MD5 c208e60f0862e2dcb3e6db7648ea675a
BLAKE2b-256 aa1ce667ff0ad55256d1719571343fc3250d0c55292ed83881eaa14ed7b39c6c

See more details on using hashes here.

Provenance

The following attestation bundles were made for psw-0.1.4.tar.gz:

Publisher: workflow.yml on KenjiOhtsuka/psw

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file psw-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: psw-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for psw-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b2cba7321756fd77560973c65681db8a62898ab7fc037ea03e748bb006c31be5
MD5 185c5854bd511e47ddac56656d64cde1
BLAKE2b-256 326fa58b0cb8f5031d060198bfb253a639a4a1edf89b6e8d9fa6129b3f2ec979

See more details on using hashes here.

Provenance

The following attestation bundles were made for psw-0.1.4-py3-none-any.whl:

Publisher: workflow.yml on KenjiOhtsuka/psw

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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