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=$(cat /proc/loadavg | awk '{printf "%4.2f %4.2f %4.2f", $1, $2, $3}')
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 function round(n) {return int(n + 0.5)}
46 $1 == "/dev/mapper/kubuntu--vg-root" {
48 curr_perc = $5; sub("%$", "", curr_perc);
49 prev_file_prefix = "/home/siraaj/var/run/status/disk_space_used";
51 prev_perc_file = prev_file_prefix "_percentage";
52 prev_blocks_file = prev_file_prefix "_blocks";
54 getline prev_blocks < prev_blocks_file;
55 getline prev_perc < prev_perc_file;
57 print curr_blocks > prev_blocks_file;
58 print curr_perc > prev_perc_file;
59 if (curr_perc > prev_perc) {
61 } else if (curr_perc < prev_perc) {
66 diff_blocks = curr_blocks - prev_blocks;
67 printf("%s[%d%% %d]", direction, curr_perc, diff_blocks);
73 bytes_per_unit = 1024 * 1024
77 device = $1; sub(":$", "", device);
81 prev_file_prefix = "/home/siraaj/var/run/status/io_net_" device;
82 prev_read_file = prev_file_prefix "_read";
83 prev_write_file = prev_file_prefix "_write";
85 getline prev_read < prev_read_file;
86 getline prev_write < prev_write_file;
88 diff_read = (curr_read - prev_read ) / bytes_per_unit;
89 diff_write = (curr_write - prev_write) / bytes_per_unit;
91 print curr_read > prev_read_file;
92 print curr_write > prev_write_file;
94 printf("%s %0.3f▲ %0.3f▼\n", device, diff_write, diff_read);
104 /^ +percentage: +/ {percentage=$2}
105 /^ +state: +/ {state=$2}
107 if (state == "discharging") {
108 direction_of_change = "<"
109 } else if (state == "charging") {
110 direction_of_change = ">"
112 direction_of_change = "="
114 printf("%s%s", direction_of_change, percentage)
117 datetime
=$
(date +'%a, %b %d, %H:%M:%S')
120 # amixer get Master \
125 # sub("^\\[", "", level);
126 # sub("\\]$", "", level);
132 # amixer get Master \
134 # | awk '{print $4}' \
145 for (i=2; i<=NF; i++) printf(" %s", $i);
148 /^[ \t]*Mute:/ {mute = $2}
149 /^[ \t]*front-left:/ {left = $4}
150 /^[ \t]*front-right:/ {right = $4}
155 printf("%s %s", left, right)
161 volume
="[$volume_pactl]"
163 wifi
=$
(cat $STATUS_FILE__WIFI)
166 max
=$
(cat /sys
/class
/backlight
/acpi_video
0/max_brightness
)
167 cur
=$
(cat /sys
/class
/backlight
/acpi_video
0/brightness
)
168 awk -v max
=$max -v cur
=$cur 'BEGIN {printf("%d%%", cur/max*100)}'
172 # grep '^status:' /proc/acpi/ibm/bluetooth \
174 # $2 == "disabled" {printf "off"}
175 # $2 == "enabled" {printf "on"}
180 echo -e 'show \n quit' \
185 controllers[++ctrl_count] = controller;
187 /^\t[A-Z][A-Za-z]+:/ {
191 for (i=3; i<=NF; i++) {
193 data[controller, key] = val;
196 # Using the 1st seen controller. Should we select specific instead?
197 power_status = data[controllers[1], "Powered"];
198 if (ctrl_count > 0) {
199 if (power_status == "no") {
201 } else if (power_status == "yes") {
204 printf("Unexpected bluetooth power status: %s\n", power_status)\
206 power_status = "ERROR"
209 power_status = "off" # TODO: Perhaps use differentiated marker?
211 printf("%s", power_status);
216 # xinput list-props 12 \
218 # /^\tDevice Enabled \([0-9]+\):/ {
220 # printf("%s", status);
225 #color_on_bg_gray='\033[m\033[40m'
227 energy_direction
=$
(echo "$energy" | cut
-b 1)
228 energy_percentage
=$
(echo "$energy" |
tr -d '<>=%')
229 if [[ "$energy_direction" = '<' ]]
231 if [[ $energy_percentage -le 5 ]]
233 DISPLAY
=:0.0 notify-send \
235 "Energy CRITICALLY low: $energy" \
236 'CHARGE NOW!!! GO GO GO!!!'
237 elif [[ $energy_percentage -le 10 ]]
239 DISPLAY
=:0.0 notify-send \
241 "Energy VERY low: $energy" \
243 elif [[ $energy_percentage -le 15 ]]
245 DISPLAY
=:0.0 notify-send \
247 "Energy low: $energy" \
249 elif [[ $energy_percentage -le 50 ]]
251 if [[ ! -a "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF" ]]
253 DISPLAY
=:0.0 notify-send \
255 "Energy bellow half: $energy" \
256 'Where is the charger?'
257 touch "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF"
261 rm -f "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF"
264 weather
=$
(awk 'NR == 1 {printf("%d°F", $1)}' ~
/var
/run
/metar-KJFK-decoded-temp-fahrenheit
)
266 signal_last_msg_age
=$
(
267 ls -lt --time-style=+%s
$HOME/var
/lib
/signal
/latest_message.json \
268 |
awk -v now_seconds
=$
(date +%s
) \
271 seconds = now_seconds - mtime_seconds;
272 minutes = seconds / 60;
273 hours = minutes / 60;
279 #printf(fmt " s\n", seconds);
280 printf(fmt " m\n", minutes);
281 printf(fmt " h\n", hours);
282 printf(fmt " d\n", days);
283 printf(fmt " w\n", weeks);
284 printf(fmt " mo\n", months);
294 | nc
127.0.0.1 6600 \
301 state = status["state:"]
303 if (state == "play") {
305 } else if (state == "pause") {
307 } else if (state == "stop") {
326 C=[$cpu ${temp}°C ${fan}rpm]\
329 S=$screen_brightness\
338 W:[$wifi $(echo "$io_net" | awk '/^wlp3s0/ {print $2, $3}')]\
343 $signal_last_msg_age\