Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 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
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ You can then run the `anifetch` command **directly in your terminal**.

Since pipx installs packages in an isolated environment, you won't have to worry about dependency conflicts or polluting your global python environment. `anifetch` will behave just like a native cli tool. You can upgrade your installation with `pipx upgrade anifetch`


---

### 👨‍💻 Developer Installation (for contributors): via `pip` in a virtual environment
Expand Down Expand Up @@ -88,6 +87,8 @@ Any video file you give to anifetch will be stored in `~/.local/share/anifetch/a
anifetch video.mp4 -r 10 -W 40 -H 20 -c "--symbols wide --fg-only"
```

_Note : by default, the video `example.mp4` can directly be used as an example._

### Optional arguments:

- `-f` / `--file`: path to the video file (the path can be added without the `-f` argument)
Expand All @@ -100,6 +101,20 @@ anifetch video.mp4 -r 10 -W 40 -H 20 -c "--symbols wide --fg-only"
- `-ff` / `--fast-fetch`: uses `fastfetch` instead of `neofetch` if available
- `-fr` / `--force-render`: Forcefully re-renders the animation while not caring about the cache. Useful if the cache is broken.

### Cached files:

Anifetch automatically caches rendered animations to speed up future runs. Each unique combination of video and render options generates a cache stored in `~/.local/share/anifetch/`, organized by hash. This includes frames, output, and audio.

Cache-related commands:

`anifetch --cache-list` — View all cached configurations and orders them.

`anifetch --cache-delete <number>` — Delete a specific cache.

`anifetch --clear` — Delete all cached files.

Note that modifying the content of a video file but keeping the same name makes Anifetch still use the old cache. In that case, use `--force-render` to bypass the cache and generate a new version.

For full help:

```bash
Expand All @@ -121,6 +136,10 @@ Here's the benchmark from running each cli 10 times. Tested on Linux Mint with I

As it can be seen, **Anifetch** is quite fast if you cache the animations, especially when paired with fastfetch.

## Troubleshooting

Make sure to install the dependencies listed on [Prerequisites](#Prerequisites). If ffmpeg throws an error saying `libxm12.so.16: cannot open shared object file: No such file or directory exists` then you must install `libxm12`. Here's an comment showing how to install it for arch: [https://github.com/Notenlish/anifetch/issues/24#issuecomment-2920189918](solution)

## 📝 Notes

Anifetch attempts to cache the animation so that it doesn't need to render them again when you run it with the same file. However, if the name of the file is the same, but it's contents has changed, it won't re-render it. In that case, you will need to add `--force-render` as an argument to `anifetch.py` so that it re-renders it. You only have to do this only once when you change the file contents.
Expand Down Expand Up @@ -157,7 +176,7 @@ Currently only the `symbols` format of chafa is supported, formats like kitty, i

- [ ] Use threading when seperating video into frames and process them with chafa at the same time. This should speed up caching significantly.

- [X] Fix transparent video frame seperation.
- [x] Fix transparent video frame seperation.

- [ ] Figure out a way to display animations faster. Either optimize the bash script or use Python/C.

Expand Down
2 changes: 1 addition & 1 deletion nix/packages/anifetch.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ in
fs.trace sourceFiles
python3Packages.buildPythonApplication {
name = "aniftech-wrapped";
version = "0.1.1";
version = "1.1.1";
pyproject = true;
src = fs.toSource {
root = ../../.;
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "anifetch"
version = "0.1.1"
version = "1.1.1"
description = "Animated terminal fetch with video/audio support."
authors = [{name = "Notenlish"}, {name = "Immelancholy"}, {name = "Gallophostrix", email = "[email protected]"}]
readme = "README.md"
Expand Down
4 changes: 4 additions & 0 deletions ruff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

ruff check . --fix
ruff format .
3 changes: 1 addition & 2 deletions src/anifetch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
def main():
args = parse_args()

if args.filename:
run_anifetch(args)
run_anifetch(args)


if __name__ == "__main__":
Expand Down
29 changes: 16 additions & 13 deletions src/anifetch/anifetch-static-resize2.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
#!/bin/bash

FRAME_DIR="$HOME/.local/share/anifetch/output"
STATIC_TEMPLATE_FILE="$HOME/.local/share/anifetch/template.txt"

# check for num of args
if [[ $# -ne 6 && $# -ne 7 ]]; then
echo "Usage: $0 <framerate> <top> <left> <right> <bottom> <template_actual_width> [soundname]"
echo "Usage: $0 <cache_path> <framerate> <top> <left> <right> <bottom> <template_actual_width> [soundname]"
exit 1
fi

framerate=$1
top=$2
left=$3
right=$4
bottom=$5
template_actual_width=$6
soundname=$7
CACHE_DIR="$1"
framerate=$2
top=$3
left=$4
right=$5
bottom=$6
template_actual_width=$7
soundname=$8

FRAME_DIR="$CACHE_DIR/output"
STATIC_TEMPLATE_FILE="$CACHE_DIR/template.txt"

num_lines=$((bottom - top))
sleep_time=$(echo "scale=4; 1 / $framerate" | bc)
Expand All @@ -34,13 +35,15 @@ cleanup() {
tput cnorm # Show cursor
if [ -t 0 ]; then
stty echo # Restore echo
stty icanon
fi
tput sgr0 # Reset terminal attributes
tput cup $(tput lines) 0 # Move cursor to bottom
exit 0
}
trap cleanup SIGINT SIGTERM
stty -echo # won't allow ^C to be printed when SIGINT signal comes.
stty -icanon

# Process the template once and store in memory buffer
process_template() {
Expand Down Expand Up @@ -224,7 +227,7 @@ wanted_epoch=0
start_time=$(date +%s.%N)
while true; do

for frame in $(ls "$FRAME_DIR" | sort -n); do
for frame in $(ls "$FRAME_DIR" | sort -n); do #### for frame in $(find "$FRAME_DIR" -type f | sort -V); do
lock=true
current_top=$top
while IFS= read -r line; do
Expand Down Expand Up @@ -255,4 +258,4 @@ while true; do
process_resize_if_needed
done
sleep 0.005
done
done
26 changes: 23 additions & 3 deletions src/anifetch/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ def parse_args():
)
parser.add_argument(
"filename",
help="Video file to use (default: example.mp4)",
nargs="?",
default=None,
help="Video file to use (e.g. video.mp4).",
type=str,
)
parser.add_argument(
Expand Down Expand Up @@ -78,7 +80,7 @@ def parse_args():
"-c",
"--chafa-arguments",
default="--symbols ascii --fg-only",
help="Specify the arguments to give to chafa. For more informations, use 'chafa --help'",
help="Specify the arguments to give to chafa. For more information, use 'chafa --help'",
)
parser.add_argument(
"--force",
Expand All @@ -105,7 +107,25 @@ def parse_args():
action="version",
version="%(prog)s {version}".format(version=get_version_of_anifetch()),
)

parser.add_argument(
"--cache-list",
required=False,
action="store_true",
help="List all saved cache configurations.",
)
parser.add_argument(
"--delete",
required=False,
type=int,
nargs="+",
help="Delete one or more caches by number(s) (as listed with --cache-list)",
)
parser.add_argument(
"--clear",
required=False,
action="store_true",
help="Clear all saved cache configurations.",
)
args = parser.parse_args()

return args
Loading