From ac72802e5a9bd959601909c0b14980bf89567778 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 17 Sep 2022 14:37:31 -0500 Subject: [PATCH] got rid of mangaterm handling stdin --- .local/bin/mangaterm | 57 ++++++-------------------------------------- 1 file changed, 7 insertions(+), 50 deletions(-) diff --git a/.local/bin/mangaterm b/.local/bin/mangaterm index 46396c3..410a2b9 100755 --- a/.local/bin/mangaterm +++ b/.local/bin/mangaterm @@ -1,6 +1,4 @@ -#!/bin/bash - - set -e +#!/bin/sh #using PID for dirname in case multiple instances are opened they do not interfere CACHEDIR="$HOME/.cache/mangaterm" @@ -15,7 +13,7 @@ read_char() { } help() { - echo "Read manga/comics in the terminal" + echo "Read manga/comics/pdfs in the terminal" echo " mangaterm.sh DIRECTORY" echo " mangaterm.sh FILE" echo "" @@ -98,53 +96,12 @@ handleFile() { trap 'close' 2 trap 'close' 15 - [ "$1" = "--help" ] && help -if [ "$#" -gt 0 ]; then - - mkdir -p "$TMPDIR" - - if [ "$(echo "$1" | cut -c1-1)" = "-" ]; then - foot -e mangaterm "$2" 2>/dev/null > /dev/null - fi - - handleFile "$1" -else - - LINES=() - - while IFS= read -r line; do - LINES+=("$line") - done - - echo "${LINES[0]}" - echo "$I" - - LEN="${#LINES[@]}" - I=0 - while read -r -n 1 char < /dev/tty; do - if [ "$char" = "j" ]; then - I=$((I + 1)) - elif [ "$char" = "k" ]; then - I=$((I - 1)) - elif [ "$char" = "q" ]; then - close - fi - - if [ "$I" -ge "$LEN" ] || [ "$I" -le "0" ]; then - if [ "$I" -ge "$LEN" ]; then - I="$LEN" - elif [ "$I" -lt "0" ]; then - I=0 - fi - fi - - echo "${LINES["$I"]}" - echo "$I" - done - - close - +mkdir -p "$TMPDIR" +if [ "$(echo "$1" | cut -c1-1)" = "-" ]; then + foot -e mangaterm "$2" 2>/dev/null > /dev/null fi + +handleFile "$1"