From d506ab9c525280d4404fa96bb9833f7864c1d9a5 Mon Sep 17 00:00:00 2001 From: Notenlish <71970100+Notenlish@users.noreply.github.com> Date: Mon, 30 Jun 2025 18:35:52 +0300 Subject: [PATCH 1/6] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 48d2907..a59aa7e 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,11 @@ If you set animation resolution really big it may not be able to keep up with th Currently only the `symbols` format of chafa is supported, formats like kitty, iterm etc. are not supported. If you try to tell chafa to use iterm, kitty etc. it will just override your format with `symbols` mode. +## Running Anifetch On Terminal Startup + +Add `exec anifetch [YOUR_FILENAME] [YOUR_ARGS] &` to the bottom of your `.bashrc` + + ## 🚧 What's Next - [x] Add music support From 3d7d9b53c7a0cc9945ae0ffca3326c940b3038ec Mon Sep 17 00:00:00 2001 From: Notenlish <71970100+Notenlish@users.noreply.github.com> Date: Thu, 10 Jul 2025 01:24:29 +0300 Subject: [PATCH 2/6] added startup functionality --- README.md | 6 ++--- pyproject.toml | 2 +- src/anifetch/anifetch-static-resize2.sh | 31 ++++++++++++++++++------- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index a59aa7e..b9bba53 100644 --- a/README.md +++ b/README.md @@ -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 @@ -139,8 +138,7 @@ Currently only the `symbols` format of chafa is supported, formats like kitty, i ## Running Anifetch On Terminal Startup -Add `exec anifetch [YOUR_FILENAME] [YOUR_ARGS] &` to the bottom of your `.bashrc` - +Add `anifetch [YOUR_FILENAME] [YOUR_ARGS]` to the bottom of your `.bashrc` ## 🚧 What's Next @@ -166,7 +164,7 @@ Add `exec anifetch [YOUR_FILENAME] [YOUR_ARGS] &` to the bottom of your `.bashrc - [ ] 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. diff --git a/pyproject.toml b/pyproject.toml index 4392d1a..24798da 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "anifetch" -version = "0.1.1" +version = "0.1.2" description = "Animated terminal fetch with video/audio support." authors = [{name = "Notenlish"}, {name = "Immelancholy"}, {name = "Gallophostrix", email = "gallophostrix@gmail.com"}] readme = "README.md" diff --git a/src/anifetch/anifetch-static-resize2.sh b/src/anifetch/anifetch-static-resize2.sh index 3c88fea..d646668 100644 --- a/src/anifetch/anifetch-static-resize2.sh +++ b/src/anifetch/anifetch-static-resize2.sh @@ -15,6 +15,7 @@ left=$3 right=$4 bottom=$5 template_actual_width=$6 +# last arg(optional) soundname=$7 num_lines=$((bottom - top)) @@ -32,17 +33,32 @@ tput civis # exit handler cleanup() { tput cnorm # Show cursor - if [ -t 0 ]; then - stty echo # Restore echo - stty icanon - fi + # whats wrong with stty + if [ -c /dev/tty ]; then # Check if /dev/tty is a character device + stty echo < /dev/tty # Restore echo + stty icanon < /dev/tty # Restore canonical mode + else + # Fallback for if /dev/tty is not available or not a character device. + # This might still fail though + stty echo + stty icanon + fi + tput sgr0 # Reset terminal attributes - tput cup $(tput lines) 0 # Move cursor to bottom + 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. + +# Apply stty commands, redirect stdin from /dev/tty +if [ -c /dev/tty ]; then +stty -echo < /dev/tty +stty -icanon < /dev/tty +else +stty -echo stty -icanon +fi # Process the template once and store in memory buffer process_template() { @@ -225,7 +241,6 @@ i=1 wanted_epoch=0 start_time=$(date +%s.%N) while true; do - for frame in $(ls "$FRAME_DIR" | sort -n); do lock=true current_top=$top @@ -238,7 +253,6 @@ while true; do fi done < "$FRAME_DIR/$frame" lock=false - wanted_epoch=$(echo "$i/$framerate" | bc -l) # current time in seconds (with fractional part) @@ -253,7 +267,6 @@ while true; do fi i=$((i + 1)) - process_resize_if_needed done sleep 0.005 From 8b6ab5f4b34ed3b7ae11a3410ca47f7c0a164985 Mon Sep 17 00:00:00 2001 From: Notenlish <71970100+Notenlish@users.noreply.github.com> Date: Thu, 17 Jul 2025 22:14:23 +0300 Subject: [PATCH 3/6] skipping frames added its not related in any way to this branch but im too lazy to create a new branch. --- src/anifetch/anifetch-static-resize2.sh | 33 ++++++++++++++++++------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/anifetch/anifetch-static-resize2.sh b/src/anifetch/anifetch-static-resize2.sh index d646668..afa3b9a 100644 --- a/src/anifetch/anifetch-static-resize2.sh +++ b/src/anifetch/anifetch-static-resize2.sh @@ -44,6 +44,11 @@ cleanup() { stty icanon fi + # Kill ffplay if it's running + if [[ -n "$ffplay_pid" ]] && ps -p "$ffplay_pid" > /dev/null 2>&1; then + kill "$ffplay_pid" + fi + tput sgr0 # Reset terminal attributes tput cup $(tput lines) 0 # Move cursor to bottom exit 0 @@ -234,7 +239,7 @@ draw_static_template # Start audio if sound is provided if [ $# -eq 7 ]; then - ffplay -nodisp -autoexit -loop 0 -loglevel quiet "$soundname" & + ffplay -nodisp -autoexit -loop 0 -loglevel quiet "$soundname" & ffplay_pid=$! fi i=1 @@ -242,8 +247,25 @@ wanted_epoch=0 start_time=$(date +%s.%N) while true; do for frame in $(ls "$FRAME_DIR" | sort -n); do + wanted_epoch=$(echo "$i/$framerate" | bc -l) + + # current time in seconds (with fractional part) + now=$(date +%s.%N) + + # Calculate how long to sleep to stay in sync + sleep_duration=$(echo "$wanted_epoch - ($now - $start_time)" | bc -l) + lock=true current_top=$top + + # if behind schedule + if (( $(echo "$sleep_duration < 0" | bc -l) )); then + echo "skipping frame $i (behind by ${sleep_duration}s)" >> "$HOME/Desktop/anifetch-debug.log" + i=$((i + 1)) + + continue # skip to the next frame. + fi + while IFS= read -r line; do tput cup "$current_top" "$left" echo -ne "$line" @@ -253,19 +275,12 @@ while true; do fi done < "$FRAME_DIR/$frame" lock=false - wanted_epoch=$(echo "$i/$framerate" | bc -l) - - # current time in seconds (with fractional part) - now=$(date +%s.%N) - - # Calculate how long to sleep to stay in sync - sleep_duration=$(echo "$wanted_epoch - ($now - $start_time)" | bc -l) # Only sleep if ahead of schedule if (( $(echo "$sleep_duration > 0" | bc -l) )); then sleep "$sleep_duration" fi - + i=$((i + 1)) process_resize_if_needed done From 0dc370d6b7cc5ebfb601eae39adf73afe0124f2d Mon Sep 17 00:00:00 2001 From: Notenlish <71970100+Notenlish@users.noreply.github.com> Date: Thu, 17 Jul 2025 23:04:48 +0300 Subject: [PATCH 4/6] Update README.md --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b9bba53..ee90882 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,16 @@ Currently only the `symbols` format of chafa is supported, formats like kitty, i ## Running Anifetch On Terminal Startup -Add `anifetch [YOUR_FILENAME] [YOUR_ARGS]` to the bottom of your `.bashrc` +Add this to the bottom of your `.bashrc` or `.zshrc` + +```sh +# Only launch this program on direct terminal (tty) sessions +if [[ -t 1 ]] && [[ $- == *i* ]]; then + anifetch [FILENAME] [ARGS] +fi +``` + +also make sure PATH is available(for pipx installations) so it can find anifetch. ## 🚧 What's Next From 221a08314739cee39b987d099ccee01acc8bf45a Mon Sep 17 00:00:00 2001 From: Notenlish <71970100+Notenlish@users.noreply.github.com> Date: Fri, 18 Jul 2025 00:26:18 +0300 Subject: [PATCH 5/6] forgot to remove this --- src/anifetch/anifetch-static-resize2.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/src/anifetch/anifetch-static-resize2.sh b/src/anifetch/anifetch-static-resize2.sh index afa3b9a..9d6996f 100644 --- a/src/anifetch/anifetch-static-resize2.sh +++ b/src/anifetch/anifetch-static-resize2.sh @@ -260,7 +260,6 @@ while true; do # if behind schedule if (( $(echo "$sleep_duration < 0" | bc -l) )); then - echo "skipping frame $i (behind by ${sleep_duration}s)" >> "$HOME/Desktop/anifetch-debug.log" i=$((i + 1)) continue # skip to the next frame. From e979d6e9f8ee5a8f2a6b8864e974fe0283c32ed0 Mon Sep 17 00:00:00 2001 From: Notenlish <71970100+Notenlish@users.noreply.github.com> Date: Mon, 21 Jul 2025 23:09:02 +0300 Subject: [PATCH 6/6] fix text of -ff --fastfetch help --- src/anifetch/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/anifetch/cli.py b/src/anifetch/cli.py index a19d484..1904ad7 100644 --- a/src/anifetch/cli.py +++ b/src/anifetch/cli.py @@ -90,7 +90,7 @@ def parse_args(): "-ff", "--fast-fetch", default=False, - help="Add this argument if you want to use fastfetch instead. Note than fastfetch will be run with '--logo none'.", + help="Add this argument if you want to use fastfetch instead of Neofetch.", action="store_true", ) parser.add_argument(