[lastbash-cvs] SF.net SVN: lastbash: [237] lastbash/lastbash
Status: Beta
Brought to you by:
cstroie
From: <cs...@us...> - 2007-08-30 10:33:21
|
Revision: 237 http://lastbash.svn.sourceforge.net/lastbash/?rev=237&view=rev Author: cstroie Date: 2007-08-30 03:33:14 -0700 (Thu, 30 Aug 2007) Log Message: ----------- Added the volume up and down commands. Parse the http get status. Modified Paths: -------------- lastbash/lastbash Modified: lastbash/lastbash =================================================================== --- lastbash/lastbash 2007-08-30 09:56:24 UTC (rev 236) +++ lastbash/lastbash 2007-08-30 10:33:14 UTC (rev 237) @@ -533,7 +533,7 @@ # Do the HTTP request if "${HTTP_CLIENT_FUNCTION}" "${TMP_FILE}" "$1" "$2" "${GET_PATH}" then - # Append one (missing) EOL (and make sure the file exits) + # Append one (missing) EOL (and make sure the file exists) echo >> "${TMP_FILE}" # Clear the HTTP_* arrays @@ -563,16 +563,29 @@ (( N++ )) done < "${TMP_FILE}" - # Check the status - if [[ -n `expr "${HTTP_HEADERS[0]}" : '.*\(200\)'` ]] + # Get the protocol, status and error message + local PROTO STATUS MSG + PROTO="${HTTP_HEADERS[0]%% *}" + MSG="${HTTP_HEADERS[0]#* }" + STATUS="${MSG%% *}" + MSG="${MSG#* }" + if [ "${STATUS}" == "200" ] then RET="0" + elif [ "${STATUS}" == "403" ] + then + debug "${FUNCNAME}: HTTP GET status is ${STATUS} ${MSG}" + RET="4" + elif [ "${STATUS}" == "503" ] + then + debug "${FUNCNAME}: HTTP GET status is ${STATUS} ${MSG}" + RET="5" else - debug "${FUNCNAME}: HTTP GET status is not OK" + debug "${FUNCNAME}: HTTP GET status is not OK: ${STATUS} ${MSG}" RET="1" fi else - debug "${FUNCNAME}: HTTP GET error" + debug "${FUNCNAME}: Unidentified HTTP GET error" RET="2" fi @@ -2211,7 +2224,6 @@ return "${RET}" } - # Function: Mute the player {{{1 #----------------------------------------------------------------------------- function player_mute() @@ -2223,7 +2235,7 @@ # Set the status line tui_sbar $"Muting/Unmuting..." - # Stop playing + # Mute if [ "${PLAYER}" == "mplayer" ] then player_command "mute" @@ -2246,6 +2258,74 @@ return "${RET}" } +# Function: Player volume up {{{1 +#----------------------------------------------------------------------------- +function player_volup() +{ + player_running || return + + local RET + + # Set the status line + tui_sbar $"Volume up" + + # Volume up + if [ "${PLAYER}" == "mplayer" ] + then + player_command "volume +10" + RET=$? + elif [ "${PLAYER}" == "mpg123" ] + then + RET="1" + tui_sbar "Command not supported" + else + RET="1" + debug "${FUNCNAME}: No supported player running" + tui_sbar $"No supported player is running" + fi + + # Restore the status bar + sleep 1 + tui_sbar + + # Return the status + return "${RET}" +} + +# Function: Player volume down {{{1 +#----------------------------------------------------------------------------- +function player_voldown() +{ + player_running || return + + local RET + + # Set the status line + tui_sbar $"Volume down" + + # Volume down + if [ "${PLAYER}" == "mplayer" ] + then + player_command "volume -10" + RET=$? + elif [ "${PLAYER}" == "mpg123" ] + then + RET="1" + tui_sbar "Command not supported" + else + RET="1" + debug "${FUNCNAME}: No supported player running" + tui_sbar $"No supported player is running" + fi + + # Restore the status bar + sleep 1 + tui_sbar + + # Return the status + return "${RET}" +} + # Function: Stop playing {{{1 #----------------------------------------------------------------------------- function player_stop() @@ -2511,6 +2591,8 @@ "v") player_stop ;; "${CTRL_V}") player_quit ;; "m") player_mute ;; + "+") player_volup ;; + "-") player_voldown ;; # Quit "q") DONE="y" ;; # Any key or timeout This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |