10 for (i=2; i<=NF; i++) printf(" %s", $i);
13 /^[ \t]*Mute:/ {mute = $2}
14 /^[ \t]*front-left:/ {left = $4}
15 /^[ \t]*front-right:/ {right = $4}
20 printf("%s %s", left, right)
34 /^time: +[0-9]+:[0-9]+$/ {
36 seconds_current = time[1]
37 seconds_total = time[2]
39 hours = int(seconds_current / 60 / 60);
40 secs_beyond_hours = seconds_current - (hours * 60 * 60);
41 mins = int(secs_beyond_hours / 60);
42 secs = secs_beyond_hours - (mins * 60);
44 current_time = sprintf("%d:%.2d:%.2d", hours, mins, secs)
46 current_time = sprintf("%.2d:%.2d", mins, secs)
49 if (seconds_total > 0) {
50 time_percentage = (seconds_current / seconds_total) * 100
51 current_percentage = sprintf("%d%%", time_percentage)
53 current_percentage = "~"
58 state = status["state:"]
60 if (state == "play") {
62 } else if (state == "pause") {
64 } else if (state == "stop") {
72 status["state:"], current_time, current_percentage\
95 title = data["Title:"]
103 last = split(file, parts, "/")
114 metar
-d "$WEATHER_STATION_ID" 2>&1 \
116 /METAR pattern not found in NOAA data/ {
122 fahrenheit = (celsius * (9 / 5)) + 32;
123 temperature = fahrenheit
130 print temperature "°F"
135 date +'%a %b %d %H:%M:%S'
143 -v opt_mpd_song_max_chars
=10 \
148 db["volume"] = msg_body
155 db["mpd_curr_song_time"] = $2
156 db["mpd_curr_song_percent"] = $3
162 db["mpd_curr_song_name"] = msg_body
168 db["weather_temperature"] = msg_body
174 db["datetime"] = msg_body
184 function split_msg_parts() {
186 sub("^" msg_head " +", "")
188 debug(msg_head, msg_body)
191 function make_bar( position, bar, sep, i, j) {
192 position[++i] = sprintf("(%s)", db["volume"])
193 position[++i] = make_status_mpd()
194 position[++i] = db["weather_temperature"]
195 position[++i] = db["datetime"]
198 for (j = 1; j <= i; j++) {
199 bar = bar sep position[j]
205 function make_status_mpd( state, status) {
206 state = db["mpd_state"]
208 if (state == "play") {
209 status = make_status_mpd_state_known("▶")
210 } else if (state == "pause") {
211 status = make_status_mpd_state_known("❚❚")
212 } else if (state == "stop") {
213 status = make_status_mpd_state_known("⬛")
215 status = make_status_mpd_state_unknown("--")
218 return sprintf("[%s]", status)
221 function make_status_mpd_state_known(symbol) {
225 db["mpd_curr_song_time"],
226 db["mpd_curr_song_percent"],
227 substr(db["mpd_curr_song_name"], 1, opt_mpd_song_max_chars)\
231 function make_status_mpd_state_unknown(symbol) {
232 return sprintf("%s", symbol)
235 function debug(location, msg) {
237 print_error(location, msg)
241 function print_error(location, msg) {
242 print(location " ==> " msg) > "/dev/stderr"
257 echo "${msg_head} $($cmd)" > "$pipe"
265 pipe
="$dir_data/pipe"
267 WEATHER_STATION_ID
='KJFK'
272 spawn produce_datetime
"$pipe" 'in:DATE_TIME' 1
273 spawn produce_weather
"$pipe" 'in:WEATHER' $
(( 30 * 60 ))
274 spawn produce_mpd_state
"$pipe" 'in:MPD_STATE' 1
275 spawn produce_mpd_song
"$pipe" 'in:MPD_SONG' 1
276 spawn produce_volume
"$pipe" 'in:VOLUME' 1
277 spawn produce_bar_req
"$pipe" 'out:BAR' 1
This page took 0.118305 seconds and 5 git commands to generate.