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 = ENVIRON["HOME"] "/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 = ENVIRON["HOME"] "/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 = ENVIRON["HOME"] "/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);
97 |
awk -v wifi_conn
="$(cat $STATUS_FILE__WIFI)" '
99 bytes_per_unit = 1024 * 1024
107 interfaces[sequence] = interface
111 sub("/[0-9]+", "", $2)
113 addrs[interface] = addr
116 /^ +RX: / {transfer_direction = "r"}
117 /^ +TX: / {transfer_direction = "w"}
119 /^ +[0-9]+ +[0-9]+ +[0-9]+ +[0-9]+ +[0-9]+ +[0-9]+ *$/ {
120 io[interface, transfer_direction] = $1;
125 excluded["enp0s25"]++
127 for (i=1; i<=sequence; i++) {
128 interface = interfaces[i]
129 label = substr(interface, 1, 1)
130 if (addrs[interface]) {
131 curr_read = io[interface, "r"]
132 curr_write = io[interface, "w"]
134 prefix = ENVIRON["HOME"] "/var/run/status/io_net_" interface
135 prev_read_file = prefix "_read"
136 prev_write_file = prefix "_write"
138 getline prev_read < prev_read_file
139 getline prev_write < prev_write_file
141 diff_read = (curr_read - prev_read ) / bytes_per_unit
142 diff_written = (curr_write - prev_write) / bytes_per_unit
144 print curr_read > prev_read_file
145 print curr_write > prev_write_file
147 io_stat = sprintf("%0.3f▲ %0.3f▼", diff_written, diff_read)
148 if (interface == "wlp3s0") {
149 label = label ":" wifi_conn
154 if (!(interface in excluded)) {
155 if (++count_printed > 1) {
160 printf("%s%s:%s", sep, label, io_stat)
171 /^ +percentage: +/ {percentage=$2}
172 /^ +state: +/ {state=$2}
174 if (state == "discharging") {
175 direction_of_change = "<"
176 } else if (state == "charging") {
177 direction_of_change = ">"
179 direction_of_change = "="
181 printf("%s%s", direction_of_change, percentage)
184 datetime
=$
(date +'%a %b %d %H:%M:%S')
186 # date +'%a %u %b %d %H:%M:%S' \
196 # for (i=1; i<=7; i++) {
197 # if (i == 6 || i == 4) {
203 # if (i == wday_seq) {
204 # #symbol = substr(wday_name, 1, 1)
206 # } else if (i < wday_seq){
211 # week = week sep symbol
214 # print "["week"]", month, mday, time;
220 # amixer get Master \
225 # sub("^\\[", "", level);
226 # sub("\\]$", "", level);
232 # amixer get Master \
234 # | awk '{print $4}' \
245 for (i=2; i<=NF; i++) printf(" %s", $i);
248 /^[ \t]*Mute:/ {mute = $2}
249 /^[ \t]*front-left:/ {left = $4}
250 /^[ \t]*front-right:/ {right = $4}
255 printf("%s %s", left, right)
261 volume
="($volume_pactl)"
264 max
=$
(cat /sys
/class
/backlight
/acpi_video
0/max_brightness
)
265 cur
=$
(cat /sys
/class
/backlight
/acpi_video
0/brightness
)
266 awk -v max
=$max -v cur
=$cur 'BEGIN {printf("%d%%", cur/max*100)}'
270 # grep '^status:' /proc/acpi/ibm/bluetooth \
272 # $2 == "disabled" {printf "off"}
273 # $2 == "enabled" {printf "on"}
278 echo -e 'show \n quit' \
283 controllers[++ctrl_count] = controller;
285 /^\t[A-Z][A-Za-z]+:/ {
289 for (i=3; i<=NF; i++) {
291 data[controller, key] = val;
294 # Using the 1st seen controller. Should we select specific instead?
295 power_status = data[controllers[1], "Powered"];
296 if (ctrl_count > 0) {
297 if (power_status == "no") {
299 } else if (power_status == "yes") {
302 printf("Unexpected bluetooth power status: %s\n", power_status)\
304 power_status = "ERROR"
307 power_status = "off" # TODO: Perhaps use differentiated marker?
309 printf("%s", power_status);
314 # xinput list-props 12 \
316 # /^\tDevice Enabled \([0-9]+\):/ {
318 # printf("%s", status);
323 #color_on_bg_gray='\033[m\033[40m'
325 energy_direction
=$
(echo "$energy" | cut
-b 1)
326 energy_percentage
=$
(echo "$energy" |
tr -d '<>=%')
327 if [[ "$energy_direction" = '<' ]]
329 if [[ $energy_percentage -le 5 ]]
331 DISPLAY
=:0.0 notify-send \
333 "Energy CRITICALLY low: $energy" \
334 'CHARGE NOW!!! GO GO GO!!!'
335 elif [[ $energy_percentage -le 10 ]]
337 DISPLAY
=:0.0 notify-send \
339 "Energy VERY low: $energy" \
341 elif [[ $energy_percentage -le 15 ]]
343 DISPLAY
=:0.0 notify-send \
345 "Energy low: $energy" \
347 elif [[ $energy_percentage -le 50 ]]
349 if [[ ! -a "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF" ]]
351 DISPLAY
=:0.0 notify-send \
353 "Energy bellow half: $energy" \
354 'Where is the charger?'
355 touch "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF"
359 rm -f "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF"
362 weather
=$
(awk 'NR == 1 {printf("%s°F", $1)}' ~
/var
/run
/metar-KJFK-decoded-temp-fahrenheit
)
364 #signal_last_msg_age=$(
365 # ls -lt --time-style=+%s $HOME/var/lib/signal/latest_message.json \
366 # | awk -v now_seconds=$(date +%s) \
368 # mtime_seconds = $6;
369 # seconds = now_seconds - mtime_seconds;
370 # minutes = seconds / 60;
371 # hours = minutes / 60;
374 # months = days / 30;
377 # printf(fmt " s\n", seconds);
378 # printf(fmt " m\n", minutes);
379 # printf(fmt " h\n", hours);
380 # printf(fmt " d\n", days);
381 # printf(fmt " w\n", weeks);
382 # printf(fmt " mo\n", months);
392 | nc
127.0.0.1 6600 \
393 |
awk -v max_chars
=10 '
401 for (i=3; i<=NF; i++) {val = val " " $i}
407 title = data["Title:"]
415 last = split(file, parts, "/")
421 printf("%s", substr(out, 1, max_chars))
428 | nc
127.0.0.1 6600 \
430 -v current_song
="$mpd_currentsong" \
436 /^time: +[0-9]+:[0-9]+$/ {
438 seconds_current = time[1]
439 seconds_total = time[2]
441 hours = int(seconds_current / 60 / 60);
442 secs_beyond_hours = seconds_current - (hours * 60 * 60);
443 mins = int(secs_beyond_hours / 60);
444 secs = secs_beyond_hours - (mins * 60);
446 current_time = sprintf("%d:%.2d:%.2d", hours, mins, secs)
448 current_time = sprintf("%.2d:%.2d", mins, secs)
451 if (seconds_total > 0) {
452 time_percentage = (seconds_current / seconds_total) * 100
453 current_percentage = sprintf("%d%%", time_percentage)
455 current_percentage = "~"
459 function print_known_state(symbol) {
462 symbol, current_time, current_percentage, current_song \
466 function print_unknown_state(symbol) {
471 state = status["state:"]
473 if (state == "play") {
474 print_known_state("▶")
475 } else if (state == "pause") {
476 print_known_state("❚❚")
477 } else if (state == "stop") {
478 print_known_state("⬛")
480 print_unknown_state("--")
488 #--format=csv,noheader,nounits \
489 #--query-gpu=memory.total,memory.used,temperature.gpu \
495 #mem_used_percent = (100 * mem_used) / mem_total;
496 #printf("[%d%% %dC]", mem_used_percent, temp);
507 C=[$load ${temp}°C ${fan}rpm]\