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
12 #load=$(cat /proc/loadavg | awk '{printf "%4.2f %4.2f %4.2f", $1, $2, $3}')
14 fan
=$
(awk '/^speed:/ {printf "%4d", $2}' /proc
/acpi
/ibm
/fan
)
16 cpu
=$
($BIN/khatus_cpu_usage_from_proc_since_last_check
)
21 function round(n) {return int(n + 0.5)}
27 prev_file = "/home/siraaj/var/run/status/memory_used_percentage";
28 curr = round(used / total * 100);
29 getline prev < prev_file;
30 print curr > prev_file;
33 } else if (curr < prev) {
38 printf("%s%d%%", direction, curr);
41 temp
=$
(awk 'NR == 1 {print $1 / 1000}' /sys
/class
/thermal
/thermal_zone
0/temp
)
46 bytes_per_sector = 512
47 bytes_per_unit = 1024 * 1024
49 curr_sectors_read = $3
50 curr_sectors_write = $7
52 prev_file_prefix = "/home/siraaj/var/run/status/disk_io"
53 prev_sectors_read_file = prev_file_prefix "_sectors_read"
54 prev_sectors_write_file = prev_file_prefix "_sectors_write"
56 getline prev_sectors_read < prev_sectors_read_file
57 getline prev_sectors_write < prev_sectors_write_file
59 diff_read_sectors = (curr_sectors_read - prev_sectors_read)
60 diff_write_sectors = (curr_sectors_write - prev_sectors_write)
62 diff_read_bytes = diff_read_sectors * bytes_per_sector
63 diff_write_bytes = diff_write_sectors * bytes_per_sector
65 diff_read = diff_read_bytes / bytes_per_unit
66 diff_write = diff_write_bytes / bytes_per_unit
68 print curr_sectors_read > prev_sectors_read_file
69 print curr_sectors_write > prev_sectors_write_file
71 printf("%0.3f▲ %0.3f▼\n", diff_write, diff_read);
74 ' /sys
/block
/dm-
1/stat
79 |
awk -v disk_io
="$disk_io" '
80 function round(n) {return int(n + 0.5)}
82 $1 == "/dev/mapper/kubuntu--vg-root" {
83 curr_perc = $5; sub("%$", "", curr_perc);
84 prev_perc_file = "/home/siraaj/var/run/status/disk_space_used";
85 getline prev_perc < prev_perc_file;
86 print curr_perc > prev_perc_file;
87 if (curr_perc > prev_perc) {
89 } else if (curr_perc < prev_perc) {
94 printf("%s[%d%% %s]", direction, curr_perc, disk_io);
100 bytes_per_unit = 1024 * 1024
104 device = $1; sub(":$", "", device);
108 prev_file_prefix = "/home/siraaj/var/run/status/io_net_" device;
109 prev_read_file = prev_file_prefix "_read";
110 prev_write_file = prev_file_prefix "_write";
112 getline prev_read < prev_read_file;
113 getline prev_write < prev_write_file;
115 diff_read = (curr_read - prev_read ) / bytes_per_unit;
116 diff_write = (curr_write - prev_write) / bytes_per_unit;
118 print curr_read > prev_read_file;
119 print curr_write > prev_write_file;
121 printf("%s %0.3f▲ %0.3f▼\n", device, diff_write, diff_read);
131 /^ +percentage: +/ {percentage=$2}
132 /^ +state: +/ {state=$2}
134 if (state == "discharging") {
135 direction_of_change = "<"
136 } else if (state == "charging") {
137 direction_of_change = ">"
139 direction_of_change = "="
141 printf("%s%s", direction_of_change, percentage)
144 datetime
=$
(date +'%a, %b %d, %H:%M:%S')
147 # amixer get Master \
152 # sub("^\\[", "", level);
153 # sub("\\]$", "", level);
159 # amixer get Master \
161 # | awk '{print $4}' \
172 for (i=2; i<=NF; i++) printf(" %s", $i);
175 /^[ \t]*Mute:/ {mute = $2}
176 /^[ \t]*front-left:/ {left = $4}
177 /^[ \t]*front-right:/ {right = $4}
182 printf("%s %s", left, right)
188 volume
="[$volume_pactl]"
190 wifi
=$
(cat $STATUS_FILE__WIFI)
193 max
=$
(cat /sys
/class
/backlight
/acpi_video
0/max_brightness
)
194 cur
=$
(cat /sys
/class
/backlight
/acpi_video
0/brightness
)
195 awk -v max
=$max -v cur
=$cur 'BEGIN {printf("%d%%", cur/max*100)}'
199 # grep '^status:' /proc/acpi/ibm/bluetooth \
201 # $2 == "disabled" {printf "off"}
202 # $2 == "enabled" {printf "on"}
207 echo -e 'show \n quit' \
212 controllers[++ctrl_count] = controller;
214 /^\t[A-Z][A-Za-z]+:/ {
218 for (i=3; i<=NF; i++) {
220 data[controller, key] = val;
223 # Using the 1st seen controller. Should we select specific instead?
224 power_status = data[controllers[1], "Powered"];
225 if (ctrl_count > 0) {
226 if (power_status == "no") {
228 } else if (power_status == "yes") {
231 printf("Unexpected bluetooth power status: %s\n", power_status)\
233 power_status = "ERROR"
236 power_status = "off" # TODO: Perhaps use differentiated marker?
238 printf("%s", power_status);
243 # xinput list-props 12 \
245 # /^\tDevice Enabled \([0-9]+\):/ {
247 # printf("%s", status);
252 #color_on_bg_gray='\033[m\033[40m'
254 energy_direction
=$
(echo "$energy" | cut
-b 1)
255 energy_percentage
=$
(echo "$energy" |
tr -d '<>=%')
256 if [[ "$energy_direction" = '<' ]]
258 if [[ $energy_percentage -le 5 ]]
260 DISPLAY
=:0.0 notify-send \
262 "Energy CRITICALLY low: $energy" \
263 'CHARGE NOW!!! GO GO GO!!!'
264 elif [[ $energy_percentage -le 10 ]]
266 DISPLAY
=:0.0 notify-send \
268 "Energy VERY low: $energy" \
270 elif [[ $energy_percentage -le 15 ]]
272 DISPLAY
=:0.0 notify-send \
274 "Energy low: $energy" \
276 elif [[ $energy_percentage -le 50 ]]
278 if [[ ! -a "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF" ]]
280 DISPLAY
=:0.0 notify-send \
282 "Energy bellow half: $energy" \
283 'Where is the charger?'
284 touch "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF"
288 rm -f "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF"
291 weather
=$
(awk 'NR == 1 {printf("%d°F", $1)}' ~
/var
/run
/metar-KJFK-decoded-temp-fahrenheit
)
293 signal_last_msg_age
=$
(
294 ls -lt --time-style=+%s
$HOME/var
/lib
/signal
/latest_message.json \
295 |
awk -v now_seconds
=$
(date +%s
) \
298 seconds = now_seconds - mtime_seconds;
299 minutes = seconds / 60;
300 hours = minutes / 60;
306 #printf(fmt " s\n", seconds);
307 printf(fmt " m\n", minutes);
308 printf(fmt " h\n", hours);
309 printf(fmt " d\n", days);
310 printf(fmt " w\n", weeks);
311 printf(fmt " mo\n", months);
321 | nc
127.0.0.1 6600 \
328 state = status["state:"]
330 if (state == "play") {
332 } else if (state == "pause") {
334 } else if (state == "stop") {
350 C=[$cpu ${temp}°C ${fan}rpm]\
356 $SYMBOL_WIFI [$wifi $(echo "$io_net" | awk '/^wlp3s0/ {print $2, $3}')]\
362 S=$screen_brightness\
369 $signal_last_msg_age\