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}')
+load=$(awk '{printf("%4.2f", $1)}' /proc/loadavg)
fan=$(awk '/^speed:/ {printf "%4d", $2}' /proc/acpi/ibm/fan)
temp=$(awk 'NR == 1 {print $1 / 1000}' /sys/class/thermal/thermal_zone0/temp)
+disk_io=$(
+ awk '
+ {
+ bytes_per_sector = 512
+ bytes_per_unit = 1024 * 1024
+
+ curr_sectors_read = $3
+ curr_sectors_write = $7
+
+ prev_file_prefix = "/home/siraaj/var/run/status/disk_io"
+ prev_sectors_read_file = prev_file_prefix "_sectors_read"
+ prev_sectors_write_file = prev_file_prefix "_sectors_write"
+
+ getline prev_sectors_read < prev_sectors_read_file
+ getline prev_sectors_write < prev_sectors_write_file
+
+ diff_read_sectors = (curr_sectors_read - prev_sectors_read)
+ diff_write_sectors = (curr_sectors_write - prev_sectors_write)
+
+ diff_read_bytes = diff_read_sectors * bytes_per_sector
+ diff_write_bytes = diff_write_sectors * bytes_per_sector
+
+ diff_read = diff_read_bytes / bytes_per_unit
+ diff_write = diff_write_bytes / bytes_per_unit
+
+ print curr_sectors_read > prev_sectors_read_file
+ print curr_sectors_write > prev_sectors_write_file
+
+ printf("%0.3fâ–² %0.3fâ–¼\n", diff_write, diff_read);
+
+ }
+ ' /sys/block/dm-1/stat
+)
+
disk=$(
df \
- | awk '
+ | awk -v disk_io="$disk_io" '
function round(n) {return int(n + 0.5)}
$1 == "/dev/mapper/kubuntu--vg-root" {
- 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;
+ prev_perc_file = "/home/siraaj/var/run/status/disk_space_used";
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 {
direction = "=";
}
- diff_blocks = curr_blocks - prev_blocks;
- printf("%s[%d%% %d]", direction, curr_perc, diff_blocks);
+ printf("%s[%d%% %s]", direction, curr_perc, disk_io);
}')
-io_net=$(
- awk '
+network=$(
+ awk -v wifi_conn=$(cat $STATUS_FILE__WIFI) '
BEGIN {
bytes_per_unit = 1024 * 1024
}
- NR > 2 {
+ FILENAME == "/proc/net/dev" && NR > 2 {
device = $1; sub(":$", "", device);
curr_read = $2;
curr_write = $10;
print curr_read > prev_read_file;
print curr_write > prev_write_file;
- printf("%s %0.3fâ–² %0.3fâ–¼\n", device, diff_write, diff_read);
+ io_rates[device] = sprintf("%0.3fâ–² %0.3fâ–¼", diff_write, diff_read);
+
+ next;
+ }
+
+ /^[a-zA-Z0-9]/ {
+ interface = $1
+ interfaces[interface_count++] = interface
}
- ' /proc/net/dev
+
+ /^ +inet addr:/ {
+ split($2, addr, ":")
+ ipaddr = addr[2]
+ ipaddrs[interface] = ipaddr
+ }
+
+ END {
+ canvas = ""
+ i_last = length(ipaddrs)
+ for (interface in ipaddrs) {
+ #ipaddr = ipaddrs[interface]
+
+ if (++i_curr == i_last) {
+ sep = ""
+ } else {
+ sep = " |"
+ }
+
+ if (interface == "wlp3s0") {
+ curr = wifi_conn " " io_rates[interface]
+ } else if (interface == "lo") {
+ curr = interface " " io_rates[interface]
+ } else {
+ curr = "e" ++eth_count " " io_rates[interface]
+ }
+
+ canvas = canvas " " curr sep
+ }
+ canvas = "[" canvas "]"
+ printf("%s", canvas)
+ }
+ ' \
+ /proc/net/dev \
+ <(ifconfig)
)
energy=$(
volume="[$volume_pactl]"
-wifi=$(cat $STATUS_FILE__WIFI)
-
screen_brightness=$(
max=$(cat /sys/class/backlight/acpi_video0/max_brightness)
cur=$(cat /sys/class/backlight/acpi_video0/brightness)
'
)
+mpd_current=$(
+ echo 'currentsong' \
+ | nc 127.0.0.1 6600 \
+ | awk -v max_chars=10 '
+ /^OK/ {
+ next
+ }
+
+ {
+ key = $1
+ val = $2
+ for (i=3; i<=NF; i++) {val = val " " $i}
+ data[key] = val
+ }
+
+ END {
+ if (data["Name:"]) {
+ out = data["Name:"]
+ } else {
+ file = data["file:"]
+ last = split(file, parts, "/")
+ out = parts[last]
+ }
+ printf("%s", substr(out, 1, max_chars))
+ }
+ '
+)
+
+graphics_card=$(
+ nvidia-smi \
+ --format=csv,noheader,nounits \
+ --query-gpu=memory.total,memory.used,temperature.gpu \
+ | awk -F ',' '
+ {
+ mem_total = $1;
+ mem_used = $2;
+ temp = $3;
+ mem_used_percent = (100 * mem_used) / mem_total;
+ printf("[%d%% %dC]", mem_used_percent, temp);
+ }
+ '
+)
+
echo \
"\
E$energy\
\
\
+ G=$graphics_card\
+ \
+ \
M$memory\
\
\
C=[$cpu ${temp}°C ${fan}rpm]\
\
\
+ L=$load\
+ \
+ \
D$disk\
\
\
- $SYMBOL_WIFI [$wifi $(echo "$io_net" | awk '/^wlp3s0/ {print $2, $3}')]\
+ N:$network\
\
\
B:$bluetooth_power\
\
V=$volume\
\
- $mpd_state\
+ [$mpd_state $mpd_current]\
\
$signal_last_msg_age\
\