e5174c505225f06ec520a516033c51494ad075a8
11 /^time: +[0-9]+:[0-9]+$/ {
13 seconds_current = time[1]
14 seconds_total = time[2]
16 hours = int(seconds_current / 60 / 60);
17 secs_beyond_hours = seconds_current - (hours * 60 * 60);
18 mins = int(secs_beyond_hours / 60);
19 secs = secs_beyond_hours - (mins * 60);
21 current_time = sprintf("%d:%.2d:%.2d", hours, mins, secs)
23 current_time = sprintf("%.2d:%.2d", mins, secs)
26 if (seconds_total > 0) {
27 time_percentage = (seconds_current / seconds_total) * 100
28 current_percentage = sprintf("%d%%", time_percentage)
30 current_percentage = "~"
35 state = status["state:"]
37 if (state == "play") {
39 } else if (state == "pause") {
41 } else if (state == "stop") {
49 status["state:"], current_time, current_percentage\
72 title = data["Title:"]
80 last = split(file, parts, "/")
91 metar
-d "$WEATHER_STATION_ID" 2>&1 \
93 /METAR pattern not found in NOAA data/ {
99 fahrenheit = (celsius * (9 / 5)) + 32;
100 temperature = fahrenheit
107 print temperature "°F"
112 date +'%a %b %d %H:%M:%S'
120 -v opt_mpd_song_max_chars
=10 \
126 db["mpd_curr_song_time"] = $2
127 db["mpd_curr_song_percent"] = $3
133 db["mpd_curr_song_name"] = msg_body
139 db["weather_temperature"] = msg_body
145 db["datetime"] = msg_body
155 function split_msg_parts() {
157 sub("^" msg_head " +", "")
159 debug(msg_head, msg_body)
162 function make_bar( position, bar, sep, i, j) {
163 position[++i] = make_status_mpd()
164 position[++i] = db["weather_temperature"]
165 position[++i] = db["datetime"]
168 for (j = 1; j <= i; j++) {
169 bar = bar sep position[j]
175 function make_status_mpd( state, status) {
176 state = db["mpd_state"]
178 if (state == "play") {
179 status = make_status_mpd_state_known("▶")
180 } else if (state == "pause") {
181 status = make_status_mpd_state_known("❚❚")
182 } else if (state == "stop") {
183 status = make_status_mpd_state_known("⬛")
185 status = make_status_mpd_state_unknown("--")
188 return sprintf("[%s]", status)
191 function make_status_mpd_state_known(symbol) {
195 db["mpd_curr_song_time"],
196 db["mpd_curr_song_percent"],
197 substr(db["mpd_curr_song_name"], 1, opt_mpd_song_max_chars)\
201 function make_status_mpd_state_unknown(symbol) {
202 return sprintf("%s", symbol)
205 function debug(location, msg) {
207 print_error(location, msg)
211 function print_error(location, msg) {
212 print(location " ==> " msg) > "/dev/stderr"
227 echo "${msg_head} $($cmd)" > "$pipe"
235 pipe
="$dir_data/pipe"
237 WEATHER_STATION_ID
='KJFK'
242 spawn produce_datetime
"$pipe" 'in:DATE_TIME' 1
243 spawn produce_weather
"$pipe" 'in:WEATHER' $
(( 30 * 60 ))
244 spawn produce_mpd_state
"$pipe" 'in:MPD_STATE' 1
245 spawn produce_mpd_song
"$pipe" 'in:MPD_SONG' 1
246 spawn produce_bar_req
"$pipe" 'out:BAR' 1
This page took 0.105359 seconds and 3 git commands to generate.