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
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 devices[device] = sprintf("%0.3f▲ %0.3f▼", diff_write, diff_read);
124 #eth = devices["enp0s25"]
125 wifi_io = devices["wlp3s0"]
126 if (wifi_conn == "--") {
129 wifi = wifi_conn " " wifi_io
131 printf("[%s | %s]", lo, wifi)
141 /^ +percentage: +/ {percentage=$2}
142 /^ +state: +/ {state=$2}
144 if (state == "discharging") {
145 direction_of_change = "<"
146 } else if (state == "charging") {
147 direction_of_change = ">"
149 direction_of_change = "="
151 printf("%s%s", direction_of_change, percentage)
154 datetime
=$
(date +'%a, %b %d, %H:%M:%S')
157 # amixer get Master \
162 # sub("^\\[", "", level);
163 # sub("\\]$", "", level);
169 # amixer get Master \
171 # | awk '{print $4}' \
182 for (i=2; i<=NF; i++) printf(" %s", $i);
185 /^[ \t]*Mute:/ {mute = $2}
186 /^[ \t]*front-left:/ {left = $4}
187 /^[ \t]*front-right:/ {right = $4}
192 printf("%s %s", left, right)
198 volume
="[$volume_pactl]"
201 max
=$
(cat /sys
/class
/backlight
/acpi_video
0/max_brightness
)
202 cur
=$
(cat /sys
/class
/backlight
/acpi_video
0/brightness
)
203 awk -v max
=$max -v cur
=$cur 'BEGIN {printf("%d%%", cur/max*100)}'
207 # grep '^status:' /proc/acpi/ibm/bluetooth \
209 # $2 == "disabled" {printf "off"}
210 # $2 == "enabled" {printf "on"}
215 echo -e 'show \n quit' \
220 controllers[++ctrl_count] = controller;
222 /^\t[A-Z][A-Za-z]+:/ {
226 for (i=3; i<=NF; i++) {
228 data[controller, key] = val;
231 # Using the 1st seen controller. Should we select specific instead?
232 power_status = data[controllers[1], "Powered"];
233 if (ctrl_count > 0) {
234 if (power_status == "no") {
236 } else if (power_status == "yes") {
239 printf("Unexpected bluetooth power status: %s\n", power_status)\
241 power_status = "ERROR"
244 power_status = "off" # TODO: Perhaps use differentiated marker?
246 printf("%s", power_status);
251 # xinput list-props 12 \
253 # /^\tDevice Enabled \([0-9]+\):/ {
255 # printf("%s", status);
260 #color_on_bg_gray='\033[m\033[40m'
262 energy_direction
=$
(echo "$energy" | cut
-b 1)
263 energy_percentage
=$
(echo "$energy" |
tr -d '<>=%')
264 if [[ "$energy_direction" = '<' ]]
266 if [[ $energy_percentage -le 5 ]]
268 DISPLAY
=:0.0 notify-send \
270 "Energy CRITICALLY low: $energy" \
271 'CHARGE NOW!!! GO GO GO!!!'
272 elif [[ $energy_percentage -le 10 ]]
274 DISPLAY
=:0.0 notify-send \
276 "Energy VERY low: $energy" \
278 elif [[ $energy_percentage -le 15 ]]
280 DISPLAY
=:0.0 notify-send \
282 "Energy low: $energy" \
284 elif [[ $energy_percentage -le 50 ]]
286 if [[ ! -a "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF" ]]
288 DISPLAY
=:0.0 notify-send \
290 "Energy bellow half: $energy" \
291 'Where is the charger?'
292 touch "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF"
296 rm -f "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF"
299 weather
=$
(awk 'NR == 1 {printf("%d°F", $1)}' ~
/var
/run
/metar-KJFK-decoded-temp-fahrenheit
)
301 signal_last_msg_age
=$
(
302 ls -lt --time-style=+%s
$HOME/var
/lib
/signal
/latest_message.json \
303 |
awk -v now_seconds
=$
(date +%s
) \
306 seconds = now_seconds - mtime_seconds;
307 minutes = seconds / 60;
308 hours = minutes / 60;
314 #printf(fmt " s\n", seconds);
315 printf(fmt " m\n", minutes);
316 printf(fmt " h\n", hours);
317 printf(fmt " d\n", days);
318 printf(fmt " w\n", weeks);
319 printf(fmt " mo\n", months);
329 | nc
127.0.0.1 6600 \
336 state = status["state:"]
338 if (state == "play") {
340 } else if (state == "pause") {
342 } else if (state == "stop") {
352 | nc
127.0.0.1 6600 \
353 |
awk -v max_chars
=10 '
361 for (i=3; i<=NF; i++) {val = val " " $i}
370 last = split(file, parts, "/")
373 printf("%s", substr(out, 1, max_chars))
380 --format=csv
,noheader
,nounits \
381 --query-gpu=memory.total
,memory.used
,temperature.gpu \
387 mem_used_percent = (100 * mem_used) / mem_total;
388 printf("[%d%% %dC]", mem_used_percent, temp);
404 C=[$cpu ${temp}°C ${fan}rpm]\
419 S=$screen_brightness\
424 [$mpd_state $mpd_current]\
426 $signal_last_msg_age\