6 STATUS_DIR
=$HOME/var
/run
/status
7 STATUS_FILE__WIFI
=$STATUS_DIR/wifi
8 STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF
=$STATUS_DIR/notified_energy_bellow_half
10 load
=$
(awk '{printf("%4.2f", $1)}' /proc
/loadavg
)
12 fan
=$
(awk '/^speed:/ {printf "%4d", $2}' /proc
/acpi
/ibm
/fan
)
14 cpu
=$
($BIN/khatus_cpu_usage_from_proc_since_last_check
)
19 function round(n) {return int(n + 0.5)}
25 prev_file = "/home/siraaj/var/run/status/memory_used_percentage";
26 curr = round(used / total * 100);
27 getline prev < prev_file;
28 print curr > prev_file;
31 } else if (curr < prev) {
36 printf("%s%d%%", direction, curr);
39 temp
=$
(awk 'NR == 1 {print $1 / 1000}' /sys
/class
/thermal
/thermal_zone
0/temp
)
44 bytes_per_sector = 512
45 bytes_per_unit = 1024 * 1024
47 curr_sectors_read = $3
48 curr_sectors_write = $7
50 prev_file_prefix = "/home/siraaj/var/run/status/disk_io"
51 prev_sectors_read_file = prev_file_prefix "_sectors_read"
52 prev_sectors_write_file = prev_file_prefix "_sectors_write"
54 getline prev_sectors_read < prev_sectors_read_file
55 getline prev_sectors_write < prev_sectors_write_file
57 diff_read_sectors = (curr_sectors_read - prev_sectors_read)
58 diff_write_sectors = (curr_sectors_write - prev_sectors_write)
60 diff_read_bytes = diff_read_sectors * bytes_per_sector
61 diff_write_bytes = diff_write_sectors * bytes_per_sector
63 diff_read = diff_read_bytes / bytes_per_unit
64 diff_write = diff_write_bytes / bytes_per_unit
66 print curr_sectors_read > prev_sectors_read_file
67 print curr_sectors_write > prev_sectors_write_file
69 printf("%0.3f▲ %0.3f▼\n", diff_write, diff_read);
72 ' /sys
/block
/dm-
1/stat
77 |
awk -v disk_io
="$disk_io" '
78 function round(n) {return int(n + 0.5)}
80 $1 == "/dev/mapper/kubuntu--vg-root" {
81 curr_perc = $5; sub("%$", "", curr_perc);
82 prev_perc_file = "/home/siraaj/var/run/status/disk_space_used";
83 getline prev_perc < prev_perc_file;
84 print curr_perc > prev_perc_file;
85 if (curr_perc > prev_perc) {
87 } else if (curr_perc < prev_perc) {
92 printf("%s[%d%% %s]", direction, curr_perc, disk_io);
96 awk -v wifi_conn
=$
(cat $STATUS_FILE__WIFI) '
98 bytes_per_unit = 1024 * 1024
101 FILENAME == "/proc/net/dev" && NR > 2 {
102 device = $1; sub(":$", "", device);
106 prev_file_prefix = "/home/siraaj/var/run/status/io_net_" device;
107 prev_read_file = prev_file_prefix "_read";
108 prev_write_file = prev_file_prefix "_write";
110 getline prev_read < prev_read_file;
111 getline prev_write < prev_write_file;
113 diff_read = (curr_read - prev_read ) / bytes_per_unit;
114 diff_write = (curr_write - prev_write) / bytes_per_unit;
116 print curr_read > prev_read_file;
117 print curr_write > prev_write_file;
119 io_rates[device] = sprintf("%0.3f▲ %0.3f▼", diff_write, diff_read);
126 interfaces[interface_count++] = interface
132 ipaddrs[interface] = ipaddr
137 i_last = length(ipaddrs)
138 for (interface in ipaddrs) {
139 #ipaddr = ipaddrs[interface]
141 if (++i_curr == i_last) {
147 if (interface == "wlp3s0") {
148 curr = wifi_conn " " io_rates[interface]
149 } else if (interface == "lo") {
150 curr = interface " " io_rates[interface]
152 curr = "e" ++eth_count " " io_rates[interface]
155 canvas = canvas " " curr sep
157 canvas = "[" canvas "]"
170 /^ +percentage: +/ {percentage=$2}
171 /^ +state: +/ {state=$2}
173 if (state == "discharging") {
174 direction_of_change = "<"
175 } else if (state == "charging") {
176 direction_of_change = ">"
178 direction_of_change = "="
180 printf("%s%s", direction_of_change, percentage)
183 datetime
=$
(date +'%a, %b %d, %H:%M:%S')
186 # amixer get Master \
191 # sub("^\\[", "", level);
192 # sub("\\]$", "", level);
198 # amixer get Master \
200 # | awk '{print $4}' \
211 for (i=2; i<=NF; i++) printf(" %s", $i);
214 /^[ \t]*Mute:/ {mute = $2}
215 /^[ \t]*front-left:/ {left = $4}
216 /^[ \t]*front-right:/ {right = $4}
221 printf("%s %s", left, right)
227 volume
="[$volume_pactl]"
230 max
=$
(cat /sys
/class
/backlight
/acpi_video
0/max_brightness
)
231 cur
=$
(cat /sys
/class
/backlight
/acpi_video
0/brightness
)
232 awk -v max
=$max -v cur
=$cur 'BEGIN {printf("%d%%", cur/max*100)}'
236 # grep '^status:' /proc/acpi/ibm/bluetooth \
238 # $2 == "disabled" {printf "off"}
239 # $2 == "enabled" {printf "on"}
244 echo -e 'show \n quit' \
249 controllers[++ctrl_count] = controller;
251 /^\t[A-Z][A-Za-z]+:/ {
255 for (i=3; i<=NF; i++) {
257 data[controller, key] = val;
260 # Using the 1st seen controller. Should we select specific instead?
261 power_status = data[controllers[1], "Powered"];
262 if (ctrl_count > 0) {
263 if (power_status == "no") {
265 } else if (power_status == "yes") {
268 printf("Unexpected bluetooth power status: %s\n", power_status)\
270 power_status = "ERROR"
273 power_status = "off" # TODO: Perhaps use differentiated marker?
275 printf("%s", power_status);
280 # xinput list-props 12 \
282 # /^\tDevice Enabled \([0-9]+\):/ {
284 # printf("%s", status);
289 #color_on_bg_gray='\033[m\033[40m'
291 energy_direction
=$
(echo "$energy" | cut
-b 1)
292 energy_percentage
=$
(echo "$energy" |
tr -d '<>=%')
293 if [[ "$energy_direction" = '<' ]]
295 if [[ $energy_percentage -le 5 ]]
297 DISPLAY
=:0.0 notify-send \
299 "Energy CRITICALLY low: $energy" \
300 'CHARGE NOW!!! GO GO GO!!!'
301 elif [[ $energy_percentage -le 10 ]]
303 DISPLAY
=:0.0 notify-send \
305 "Energy VERY low: $energy" \
307 elif [[ $energy_percentage -le 15 ]]
309 DISPLAY
=:0.0 notify-send \
311 "Energy low: $energy" \
313 elif [[ $energy_percentage -le 50 ]]
315 if [[ ! -a "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF" ]]
317 DISPLAY
=:0.0 notify-send \
319 "Energy bellow half: $energy" \
320 'Where is the charger?'
321 touch "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF"
325 rm -f "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF"
328 weather
=$
(awk 'NR == 1 {printf("%d°F", $1)}' ~
/var
/run
/metar-KJFK-decoded-temp-fahrenheit
)
330 signal_last_msg_age
=$
(
331 ls -lt --time-style=+%s
$HOME/var
/lib
/signal
/latest_message.json \
332 |
awk -v now_seconds
=$
(date +%s
) \
335 seconds = now_seconds - mtime_seconds;
336 minutes = seconds / 60;
337 hours = minutes / 60;
343 printf(fmt " s\n", seconds);
344 printf(fmt " m\n", minutes);
345 printf(fmt " h\n", hours);
346 printf(fmt " d\n", days);
347 printf(fmt " w\n", weeks);
348 printf(fmt " mo\n", months);
358 | nc
127.0.0.1 6600 \
365 state = status["state:"]
367 if (state == "play") {
369 } else if (state == "pause") {
371 } else if (state == "stop") {
381 | nc
127.0.0.1 6600 \
382 |
awk -v max_chars
=10 '
390 for (i=3; i<=NF; i++) {val = val " " $i}
399 last = split(file, parts, "/")
402 printf("%s", substr(out, 1, max_chars))
409 --format=csv
,noheader
,nounits \
410 --query-gpu=memory.total
,memory.used
,temperature.gpu \
416 mem_used_percent = (100 * mem_used) / mem_total;
417 printf("[%d%% %dC]", mem_used_percent, temp);
433 C=[$cpu ${temp}°C ${fan}rpm]\
448 S=$screen_brightness\
453 [$mpd_state $mpd_current]\
455 $signal_last_msg_age\