Skip to content

Commit 562c78c

Browse files
retr0hclaude
andauthored
feat: add DVD and pipes screensavers with cycling support (#2)
* docs: add design spec for new screensavers (dvd, pipes) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: add implementation plan for new screensavers Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: add dvd and pipes screenshots, rename screensaver to snake Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor: extract shared code from main.go into focused files Move terminal helpers to terminal.go, styles/rendering to style.go, CGo auth logic to auth.go, and grid/worm primitives to grid.go. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor: extract worm screensaver to screensaver_worm.go Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: add screensaver interface and unified --screensaver flag Introduce a screensaver interface with a factory registry and random picker. Wrap runWormDemo in wormScreensaver to satisfy the interface. Rewrite flag parsing: --screensaver <name> (snake/pipes/dvd/random), --screensaver-cycle (stub), --worm-count alias, keeping --snake and --snake-count for backwards compatibility. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: add bouncing DVD lock screensaver Implements dvdScreensaver with a tinted padlock that bounces diagonally around the terminal at 100ms per tick, changing color on each wall bounce. Supports keypress-triggered password overlay, Touch ID via Esc, SIGWINCH resize handling, and tmux focus-event filtering. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: add pipes screensaver Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: add --pipes, --dvd, --random flags, cycling support, fix pipes rendering - Add shortcut flags: --pipes, --dvd, --random alongside --snake - Replace --screensaver/--screensaver-delay with --delay and --cycle (duration strings) - Implement screensaver cycling via stop channel interface - Fix pipes to stay solid while growing (fade only on screen reset) - Remove static lock icon from DVD screensaver Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: resolve lint issues and update README usage - Remove unused vars (purple, lockTitleStyle, promptStyle) - Remove unused funcs (renderMessageOverlay, renderLockScreen) - Update README with new CLI flags (--pipes, --dvd, --random, --delay, --cycle) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: update CLAUDE.md and README for new screensavers and CLI flags Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: remove config file from roadmap Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: reformat spec and plan documents Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: update screenshots and rename worms to snake in docs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: rename --snake to --worms, update all docs and screenshots --snake kept as hidden alias for backwards compatibility. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4d0da33 commit 562c78c

18 files changed

Lines changed: 3338 additions & 827 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ dist/
44
docs/node_modules/
55
docs/bun.lock
66
.just/remote/
7+
.superpowers/

CLAUDE.md

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,17 @@ tlock is a terminal lock program for macOS written in Go. It locks the terminal
1010

1111
Single-binary Go program using CGo for macOS system integration:
1212

13-
- **`main.go`** - Entry point, terminal handling, lock screen UI, auth flow
13+
- **`main.go`** - Entry point, flag parsing, terminal setup, screensaver dispatch
14+
- **`terminal.go`** - Terminal utilities (clear, cursor, centering, lock icon, resize)
15+
- **`auth.go`** - CGo Touch ID + PAM authentication, password overlay
16+
- **`style.go`** - Lipgloss styles, color palette, message rendering
17+
- **`grid.go`** - Grid cell system (3x2 chars), block drawing, phosphor colors
18+
- **`screensaver.go`** - Screensaver interface, factory registry, random selection
19+
- **`screensaver_worm.go`** - Worms screensaver (xlock-style)
20+
- **`screensaver_dvd.go`** - Bouncing padlock screensaver
21+
- **`screensaver_pipes.go`** - Growing pipes screensaver
1422
- **CGo** - Touch ID via `LocalAuthentication.framework`, password via PAM (`pam_authenticate`)
15-
- **lipgloss** - Terminal styling (purple/teal/gray color palette)
23+
- **lipgloss** - Terminal styling (teal/gray/red color palette)
1624
- **golang.org/x/term** - Raw terminal mode, terminal size detection
1725

1826
## Key Technical Details
@@ -30,7 +38,7 @@ Single-binary Go program using CGo for macOS system integration:
3038

3139
```bash
3240
go build -o tlock . # Build binary
33-
go run main.go # Run directly (will lock terminal!)
41+
go run . --worms # Run directly (will lock terminal!)
3442
```
3543

3644
## Usage
@@ -39,30 +47,32 @@ go run main.go # Run directly (will lock terminal!)
3947
# Direct (password prompt only)
4048
tlock
4149

42-
# Worms immediately
43-
tlock --snake
50+
# Screensavers (immediate)
51+
tlock --worms # Worms
52+
tlock --pipes # Growing pipes
53+
tlock --dvd # Bouncing padlock
54+
tlock --random # Random pick
55+
tlock --random --cycle 5m # Rotate every 5 min
4456

45-
# Screensaver after 30s idle
46-
tlock --screensaver
47-
48-
# Custom delay
49-
tlock --screensaver --screensaver-delay 60
57+
# With idle delay
58+
tlock --worms --delay 30s # Worms after 30s idle
5059

5160
# As tmux lock-command
52-
set -g lock-command "tlock --snake"
61+
set -g lock-command "tlock --random --cycle 5m"
5362
set -g lock-after-time 1800
5463
bind ^X lock-server
5564
```
5665

5766
## Color Palette
5867

5968
```
60-
Purple = lipgloss.Color("99") // Headers, lock title
6169
Teal = lipgloss.Color("#06ffa5") // Accent, prompts, blinking cursor
6270
Gray = lipgloss.Color("245") // Dim/secondary text (hostname, hints)
6371
Red = lipgloss.Color("196") // Errors (auth failed)
6472
```
6573

74+
Screensavers use a 13-color retro phosphor CRT palette defined in `wormColors` (grid.go).
75+
6676
## Code Standards
6777

6878
- Follow [Conventional Commits](https://www.conventionalcommits.org/) for commit messages
@@ -73,5 +83,4 @@ Red = lipgloss.Color("196") // Errors (auth failed)
7383

7484
## Roadmap
7585

76-
- Phase 2: xlock-style worm screensaver with fading trails + cycling figurine text
77-
- Phase 3: Configuration file support (`~/.config/tlock/config.yaml`)
86+
- 1Password CLI integration

README.md

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,24 @@ A terminal lock screen for macOS that uses **Touch ID** for biometric unlock wit
2727

2828
<table align="center">
2929
<tr>
30-
<td align="center" width="33%"><a href="asset/screensaver.png"><img src="asset/screensaver.png" width="100%" alt="Worm Screensaver"></a></td>
31-
<td align="center" width="33%"><a href="asset/passphrase.png"><img src="asset/passphrase.png" width="100%" alt="Passphrase Prompt"></a></td>
32-
<td align="center" width="33%"><a href="asset/touchid.png"><img src="asset/touchid.png" width="100%" alt="Touch ID Prompt"></a></td>
30+
<td align="center" width="33%"><a href="asset/worms.png"><img src="asset/worms.png" width="100%" alt="Worms Screensaver"></a></td>
31+
<td align="center" width="33%"><a href="asset/dvd.png"><img src="asset/dvd.png" width="100%" alt="DVD Screensaver"></a></td>
32+
<td align="center" width="33%"><a href="asset/pipes.png"><img src="asset/pipes.png" width="100%" alt="Pipes Screensaver"></a></td>
33+
</tr>
34+
<tr>
35+
<td align="center"><sub>Worms</sub></td>
36+
<td align="center"><sub>DVD</sub></td>
37+
<td align="center"><sub>Pipes</sub></td>
38+
</tr>
39+
<tr>
40+
<td align="center"><a href="asset/passphrase.png"><img src="asset/passphrase.png" width="100%" alt="Passphrase Prompt"></a></td>
41+
<td align="center"><a href="asset/touchid.png"><img src="asset/touchid.png" width="100%" alt="Touch ID Prompt"></a></td>
42+
<td></td>
3343
</tr>
3444
<tr>
35-
<td align="center"><sub>Screensaver</sub></td>
3645
<td align="center"><sub>Passphrase</sub></td>
3746
<td align="center"><sub>Touch ID</sub></td>
47+
<td></td>
3848
</tr>
3949
</table>
4050

@@ -86,17 +96,20 @@ sudo mv tlock /usr/local/bin/
8696
Run directly:
8797

8898
```bash
89-
tlock # Password prompt only
90-
tlock --snake # Worms immediately
91-
tlock --screensaver # Worms after 30s idle (default delay)
92-
tlock --screensaver --screensaver-delay 60 # Worms after 1 min idle
99+
tlock # Password prompt only
100+
tlock --worms # Worms screensaver
101+
tlock --pipes # Pipes screensaver
102+
tlock --dvd # Bouncing lock screensaver
103+
tlock --random # Random screensaver
104+
tlock --random --cycle 5m # Rotate screensaver every 5 min
105+
tlock --worms --delay 30s # Worms after 30s idle
93106
```
94107

95108
As a tmux lock command:
96109

97110
```tmux
98111
# ~/.tmux.conf
99-
set -g lock-command "tlock --snake"
112+
set -g lock-command "tlock --random --cycle 5m"
100113
set -g lock-after-time 1800 # Lock after 30 min idle
101114
bind ^X lock-server # Ctrl+X to lock now
102115
```
@@ -105,13 +118,14 @@ bind ^X lock-server # Ctrl+X to lock now
105118

106119
tlock brings the classic [xlock](https://linux.die.net/man/1/xlock) experience to your terminal — an animated screensaver that kicks in when your terminal is locked, with authentication required to dismiss it.
107120

108-
1. 🐍 **Screensaver mode** (`--snake`): xlock-style worms animate across the screen
121+
1. 🎨 **Pick a screensaver** `--worms`, `--pipes`, `--dvd` (bouncing lock), or `--random`
109122
2. ⌨️ **Any keypress** pauses the screensaver and shows the passphrase prompt
110123
3. 🔑 **Type your macOS password** and press Enter to unlock
111124
4. 🖐️ **Press Esc** to switch to Touch ID — authenticate with your fingerprint
112125
5. 🚫 Wrong password? **ACCESS DENIED** — back to the screensaver
126+
6. 🔄 **Cycle mode**`--random --cycle 5m` rotates screensavers automatically
113127

114-
Without `--snake` or `--screensaver`, tlock shows the passphrase prompt directly.
128+
Without a screensaver flag, tlock shows the passphrase prompt directly.
115129

116130
All signals (SIGINT, SIGTERM, SIGTSTP) are ignored. The only way out is authentication. 🔐
117131

@@ -136,9 +150,10 @@ tlock is inspired by [xlock](https://linux.die.net/man/1/xlock), the classic X11
136150

137151
## 🗺️ Roadmap
138152

139-
- [x] 🐛 xlock-style worm screensaver with fading trails
140-
- [ ] 🔤 Additional screensaver modes (cycling figurine text, matrix rain, etc.)
141-
- [ ] ⚙️ Configuration file (`~/.config/tlock/config.yaml`)
153+
- [x] 🪱 xlock-style worm screensaver with fading trails
154+
- [x] 🔒 Bouncing DVD padlock screensaver
155+
- [x] 🔲 Pipes screensaver with fade-out reset
156+
- [x] 🎲 Random screensaver selection with `--cycle` rotation
142157
- [ ] 🔐 1Password CLI integration
143158

144159
## 📄 License

asset/dvd.png

672 KB
Loading

asset/pipes.png

810 KB
Loading

asset/screensaver.png

-91.5 KB
Binary file not shown.

asset/worms.png

712 KB
Loading

0 commit comments

Comments
 (0)