X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=bin%2Fkhatus_show;h=da35e6ea325ff8d07f65dee6f498842346b4c838;hb=a256fc3d8137adacc5870cb1fcc8de55cfaf3479;hp=a5fbae80f983a7ed6af7b508fdc51ef6046482e1;hpb=4c935074361a3acd2f868b8b605a741078397ea1;p=khatus.git diff --git a/bin/khatus_show b/bin/khatus_show index a5fbae8..da35e6e 100755 --- a/bin/khatus_show +++ b/bin/khatus_show @@ -7,6 +7,8 @@ STATUS_DIR=$HOME/var/run/status STATUS_FILE__WIFI=$STATUS_DIR/wifi STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF=$STATUS_DIR/notified_energy_bellow_half +SYMBOL_WIFI='📶' + #load=$(cat /proc/loadavg | awk '{printf "%4.2f %4.2f %4.2f", $1, $2, $3}') fan=$(awk '/^speed:/ {printf "%4d", $2}' /proc/acpi/ibm/fan) @@ -22,10 +24,10 @@ memory=$( total=$2; used=$3; cache=$6; - file = "/home/siraaj/var/run/status/memory_used_percentage"; + prev_file = "/home/siraaj/var/run/status/memory_used_percentage"; curr = round(used / total * 100); - getline prev < file; - print curr > file; + getline prev < prev_file; + print curr > prev_file; if (curr > prev) { direction = ">"; } else if (curr < prev) { @@ -44,21 +46,58 @@ disk=$( function round(n) {return int(n + 0.5)} $1 == "/dev/mapper/kubuntu--vg-root" { - curr = $5; - sub("%$", "", curr); - file = "/home/siraaj/var/run/status/disk_space_used_percentage"; - getline prev < file; - print curr > 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 * 1024 + } + + NR > 2 { + device = $1; sub(":$", "", device); + curr_read = $2; + curr_write = $10; + + prev_file_prefix = "/home/siraaj/var/run/status/io_net_" device; + prev_read_file = prev_file_prefix "_read"; + prev_write_file = prev_file_prefix "_write"; + + getline prev_read < prev_read_file; + getline prev_write < prev_write_file; + + diff_read = (curr_read - prev_read ) / bytes_per_unit; + diff_write = (curr_write - prev_write) / bytes_per_unit; + + print curr_read > prev_read_file; + print curr_write > prev_write_file; + + printf("%s %0.3f▲ %0.3f▼\n", device, diff_write, diff_read); + } + ' /proc/net/dev +) + energy=$( upower -e \ | grep battery \ @@ -224,7 +263,7 @@ else rm -f "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF" fi -weather="$(cat ~/var/run/metar-KJFK-decoded-temp-fahrenheit)°F" +weather=$(awk 'NR == 1 {printf("%d°F", $1)}' ~/var/run/metar-KJFK-decoded-temp-fahrenheit) signal_last_msg_age=$( ls -lt --time-style=+%s $HOME/var/lib/signal/latest_message.json \ @@ -252,6 +291,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\ @@ -260,23 +322,24 @@ echo \ M$memory\ \ \ - D$disk\ - \ - \ C=[$cpu ${temp}°C ${fan}rpm]\ \ \ - S=$screen_brightness\ + D$disk\ \ \ - V=$volume\ + $SYMBOL_WIFI [$wifi $(echo "$io_net" | awk '/^wlp3s0/ {print $2, $3}')]\ \ \ B:$bluetooth_power\ \ \ - W:$wifi\ + S=$screen_brightness\ + \ + \ + V=$volume\ \ + $mpd_state\ \ $signal_last_msg_age\ \