Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Help me with a script

Name: A million pies 2012-02-02 11:54

I want the function "ascii" be updated every second. I also want to be able to terminate the script when I press "q" on the keyboard.
Currently I have this:

#!/bin/bash

function ascii {
    path=$(mpc -f %file% current)
    fullpath=$(echo "/Volumes/My Passport/µziq/"$path)
    dirpath=$(dirname "$fullpath")
    folderpath=$(echo $dirpath"/folder.jpg")
    lines=$(tput lines)
    height=$(echo "$lines-1"|bc)
    width=$(echo "$height*1.87"|bc)
    if [ -f "$folderpath" ]; then
        img2txt -H $height -W $width "$folderpath"
    else
        clear
    fi
}

QQUIT="no"
read -s -t 1 QQUIT
ascii
while [ "$QQUIT" != "q" ];    do
    ascii
    sleep 1
    read -s -t 1 QQUIT
done

However, this does not work entirely as I want. First, the output spams the terminal instead of only showing one dynamic output.
Second, I have to press "return" after I press "q" to terminate.
Any suggestions?

Name: Anonymous 2012-02-02 12:10

Stop trying to spam people?

Name: Anonymous 2012-02-02 12:38

>>1
Gambit-C.

Name: Anonymous 2012-02-02 12:47

Why use shell when you have perl available?

Name: Anonymous 2012-02-02 13:59

fullpath=$(echo "/Volumes/My Passport/µziq/"$path)

stopped reading right there


also where's your code tags you faggot bitch wank=er tits

Name: Anonymous 2012-02-03 9:20

something seems off since scanning for 'q' would mean scanning the keyboard matrix which needs to be done almost by polling, which defeats the purpose of letting the program sleep for 1 second

Name: Anonymous 2012-02-03 10:26

someone suggested doing it with (n)curses. but I dont know anything about that. are there some exzmples for something similar?

Name: Anonymous 2012-02-03 10:27

someone suggested doing it with (n)curses. but I dont know anything about that. are there some exzmples for something similar?

Don't change these.
Name: Email:
Entire Thread Thread List