[lastbash-cvs] lastbash lastbash,1.80,1.81
Status: Beta
Brought to you by:
cstroie
|
From: Costin S. <cs...@us...> - 2006-12-05 21:00:14
|
Update of /cvsroot/lastbash/lastbash In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv13937 Modified Files: lastbash Log Message: Added a timing function to tui_sbar. Index: lastbash =================================================================== RCS file: /cvsroot/lastbash/lastbash/lastbash,v retrieving revision 1.80 retrieving revision 1.81 diff -u -d -r1.80 -r1.81 --- lastbash 5 Dec 2006 20:35:58 -0000 1.80 +++ lastbash 5 Dec 2006 21:00:09 -0000 1.81 @@ -897,14 +897,36 @@ echo -ne "${T_COLOR_WHITE}${T_BGCOLOR_BLUE}${LINE}${T_COLOR_NORMAL}" } +# Function: Display the status bar and control the timing {{{1 +#----------------------------------------------------------------------------- +function tui_sbar() +{ + # $1 - the text to print + # $2 - interval (seconds) before restoring default status bar + + if [ "$1" ] + then + # Display the status + tui_statusbar "$1" + if [ "$2" ] + then + # If timed, sleep and display the default status + sleep "$2" + tui_statusbar + fi + else + # Display default status + tui_statusbar + fi +} # Function: Display the status bar {{{1 #----------------------------------------------------------------------------- -function tui_sbar() +function tui_statusbar() { # $1 - the text to print - local LINE L1 L2 L3 L4 S + local LINE L1 L2 L3 L4 S MSG # Set the leds # - R: the player is running # - P: record to profile is on @@ -917,16 +939,19 @@ # Compute the main field size S=$(( T_COLUMNS - 27 )) - # Format the status line + # Set the message to display if [ "$1" ] then - printf -v LINE " %-${S}s %-15s [%c%c%c%c] " "${1:0:$S}" "${LASTFM_USER}" "${L1}" "${L2}" "${L3}" "${L4}" + MSG="${1}" elif [ "${META_STREAMING}" == "true" ] then - printf -v LINE " %-${S}s %-15s [%c%c%c%c] " "${META_STATION:0:$S}" "${LASTFM_USER}" "${L1}" "${L2}" "${L3}" "${L4}" + MSG="${META_STATION}" else - printf -v LINE " %-${S}s %-15s [%c%c%c%c] " "Not streaming, please launch the player" "${LASTFM_USER}" "${L1}" "${L2}" "${L3}" "${L4}" + MSG="Not streaming, please launch the player" fi + + # Format the status line + printf -v LINE " %-${S}s %-15s [%c%c%c%c] " "${MSG:0:$S}" "${LASTFM_USER}" "${L1}" "${L2}" "${L3}" "${L4}" # Move the cursor on lower-left corner and print tput cup ${T_LINES} 0 echo -ne "${T_COLOR_WHITE}${T_BGCOLOR_BLUE}${LINE}${T_COLOR_NORMAL}" @@ -1171,10 +1196,10 @@ else RET="1" tui_sbar "Metadata retrieving failed" - sleep 1 fi - # Set the new status bar + # Restore the status bar + sleep 1 tui_sbar # Return the status code @@ -1531,11 +1556,7 @@ sleep 1 # Update the status line - tui_sbar "Stream loaded and playing" - - # Restore the status bar - sleep 1 - tui_sbar + tui_sbar "Stream loaded and playing" "1" } # Function: Stop playing {{{1 @@ -1578,11 +1599,7 @@ rm -f "${PLAYER_PIPE}" # Set the status line - tui_sbar "Player closed" - - # Restore the status bar - sleep 1 - tui_sbar + tui_sbar "Player closed" "1" } # Function: Check if another instance is running {{{1 @@ -1649,11 +1666,7 @@ # FIXME Terminal left in wrong status "QUIT") quit 0 ;; # Any other command - *) - tui_sbar "Command not understood: $1" - sleep 1 - tui_sbar - ;; + *) tui_sbar "Command not understood: $1" "1" ;; esac } @@ -1729,9 +1742,7 @@ #----------------------------------------------------------------------------- function sigtstp() { - tui_sbar "Cannot suspend" - sleep 1 - tui_sbar + tui_sbar "Cannot suspend" "1" } # Function: The read key loop {{{1 |