Skip to content
Merged
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
1 change: 1 addition & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,4 @@ omarchy theme remove tidal # or wheelie

That deletes the theme's folder. Its two hooks then remove themselves and the animation in
`~/.local/share/wheely/themes/`, one at the next theme change and the other at the next boot.
The last of the two to go also removes `wheely-fetch`, its `fastfetch` aliases and the fastfetch config link.
6 changes: 5 additions & 1 deletion tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ directories. Additional checks and their dependencies are documented with the fe
offscreen platform cannot initialize Vulkan.
`python3 tests/wheelie-install.py` checks staged installation and that failed copies
leave the installed theme untouched, with temporary paths and command stubs; it needs
no graphics session.
no graphics session. It also checks the fastfetch link and aliases, that a user's own fastfetch
config stays, and that the last theme removed takes `wheely-fetch`, the aliases and the link along.
- `python3 tests/fastfetch-play.py` plays a tiny scene through `wheely-fetch` on a
pseudo-terminal with fastfetch stubbed, and checks plain fastfetch for arguments, pipes,
terminals too short for the output, themes without a scene and a fastfetch config of the user's own.
- `python3 tests/wallpaper-toggle.py` checks that the shared pause shortcut routes
to the active Tidal or Wheelie CLI and leaves other or missing themes alone.
- `python3 tests/theme-dpr.py` checks that both wallpapers size their textures from the
Expand Down
2 changes: 1 addition & 1 deletion tests/all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ for shader in $(git ls-files '*.frag' '*.vert'); do
done

node tests/check.js
for test in install desktop open-path shell-launch wheelie-install wallpaper-toggle runtime files-preview files-markdown \
for test in install desktop open-path shell-launch wheelie-install fastfetch-play wallpaper-toggle runtime files-preview files-markdown \
lock-process wheelie-lifecycle wheelie-dust wheelie-clock theme-dpr wheel-manual-fit; do
printf '\nRunning %s\n' "$test"
python3 "tests/$test.py"
Expand Down
73 changes: 73 additions & 0 deletions tests/fastfetch-play.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env python3
"""Play a tiny two-frame scene through wheely-fetch on a pseudo-terminal, with fastfetch stubbed."""
import fcntl
import os
from pathlib import Path
import pty
import struct
import subprocess
import tempfile
import termios
import tty

player = Path(__file__).resolve().parents[1] / "themes/fastfetch-play"

with tempfile.TemporaryDirectory(prefix="fastfetch-play-") as temp:
home, commands = Path(temp) / "home", Path(temp) / "bin"
scene = home / ".local/state/omarchy/current/theme/fastfetch"
scene.mkdir(parents=True)
commands.mkdir()
# fastfetch draws a 2-row logo padded down one line beside 3 info lines, then its blank line.
stub = commands / "fastfetch"
stub.write_text('#!/bin/sh\necho "$*" >> "$HOME/calls"\nprintf "info\\nLOGO1 info\\nLOGO2 info\\n \\n\\033[m"\n')
stub.chmod(0o755)
env = os.environ | {"HOME": str(home), "XDG_CONFIG_HOME": str(home / ".config"),
"PATH": f"{commands}{os.pathsep}{os.environ['PATH']}"}
fetch = home / ".config/fastfetch/config.jsonc"
fetch.parent.mkdir(parents=True)
fetch.symlink_to(scene / "config.jsonc")

def run(*args, height=24):
"""The player's output on a terminal of this many rows."""
leader, follower = pty.openpty()
fcntl.ioctl(follower, termios.TIOCSWINSZ, struct.pack("HHHH", height, 80, 0, 0))
tty.setraw(follower) # bytes as written, without newline translation
subprocess.run([str(player), *args], env=env, stdout=follower, check=True, timeout=10)
os.close(follower)
out = b""
try:
while chunk := os.read(leader, 65536): out += chunk
except OSError:
pass
return out.decode()

# Without a scene, plain fastfetch.
run()
assert (home / "calls").read_text() == "\n", "a theme without a scene was not plain fastfetch"

(scene / "scene.txt").write_text("4 2 2 60\nAAAA\nBBBB\n\x1b[2CX\n\n")
out = run()
assert (home / "calls").read_text().splitlines()[-1] == f"-c {scene}/config.jsonc --pipe false"
# fastfetch printed 4 lines: each frame climbs 3 to the logo, draws its 2 rows, steps back down 1.
assert out.count("\x1b[3A") == 2 and out.count("\x1b[1B") == 2, out
assert "\x1b[2CAAAA\r\n\x1b[2CBBBB\r\n" in out and "\x1b[2C\x1b[2CX\r\n\x1b[2C\r\n" in out, out
# The cursor shows again, and fastfetch's blank last line is taken back for the prompt.
assert out.endswith("\x1b[?25h") and "\x1b[1A" in out.rsplit("\x1b[2C", 1)[1], out
print("ok: wheely-fetch plays the scene over fastfetch's logo")

