A fancy sleep command written in Rust.
zzz (executed as zzs) is an interactive, feature-packed replacement for the traditional sleep command. It offers progress bars, custom themes, Pomodoro timers, process watching, flexible duration inputs, command execution post-timer, and keyboard controls.
A CodeTease project.
Install from crates.io:
cargo install zzzsleepPlease read the Installation Guide for detailed installation instructions.
- ⏳ Flexible Sleep Duration: Pass standard durations like
5s,1.5m,2h, or specify target times with--until(e.g.17:00,5:30pm,tomorrow-8am). - ⏱️ Stopwatch Mode: Track elapsed time upwards with
--stopwatchand log lap times on the fly. - 🍅 Pomodoro Mode: Built-in Pomodoro productivity timer cycles (work/break intervals).
- 🎨 Visual Themes: Choose from multiple animated themes (
classic,cat,moon,pixel,matrix). RespectsNO_COLORstandard. - ⌨️ Interactive Terminal Controls: Pause/resume, adjust remaining time (
+/-), skip, reset, or record lap times (l) interactively. - 👁️ Process Monitoring: Watch a process PID (
--watch <PID>) and exit automatically if the monitored process terminates. - 🚀 Command Execution & Hooks: Automatically run commands upon completion (
--then), pause (--on-pause), tick (--on-tick), or cancellation (--on-interrupt). - 📋 Interactive Action Menu: Choose post-timer actions (
--then-menu) interactively (Lock screen, Shutdown, Do nothing, Custom command). - 🛠️ Scripting & CI Support: Non-interactive mode (
--no-interaction), quiet mode (--quiet), and raw output mode (--raw) for seamless script and pipeline integration. - ⚙️ Environment Variable Config: Configure options via environment variables (
ZZZ_*).
Sleep for a specific duration:
zzs 10s
zzs 1.5m
zzs 2hSleep until a target time today or tomorrow:
zzs --until 17:00
zzs --until 5:30pm
zzs --until tomorrow-8amStart a Pomodoro cycle with default 25m work / 5m break intervals:
zzs --pomoCustomize work and break durations:
zzs --pomo --pomo-work 50m --pomo-break 10mChoose a visual theme for the progress bar:
zzs 5m --theme cat
zzs 10m --theme moon
zzs 1h --theme matrix
zzs 30s --theme pixelAvailable themes: classic, cat, moon, pixel, matrix.
Track elapsed time upwards until you press q or Ctrl+C:
zzs --stopwatchPress l while running to log the lap time to the terminal.
Execute specific shell commands on pause, tick, or interrupt:
zzs 25m --then "playerctl play" --on-pause "playerctl pause" --on-interrupt "notify-send 'Cancelled'"Present an interactive menu upon timer completion to select a post-timer action:
zzs 25m --then-menuPresents choices:
[1] Lock screen[2] Shutdown[3] Do nothing[4] Run custom command
Run a shell command when waking up:
zzs 10m --then "notify-send 'Timer complete!'"
# or using the --exec alias
zzs 1h --exec "make build"Sleep while monitoring a background process PID. If the process terminates, zzs exits immediately:
zzs 1h --watch 12345While zzs is running in an interactive terminal, you can press:
SpaceorP: Pause / Resume timerL: Record and log lap time (in Stopwatch mode)+or=: Add step duration (default: +30s)-or_: Subtract step duration (default: -30s)S: Skip timer and complete immediatelyR: Reset timer to startQ: Stop / quit stopwatch timerCtrl+CorC: Cancel / interrupt timer
Custom step duration:
zzs 10m --step 1m| Option | Environment Variable | Description | Default |
|---|---|---|---|
<DURATION> |
ZZZ_DURATION |
Sleep duration (e.g. 5s, 1.5m, 2h) |
— |
--until <TIME> |
ZZZ_UNTIL |
Sleep until time (e.g. 17:00, 5:30pm, tomorrow-8am) |
— |
--pomo |
ZZZ_POMO |
Enable Pomodoro mode | false |
--pomo-work <DUR> |
ZZZ_POMO_WORK |
Work duration for Pomodoro mode | 25m |
--pomo-break <DUR> |
ZZZ_POMO_BREAK |
Break duration for Pomodoro mode | 5m |
--stopwatch |
ZZZ_STOPWATCH |
Enable Stopwatch (count-up) mode | false |
--theme <THEME> |
ZZZ_THEME |
Progress bar theme (classic, cat, moon, pixel, matrix) |
classic |
--then / --exec <CMD> |
ZZZ_THEN |
Execute command upon completion | — |
--then-menu |
ZZZ_THEN_MENU |
Select post-timer action interactively | false |
--on-interrupt <CMD> |
ZZZ_ON_INTERRUPT |
Execute command when cancelled / interrupted | — |
--on-pause <CMD> |
ZZZ_ON_PAUSE |
Execute command when timer is paused | — |
--on-tick <CMD> |
ZZZ_ON_TICK |
Execute command on each timer tick | — |
--watch <PID> |
ZZZ_WATCH |
Monitor PID and exit early if process terminates | — |
-q, --quiet |
ZZZ_QUIET |
Hide progress bar / output | false |
-m, --message <MSG> |
ZZZ_MESSAGE |
Completion message | Woke up! 🚀 |
--step <DUR> |
ZZZ_STEP |
Step duration for interactive adjustments | 30s |
--raw |
ZZZ_RAW |
Concise output format for remaining time | false |
--no-interaction |
ZZZ_NO_INTERACTION |
Disable interactive keys and raw terminal mode | false |
-V, --version |
— | Print version information and exit | — |
This project is under the MIT License.