Remove dead code
[khatus.git] / bin / khatus_sensor_mpd_state
CommitLineData
f37162a4
SK
1#! /bin/sh
2
3set -e
4
5echo 'status' \
6| nc 127.0.0.1 6600 \
7| awk '
8 {
9 status[$1] = $2
10 }
11
12 /^time: +[0-9]+:[0-9]+$/ {
13 split($2, time, ":")
14 seconds_current = time[1]
15 seconds_total = time[2]
16
17 hours = int(seconds_current / 60 / 60);
18 secs_beyond_hours = seconds_current - (hours * 60 * 60);
19 mins = int(secs_beyond_hours / 60);
20 secs = secs_beyond_hours - (mins * 60);
21 if (hours > 0) {
22 current_time = sprintf("%d:%.2d:%.2d", hours, mins, secs)
23 } else {
24 current_time = sprintf("%.2d:%.2d", mins, secs)
25 }
26
27 if (seconds_total > 0) {
28 time_percentage = (seconds_current / seconds_total) * 100
29 current_percentage = sprintf("%d%%", time_percentage)
30 } else {
31 current_percentage = "~"
32 }
33 }
34
35 END {
f37162a4
SK
36 printf(\
37 "%s %s %s\n",
38 status["state:"], current_time, current_percentage\
39 )
40 }
41 '
This page took 0.029772 seconds and 4 git commands to generate.