# A terminal no taller than the output has scrolled; the still stays.
assert "\x1b[3A" not in run(height=4)
print("ok: wheely-fetch leaves a scrolled logo still")

# Arguments, or a pipe, get plain fastfetch.
run("--logo", "none")
assert (home / "calls").read_text().splitlines()[-1] == "--logo none"
piped = subprocess.run([str(player)], env=env, capture_output=True, text=True, check=True)
assert (home / "calls").read_text().splitlines()[-1] == "" and "\x1b[" not in piped.stdout.replace("\x1b[m", "")
print("ok: wheely-fetch is plain fastfetch for arguments and pipes")

# A config of the user's own in place of the theme's link gets plain fastfetch.
fetch.unlink()
fetch.write_text("mine")
assert "\x1b[3A" not in run() and (home / "calls").read_text().splitlines()[-1] == ""
print("ok: wheely-fetch is plain fastfetch under the user's own config")
6 changes: 4 additions & 2 deletions tests/tidal-lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,18 @@ def select(name, animated, muted=False):
source = output / "source"
shutil.rmtree(source, ignore_errors=True)
# What runs goes apart from the theme's folder, which holds only data and is another theme's to replace.
data = ["colors.toml", "shell.toml", "icons.theme", "preview.jpg", "backgrounds/01-shoreline.jpg"]
data = ["colors.toml", "shell.toml", "icons.theme", "preview.jpg", "backgrounds/01-shoreline.jpg",
"fastfetch/config.jsonc", "fastfetch/logo.txt", "fastfetch/scene.txt"]
runtime = ["animated/shell.qml", "animated/tidal.frag.qsb", "animated/noise.frag.qsb"]
for name in data + runtime + ["README.md", "preview.qml", "hooks/tidal-wallpaper", "animated/tidal.frag",
"animated/noise.frag", "animated/noise.glsl", "animated/bake-bubbles.py"]:
(source / name).parent.mkdir(parents=True, exist_ok=True)
(source / name).write_text(name)
shutil.copy2(repo / "themes/tidal/tidal", source / "tidal")
(output / "fastfetch-play").write_text("player")
(theme_folder / "backgrounds").mkdir(parents=True, exist_ok=True)
(theme_folder / "backgrounds/stale.jpg").write_text("removed from the theme")
subprocess.run([str(source / "tidal"), "install"], env=cli_env, check=True, capture_output=True)
subprocess.run([str(source / "tidal"), "install"], env=dict(cli_env, HOME=str(output / "home")), check=True, capture_output=True)
for folder, files in ((theme_folder, data), (installed, runtime + ["tidal"])):
assert sorted(str(p.relative_to(folder)) for p in folder.rglob("*") if p.is_file()) == sorted(files), folder
assert not list((output / "config/omarchy").glob(".tidal-install-*"))
Expand Down
46 changes: 42 additions & 4 deletions tests/wheelie-install.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ def snapshot(directory):
source.mkdir()
commands.mkdir()
shutil.copy2(repo / "wheelie", source / "wheelie")
for folder in ("hooks", "backgrounds", "scene"):
for folder in ("hooks", "backgrounds", "scene", "fastfetch"):
(source / folder).mkdir()
(root / "fastfetch-play").write_text("player")
shutil.copy2(repo / "hooks/wheelie-wallpaper", source / "hooks/wheelie-wallpaper")
for name in ("colors.toml", "icons.theme", "preview.jpg", "backgrounds/00-wheelie-animated.jpg",
"backgrounds/static.jpg", "scene/wallpaper.qml", "scene/ambient-dust.vert.qsb",
"scene/ambient-dust.frag.qsb", "scene/ambient-dust.vert", "scene/ambient-dust.frag"):
"scene/ambient-dust.frag.qsb", "scene/ambient-dust.vert", "scene/ambient-dust.frag",
"fastfetch/config.jsonc", "fastfetch/logo.txt", "fastfetch/scene.txt"):
(source / name).write_text("new " + name)
os.utime(source, (0, 0))
stub = """#!/usr/bin/env python3
Expand Down Expand Up @@ -69,16 +71,29 @@ def snapshot(directory):
log = root / f"{failure}.log"
env = os.environ | {
"XDG_CONFIG_HOME": str(config), "XDG_DATA_HOME": str(root / (failure + "-data")), "WHEELIE_FAIL": failure, "WHEELIE_LOG": str(log),
"HOME": str(root / (failure + "-home")),
"PATH": str(commands) + os.pathsep + os.environ["PATH"],
}
(root / (failure + "-home")).mkdir()
(root / (failure + "-home/.bashrc")).write_text("# mine\n")
(config / "fish").mkdir(parents=True, exist_ok=True)
result = subprocess.run([str(source / "wheelie"), "install"], env=env,
capture_output=True, text=True, timeout=20)
calls = log.read_text()
if failure == "none":
assert result.returncode == 0, result.stderr
assert (code / "animated/wallpaper.qml").read_text() == "new scene/wallpaper.qml"
# Nothing that runs is in the theme's folder, which another theme may replace.
assert sorted(p.name for p in destination.iterdir()) == ["backgrounds", "colors.toml", "icons.theme", "preview.jpg"]
assert sorted(p.name for p in destination.iterdir()) == ["backgrounds", "colors.toml", "fastfetch", "icons.theme", "preview.jpg"]
assert (destination / "fastfetch/scene.txt").read_text() == "new fastfetch/scene.txt"
# fastfetch follows the current theme, and wheely-fetch plays its scene.
home = root / "none-home"
assert os.readlink(config / "fastfetch/config.jsonc") == str(home / ".local/state/omarchy/current/theme/fastfetch/config.jsonc")
assert (home / ".local/bin/wheely-fetch").read_text() == "player"
# Typing fastfetch plays it too, in bash and fish, added once however often install runs.
subprocess.run([str(source / "wheelie"), "install"], env=env, capture_output=True, timeout=20)
assert (home / ".bashrc").read_text() == "# mine\nalias fastfetch=wheely-fetch\n"
assert "wheely-fetch $argv" in (config / "fish/functions/fastfetch.fish").read_text()
poster = "backgrounds/00-wheelie-animated.jpg"
assert (destination / poster).read_text() == "new " + poster
for name in ("ambient-dust.vert.qsb", "ambient-dust.frag.qsb"):
Expand All @@ -101,12 +116,20 @@ def snapshot(directory):
for failure in ("copy", "none"):
config = root / f"fresh-{failure}"
destination = config / "omarchy/themes/wheelie"
env.update(XDG_CONFIG_HOME=str(config), XDG_DATA_HOME=str(config / "data"), WHEELIE_FAIL=failure)
env.update(XDG_CONFIG_HOME=str(config), XDG_DATA_HOME=str(config / "data"), WHEELIE_FAIL=failure, HOME=str(config / "home"))
(config / "fastfetch").mkdir(parents=True)
(config / "fastfetch/config.jsonc").write_text("mine")
(config / "fish").mkdir()
(config / "home").mkdir()
(config / "home/.bashrc").write_text("# mine\n")
result = subprocess.run([str(source / "wheelie"), "install"], env=env,
capture_output=True, text=True, timeout=20)
assert (result.returncode == 0) == (failure == "none"), result.stderr
assert destination.exists() == (config / "data/wheely/themes/wheelie").exists() == (failure == "none")
assert not list(destination.parent.parent.glob(".wheelie-install-*"))
assert (config / "fastfetch/config.jsonc").read_text() == "mine", "a user's fastfetch config was replaced"
assert "alias" not in (config / "home/.bashrc").read_text(), "fastfetch was aliased past the user's config"
assert not (config / "fish/functions/fastfetch.fish").exists()
print(f"ok: first Wheelie install {failure}")

# Omarchy's theme removal deletes only the folder; each animated theme's hook then removes itself
Expand All @@ -125,6 +148,17 @@ def snapshot(directory):
(where / theme).chmod(0o755)
hooked = os.environ | {"HOME": str(home), "XDG_CONFIG_HOME": str(home / ".config"),
"XDG_DATA_HOME": str(home / "data")}
fetch, player = home / ".config/fastfetch/config.jsonc", home / ".local/bin/wheely-fetch"
fetch.parent.mkdir(parents=True)
fetch.symlink_to(home / ".local/state/omarchy/current/theme/fastfetch/config.jsonc")
player.parent.mkdir(parents=True)
player.write_text("player")
alias, fish = home / ".bashrc", home / ".config/fish/functions/fastfetch.fish"
alias.write_text("# mine\nalias fastfetch=wheely-fetch\n")
fish.parent.mkdir(parents=True)
fish.write_text("function fastfetch; wheely-fetch $argv; end\n")
if theme == "wheelie": # another animated theme stays installed
(home / "data/wheely/themes/tidal").mkdir(parents=True)
subprocess.run(["bash", str(hook)], env=hooked, check=True)
assert hook.exists() and not (home / "ran").exists(), theme + "'s hook ran or left under another theme"
(home / ".local/state/omarchy/current/theme.name").write_text(theme + "\n")
Expand All @@ -133,4 +167,8 @@ def snapshot(directory):
shutil.rmtree(folder)
subprocess.run(["bash", str(hook)], env=hooked, check=True)
assert not hook.exists() and not code.exists(), theme + "'s hook or scene outlived its theme"
# wheely-fetch, its aliases and the fastfetch link leave with the last animated theme.
last = theme == "tidal"
assert player.exists() != last and fetch.is_symlink() != last and fish.exists() != last, theme
assert ("alias" in alias.read_text()) != last and alias.read_text().startswith("# mine"), theme
print(f"ok: {theme}'s hook leaves with its theme")
24 changes: 23 additions & 1 deletion themes/animated-theme
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ case "${1:-help}" in
trap 'rm -rf "$stage"' EXIT
new="$stage/$name"
mkdir "$new"
cp -a "$theme"/{colors.toml,icons.theme,preview.jpg,backgrounds} "$new/"
cp -a "$theme"/{colors.toml,icons.theme,preview.jpg,backgrounds,fastfetch} "$new/"
if [[ -e $theme/shell.toml ]]; then cp -a "$theme/shell.toml" "$new/"; fi
mkdir "$stage/code"
cp -L "$theme/$name" "$stage/code/$name"
Expand Down Expand Up @@ -55,6 +55,28 @@ case "${1:-help}" in
fi
exit 1
fi
# fastfetch follows the current theme: its scene's last frame, or Omarchy's own when the theme
# has none, since fastfetch skips a config link that leads nowhere. A config of the user's stays.
fetch="${XDG_CONFIG_HOME:-$HOME/.config}/fastfetch/config.jsonc"
link="$HOME/.local/state/omarchy/current/theme/fastfetch/config.jsonc"
if [[ ! -e $fetch && ! -L $fetch ]]; then
mkdir -p "${fetch%/*}"
ln -s "$link" "$fetch"
fi
mkdir -p "$HOME/.local/bin"
cp "$theme/../fastfetch-play" "$HOME/.local/bin/wheely-fetch"
# Unless fastfetch has the user's config, typing fastfetch plays the scene too, in bash and fish.
if [[ $(readlink -- "$fetch") == "$link" ]]; then
if [[ -f ~/.bashrc ]] && ! grep -qx 'alias fastfetch=wheely-fetch' ~/.bashrc; then
echo 'alias fastfetch=wheely-fetch' >>~/.bashrc
fi
fish="${XDG_CONFIG_HOME:-$HOME/.config}/fish"
if [[ -d $fish && ! -e $fish/functions/fastfetch.fish ]]; then
mkdir -p "$fish/functions"
# shellcheck disable=SC2016 # $argv is fish's
echo 'function fastfetch; wheely-fetch $argv; end' >"$fish/functions/fastfetch.fish"
fi
fi
omarchy hook install theme-set "$theme/hooks/$name-wallpaper"
omarchy hook install post-boot "$theme/hooks/$name-wallpaper"
"$code/$name" watch
Expand Down
14 changes: 13 additions & 1 deletion themes/animated-theme-hook
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,19 @@ name=$(basename -- "$0" -wallpaper)
theme="${XDG_CONFIG_HOME:-$HOME/.config}/omarchy/themes/$name"
code="${XDG_DATA_HOME:-$HOME/.local/share}/wheely/themes/$name"
# Omarchy's theme removal deletes only the folder, so this hook and what it runs leave too.
if [[ ! -d $theme && $0 == "$HOME"/.config/omarchy/hooks/* ]]; then rm -rf -- "$code" "$0"; exit 0; fi
if [[ ! -d $theme && $0 == "$HOME"/.config/omarchy/hooks/* ]]; then
rm -rf -- "$code" "$0"
# The last animated theme to leave takes wheely-fetch, its aliases and the fastfetch link along.
if [[ -z $(ls -A -- "${code%/*}" 2>/dev/null) ]]; then
fetch="${XDG_CONFIG_HOME:-$HOME/.config}/fastfetch/config.jsonc"
fish="${XDG_CONFIG_HOME:-$HOME/.config}/fish/functions/fastfetch.fish"
rm -f -- "$HOME/.local/bin/wheely-fetch"
if [[ -f ~/.bashrc ]]; then sed -i --follow-symlinks '/^alias fastfetch=wheely-fetch$/d' ~/.bashrc; fi
if grep -qs wheely-fetch "$fish"; then rm -f -- "$fish"; fi
if [[ $(readlink -- "$fetch") == "$HOME/.local/state/omarchy/current/theme/fastfetch/config.jsonc" ]]; then rm -f -- "$fetch"; fi
fi
exit 0
fi
if [[ "$(cat "$HOME/.local/state/omarchy/current/theme.name")" == "$name" ]]; then
# Never from the theme's folder: another theme installed under this name is not ours to run.
exec "$code/$name" watch
Expand Down
Loading