The original script (J621-Django/extras/fish_greeting system) downloaded image bytes from /random/?rating=X and read the X-File-* headers. The new API answers with JSON and a signed link, so the greeting now: - asks /api/random/?fastfetch=1&rating=<mode> for JSON; - parses url/j_id/filename/md5 with jq, python3, or a grep/sed fallback; - downloads the signed link and keeps the original display path (fastfetch kitty/kitty-icat logos, gifsicle preprocessing for GIFs, recursion guard, logging with rotation, greeting_mode 0/1/2 = NSFW/SFW/Questionable); - is configured through ~/.config/j621Greeting/config.fish or universal variables (J621_BASE, J621_WEB, J621_TOKEN, J621_FASTFETCH_CONFIG) instead of a hardcoded host, and prints the /detail/<J-ID> link on J621_WEB; - reports the API's own 404 message when a rating has no images, and keeps curl quiet so failures do not spill into the greeting. extras/fish_greeting/ contains the function, an install.fish (copies it into the fish functions dir, creates the config once, checks dependencies) and a README with the old-vs-new table and troubleshooting. The existing gm-switch helper and .desktop launchers keep working (same mode file). Tested with fish 4.9.3: syntax check on every file, guest and token runs against the dev API (unsigned vs signed URLs), the empty-rating and unreachable-API paths, and the grep/sed fallback with jq and python3 unavailable.
18 lines
800 B
Fish
18 lines
800 B
Fish
# Copy to ~/.config/j621Greeting/config.fish and adjust. All of these can also
|
|
# be universal variables, e.g. `set -Ux J621_BASE https://j621.example.ts.net`.
|
|
|
|
# API origin (no trailing slash needed).
|
|
set -g J621_BASE https://j621.rainbow-herring.ts.net
|
|
|
|
# Web origin used in the printed link. Only needed when the SPA is served
|
|
# from a different host than the API (split deployment).
|
|
# set -g J621_WEB https://j621-frontend.rainbow-herring.ts.net
|
|
|
|
# API token. Optional: gives you signed image URLs and access to items that
|
|
# are hidden from guests. Create one with `manage.py drf_create_token <user>`
|
|
# or copy it from the app (it is the same token the SPA stores).
|
|
# set -g J621_TOKEN paste-your-token-here
|
|
|
|
# fastfetch config name used for the greeting logo.
|
|
# set -g J621_FASTFETCH_CONFIG jake
|