X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=bin%2Fkhatus_show;h=fc4415a58d95589b46137b6a483a3659a5384fdf;hb=a8c81faf5ef88157d62a6665136597b2294b3b60;hp=f8d5dc61d64702f4a838a718788abc6d64c1f650;hpb=3de5d938bea1b1fb5149657a57df1baba94a0ee3;p=khatus.git diff --git a/bin/khatus_show b/bin/khatus_show index f8d5dc6..fc4415a 100755 --- a/bin/khatus_show +++ b/bin/khatus_show @@ -44,25 +44,33 @@ disk=$( function round(n) {return int(n + 0.5)} $1 == "/dev/mapper/kubuntu--vg-root" { - curr = $5; - sub("%$", "", curr); - prev_file = "/home/siraaj/var/run/status/disk_space_used_percentage"; - getline prev < prev_file; - print curr > prev_file; - if (curr > prev) { + curr_blocks = $3; + curr_perc = $5; sub("%$", "", curr_perc); + prev_file_prefix = "/home/siraaj/var/run/status/disk_space_used"; + + prev_perc_file = prev_file_prefix "_percentage"; + prev_blocks_file = prev_file_prefix "_blocks"; + + getline prev_blocks < prev_blocks_file; + getline prev_perc < prev_perc_file; + + print curr_blocks > prev_blocks_file; + print curr_perc > prev_perc_file; + if (curr_perc > prev_perc) { direction = ">"; - } else if (curr < prev) { + } else if (curr_perc < prev_perc) { direction = "<"; } else { direction = "="; } - printf("%s%d%%", direction, curr); + diff_blocks = curr_blocks - prev_blocks; + printf("%s[%d%% %d]", direction, curr_perc, diff_blocks); }') io_net=$( awk ' BEGIN { - bytes_per_unit = 1024 + bytes_per_unit = 1024 * 1024 } NR > 2 { @@ -83,7 +91,7 @@ io_net=$( print curr_read > prev_read_file; print curr_write > prev_write_file; - printf("%s %0.0f▲ %0.0f▼\n", device, diff_write, diff_read); + printf("%s %0.3f▲ %0.3f▼\n", device, diff_write, diff_read); } ' /proc/net/dev ) @@ -281,6 +289,29 @@ signal_last_msg_age=$( | tr -d ' ' ) +mpd_state=$( + echo 'status' \ + | nc 127.0.0.1 6600 \ + | awk ' + { + status[$1] = $2 + } + + END { + state = status["state:"] + symbol = "-" + if (state == "play") { + symbol = "▶" + } else if (state == "pause") { + symbol = "❚❚" + } else if (state == "stop") { + symbol = "⬛" + } + printf("%s", symbol) + } + ' +) + echo \ "\ E$energy\ @@ -307,6 +338,8 @@ echo \ W:[$wifi $(echo "$io_net" | awk '/^wlp3s0/ {print $2, $3}')]\ \ \ + $mpd_state\ + \ $signal_last_msg_age\ \ $weather\