Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion bin/omarchy-screensaver
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ wait_for_terminal_resize() {

wait_for_terminal_resize

effect_args=(--random-effect)
screensaver_effect=$(omarchy-screensaver-effect)
[[ -n $screensaver_effect ]] && effect_args=(--random-effect --include-effects "$screensaver_effect")

while true; do
ttfx -i ~/.config/omarchy/branding/screensaver.txt \
--frame-rate 120 --canvas-width 0 --canvas-height 0 --reuse-canvas --anchor-canvas c --anchor-text c\
--random-effect --no-eol --no-restore-cursor &
"${effect_args[@]}" --no-eol --no-restore-cursor &

while pgrep -t "${tty#/dev/}" -x ttfx >/dev/null; do
if read -n1 -t 1 || ! screensaver_in_focus; then
Expand Down
21 changes: 21 additions & 0 deletions bin/omarchy-screensaver-effect
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# omarchy:summary=Resolve the configured ttfx effect for the screensaver, if any.
# omarchy:hidden=true

config_file="$HOME/.config/omarchy/shell.json"
defaults_file="$OMARCHY_PATH/config/omarchy/shell.json"
source_file=$defaults_file
[[ -s $config_file ]] && source_file=$config_file

effect=$(jq -er '.idle.screensaverEffect // empty' "$source_file" 2>/dev/null) || exit 0
[[ -n $effect ]] || exit 0

# Every ttfx effect is also its own subcommand, so this doubles as validation:
# an effect name that isn't real fails --help instead of ttfx erroring later,
# inside the screensaver's restart loop, with no easy way to surface why.
if ttfx "$effect" --help >/dev/null 2>&1; then
printf '%s\n' "$effect"
else
omarchy-notification-send -g ⚠️ "Unknown screensaver effect \"$effect\" in shell.json, using random effects"
fi
4 changes: 4 additions & 0 deletions default/agents/skills/omarchy/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,7 @@ automatically. If a change somehow fails to apply, force a reload with
Set `idle.screensaver` and `idle.lock` in `~/.config/omarchy/shell.json`,
in seconds since user idle began. Example: "lock after ten minutes" means
setting `idle.lock` to `600`.

Set `idle.screensaverEffect` to a `ttfx` effect name (e.g. `"matrix"`) to
pin the screensaver to that effect instead of a random one each cycle. An
unrecognized name falls back to random and notifies.
3 changes: 3 additions & 0 deletions docs/omarchy-shell.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ Rules:
First-party non-bar plugins are enabled unless listed in `disabledPlugins[]`.
6. `barWidget.allowMultiple: true` in the manifest permits multiple instances.
7. `idle.screensaver` and `idle.lock` are seconds since user idle began.
`idle.screensaverEffect` is optional and pins the screensaver to one
`ttfx` effect name instead of picking randomly each cycle; an
unrecognized name is ignored (falls back to random) and notifies.
8. `version: 1` is required.

`config/omarchy/shell.json` describes the fresh-install state. When no
Expand Down
14 changes: 14 additions & 0 deletions manual/13-toggles-idle-screensaver.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,20 @@ You can start it on demand from _System > Screensaver_ (`Super + Esc`), which fo

The logo it draws is yours to change, under _Style > Screensaver_. Upload a png or svg and Omarchy converts it to ASCII. See [branding](41-branding.md).

Each run of the screensaver picks a random effect from `ttfx`, the terminal text-effects engine underneath it — beams, matrix-style digital rain, fireworks, and dozens more. To pin it to one effect instead, add `screensaverEffect` to the `idle` block in `~/.config/omarchy/shell.json`:

```json
{
"idle": {
"screensaver": 150,
"lock": 300,
"screensaverEffect": "matrix"
}
}
```

The name has to match one of `ttfx`'s effects (run `ttfx --help` for the full list); an unrecognized name falls back to the random rotation and sends a notification saying so.

### The lock screen

`Super + Ctrl + L` locks the machine. That runs the lock screen from the Omarchy shell, blanks the display, resets your keyboard layout to the first one so you're not typing your password in the wrong alphabet, and — if you have it running — locks 1Password on the way out.
Expand Down
73 changes: 73 additions & 0 deletions test/shell.d/screensaver-effect-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

require_command jq

test_tmp=$(mktemp -d)
trap 'rm -rf "$test_tmp"' EXIT

stub_bin="$test_tmp/bin"
mkdir -p "$stub_bin"

# Only "matrix" is a real effect here; anything else fails --help the way an
# unrecognized ttfx subcommand would.
cat >"$stub_bin/ttfx" <<'STUB'
#!/bin/bash
[[ $1 == "matrix" && $2 == "--help" ]]
STUB
chmod +x "$stub_bin/ttfx"

notify_log="$test_tmp/notify.log"
cat >"$stub_bin/omarchy-notification-send" <<STUB
#!/bin/bash
printf '%s\n' "\$*" >>"$notify_log"
STUB
chmod +x "$stub_bin/omarchy-notification-send"

fake_home="$test_tmp/home"
fake_omarchy_path="$test_tmp/omarchy-path"
mkdir -p "$fake_home/.config/omarchy" "$fake_omarchy_path/config/omarchy"

cat >"$fake_omarchy_path/config/omarchy/shell.json" <<'JSON'
{
"version": 1,
"idle": { "screensaver": 150, "lock": 300 }
}
JSON

resolve_effect() {
rm -f "$notify_log"
HOME="$fake_home" OMARCHY_PATH="$fake_omarchy_path" PATH="$stub_bin:$PATH" \
"$ROOT/bin/omarchy-screensaver-effect"
}

# No screensaverEffect configured anywhere: falls back to random, silently.
rm -f "$fake_home/.config/omarchy/shell.json"
[[ -z $(resolve_effect) ]] || fail "screensaver effect defaults to random when unset"
[[ ! -s $notify_log ]] || fail "screensaver effect stays quiet when unset"
pass "screensaver effect defaults to random when unset"

# A recognized effect is resolved and printed as-is.
cat >"$fake_home/.config/omarchy/shell.json" <<'JSON'
{
"version": 1,
"idle": { "screensaver": 150, "lock": 300, "screensaverEffect": "matrix" }
}
JSON
[[ $(resolve_effect) == "matrix" ]] || fail "screensaver effect resolves a configured effect"
[[ ! -s $notify_log ]] || fail "screensaver effect stays quiet for a valid effect"
pass "screensaver effect resolves a configured effect"

# An unrecognized effect name falls back to random and notifies why.
cat >"$fake_home/.config/omarchy/shell.json" <<'JSON'
{
"version": 1,
"idle": { "screensaver": 150, "lock": 300, "screensaverEffect": "not-a-real-effect" }
}
JSON
[[ -z $(resolve_effect) ]] || fail "screensaver effect falls back to random for an unknown effect"
grep -q "not-a-real-effect" "$notify_log" || fail "screensaver effect notifies about the unknown effect"
pass "screensaver effect falls back to random and notifies for an unknown effect"