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);
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;
124 for (i=1; i<=sequence; i++) {
125 interface = interfaces[i]
126 if (addrs[interface]) {
127 curr_read = io[interface, "r"]
128 curr_write = io[interface, "w"]
130 prefix = "/home/siraaj/var/run/status/io_net_" interface
131 prev_read_file = prefix "_read"
132 prev_write_file = prefix "_write"
134 getline prev_read < prev_read_file
135 getline prev_write < prev_write_file
137 diff_r = (curr_read - prev_read ) / bytes_per_unit
138 diff_w = (curr_write - prev_write) / bytes_per_unit
140 print curr_read > prev_read_file
141 print curr_write > prev_write_file
143 if (interface == "wlp3s0") {
155 printf("%s %0.3f▲ %0.3f▼%s", label, diff_w, diff_r, sep)
166 /^ +percentage: +/ {percentage=$2}
167 /^ +state: +/ {state=$2}
169 if (state == "discharging") {
170 direction_of_change = "<"
171 } else if (state == "charging") {
172 direction_of_change = ">"
174 direction_of_change = "="
176 printf("%s%s", direction_of_change, percentage)
179 datetime
=$
(date +'%a, %b %d, %H:%M:%S')
182 # amixer get Master \
187 # sub("^\\[", "", level);
188 # sub("\\]$", "", level);
194 # amixer get Master \
196 # | awk '{print $4}' \
207 for (i=2; i<=NF; i++) printf(" %s", $i);
210 /^[ \t]*Mute:/ {mute = $2}
211 /^[ \t]*front-left:/ {left = $4}
212 /^[ \t]*front-right:/ {right = $4}
217 printf("%s %s", left, right)
223 volume
="[$volume_pactl]"
226 max
=$
(cat /sys
/class
/backlight
/acpi_video
0/max_brightness
)
227 cur
=$
(cat /sys
/class
/backlight
/acpi_video
0/brightness
)
228 awk -v max
=$max -v cur
=$cur 'BEGIN {printf("%d%%", cur/max*100)}'
232 # grep '^status:' /proc/acpi/ibm/bluetooth \
234 # $2 == "disabled" {printf "off"}
235 # $2 == "enabled" {printf "on"}
240 echo -e 'show \n quit' \
245 controllers[++ctrl_count] = controller;
247 /^\t[A-Z][A-Za-z]+:/ {
251 for (i=3; i<=NF; i++) {
253 data[controller, key] = val;
256 # Using the 1st seen controller. Should we select specific instead?
257 power_status = data[controllers[1], "Powered"];
258 if (ctrl_count > 0) {
259 if (power_status == "no") {
261 } else if (power_status == "yes") {
264 printf("Unexpected bluetooth power status: %s\n", power_status)\
266 power_status = "ERROR"
269 power_status = "off" # TODO: Perhaps use differentiated marker?
271 printf("%s", power_status);
276 # xinput list-props 12 \
278 # /^\tDevice Enabled \([0-9]+\):/ {
280 # printf("%s", status);
285 #color_on_bg_gray='\033[m\033[40m'
287 energy_direction
=$
(echo "$energy" | cut
-b 1)
288 energy_percentage
=$
(echo "$energy" |
tr -d '<>=%')
289 if [[ "$energy_direction" = '<' ]]
291 if [[ $energy_percentage -le 5 ]]
293 DISPLAY
=:0.0 notify-send \
295 "Energy CRITICALLY low: $energy" \
296 'CHARGE NOW!!! GO GO GO!!!'
297 elif [[ $energy_percentage -le 10 ]]
299 DISPLAY
=:0.0 notify-send \
301 "Energy VERY low: $energy" \
303 elif [[ $energy_percentage -le 15 ]]
305 DISPLAY
=:0.0 notify-send \
307 "Energy low: $energy" \
309 elif [[ $energy_percentage -le 50 ]]
311 if [[ ! -a "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF" ]]
313 DISPLAY
=:0.0 notify-send \
315 "Energy bellow half: $energy" \
316 'Where is the charger?'
317 touch "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF"
321 rm -f "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF"
324 weather
=$
(awk 'NR == 1 {printf("%d°F", $1)}' ~
/var
/run
/metar-KJFK-decoded-temp-fahrenheit
)
326 signal_last_msg_age
=$
(
327 ls -lt --time-style=+%s
$HOME/var
/lib
/signal
/latest_message.json \
328 |
awk -v now_seconds
=$
(date +%s
) \
331 seconds = now_seconds - mtime_seconds;
332 minutes = seconds / 60;
333 hours = minutes / 60;
339 printf(fmt " s\n", seconds);
340 printf(fmt " m\n", minutes);
341 printf(fmt " h\n", hours);
342 printf(fmt " d\n", days);
343 printf(fmt " w\n", weeks);
344 printf(fmt " mo\n", months);
354 | nc
127.0.0.1 6600 \
361 state = status["state:"]
363 if (state == "play") {
365 } else if (state == "pause") {
367 } else if (state == "stop") {
377 | nc
127.0.0.1 6600 \
378 |
awk -v max_chars
=10 '
386 for (i=3; i<=NF; i++) {val = val " " $i}
395 last = split(file, parts, "/")
398 printf("%s", substr(out, 1, max_chars))
405 --format=csv
,noheader
,nounits \
406 --query-gpu=memory.total
,memory.used
,temperature.gpu \
412 mem_used_percent = (100 * mem_used) / mem_total;
413 printf("[%d%% %dC]", mem_used_percent, temp);
429 C=[$cpu ${temp}°C ${fan}rpm]\
444 S=$screen_brightness\
449 [$mpd_state $mpd_current]\
451 $signal_last_msg_age\