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 function round(n) {return int(n + 0.5)}
48 $1 == "/dev/mapper/kubuntu--vg-root" {
50 curr_perc = $5; sub("%$", "", curr_perc);
51 prev_file_prefix = "/home/siraaj/var/run/status/disk_space_used";
53 prev_perc_file = prev_file_prefix "_percentage";
54 prev_blocks_file = prev_file_prefix "_blocks";
56 getline prev_blocks < prev_blocks_file;
57 getline prev_perc < prev_perc_file;
59 print curr_blocks > prev_blocks_file;
60 print curr_perc > prev_perc_file;
61 if (curr_perc > prev_perc) {
63 } else if (curr_perc < prev_perc) {
68 diff_blocks = curr_blocks - prev_blocks;
69 printf("%s[%d%% %d]", direction, curr_perc, diff_blocks);
75 bytes_per_unit = 1024 * 1024
79 device = $1; sub(":$", "", device);
83 prev_file_prefix = "/home/siraaj/var/run/status/io_net_" device;
84 prev_read_file = prev_file_prefix "_read";
85 prev_write_file = prev_file_prefix "_write";
87 getline prev_read < prev_read_file;
88 getline prev_write < prev_write_file;
90 diff_read = (curr_read - prev_read ) / bytes_per_unit;
91 diff_write = (curr_write - prev_write) / bytes_per_unit;
93 print curr_read > prev_read_file;
94 print curr_write > prev_write_file;
96 printf("%s %0.3f▲ %0.3f▼\n", device, diff_write, diff_read);
106 /^ +percentage: +/ {percentage=$2}
107 /^ +state: +/ {state=$2}
109 if (state == "discharging") {
110 direction_of_change = "<"
111 } else if (state == "charging") {
112 direction_of_change = ">"
114 direction_of_change = "="
116 printf("%s%s", direction_of_change, percentage)
119 datetime
=$
(date +'%a, %b %d, %H:%M:%S')
122 # amixer get Master \
127 # sub("^\\[", "", level);
128 # sub("\\]$", "", level);
134 # amixer get Master \
136 # | awk '{print $4}' \
147 for (i=2; i<=NF; i++) printf(" %s", $i);
150 /^[ \t]*Mute:/ {mute = $2}
151 /^[ \t]*front-left:/ {left = $4}
152 /^[ \t]*front-right:/ {right = $4}
157 printf("%s %s", left, right)
163 volume
="[$volume_pactl]"
165 wifi
=$
(cat $STATUS_FILE__WIFI)
168 max
=$
(cat /sys
/class
/backlight
/acpi_video
0/max_brightness
)
169 cur
=$
(cat /sys
/class
/backlight
/acpi_video
0/brightness
)
170 awk -v max
=$max -v cur
=$cur 'BEGIN {printf("%d%%", cur/max*100)}'
174 # grep '^status:' /proc/acpi/ibm/bluetooth \
176 # $2 == "disabled" {printf "off"}
177 # $2 == "enabled" {printf "on"}
182 echo -e 'show \n quit' \
187 controllers[++ctrl_count] = controller;
189 /^\t[A-Z][A-Za-z]+:/ {
193 for (i=3; i<=NF; i++) {
195 data[controller, key] = val;
198 # Using the 1st seen controller. Should we select specific instead?
199 power_status = data[controllers[1], "Powered"];
200 if (ctrl_count > 0) {
201 if (power_status == "no") {
203 } else if (power_status == "yes") {
206 printf("Unexpected bluetooth power status: %s\n", power_status)\
208 power_status = "ERROR"
211 power_status = "off" # TODO: Perhaps use differentiated marker?
213 printf("%s", power_status);
218 # xinput list-props 12 \
220 # /^\tDevice Enabled \([0-9]+\):/ {
222 # printf("%s", status);
227 #color_on_bg_gray='\033[m\033[40m'
229 energy_direction
=$
(echo "$energy" | cut
-b 1)
230 energy_percentage
=$
(echo "$energy" |
tr -d '<>=%')
231 if [[ "$energy_direction" = '<' ]]
233 if [[ $energy_percentage -le 5 ]]
235 DISPLAY
=:0.0 notify-send \
237 "Energy CRITICALLY low: $energy" \
238 'CHARGE NOW!!! GO GO GO!!!'
239 elif [[ $energy_percentage -le 10 ]]
241 DISPLAY
=:0.0 notify-send \
243 "Energy VERY low: $energy" \
245 elif [[ $energy_percentage -le 15 ]]
247 DISPLAY
=:0.0 notify-send \
249 "Energy low: $energy" \
251 elif [[ $energy_percentage -le 50 ]]
253 if [[ ! -a "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF" ]]
255 DISPLAY
=:0.0 notify-send \
257 "Energy bellow half: $energy" \
258 'Where is the charger?'
259 touch "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF"
263 rm -f "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF"
266 weather
=$
(awk 'NR == 1 {printf("%d°F", $1)}' ~
/var
/run
/metar-KJFK-decoded-temp-fahrenheit
)
268 signal_last_msg_age
=$
(
269 ls -lt --time-style=+%s
$HOME/var
/lib
/signal
/latest_message.json \
270 |
awk -v now_seconds
=$
(date +%s
) \
273 seconds = now_seconds - mtime_seconds;
274 minutes = seconds / 60;
275 hours = minutes / 60;
281 #printf(fmt " s\n", seconds);
282 printf(fmt " m\n", minutes);
283 printf(fmt " h\n", hours);
284 printf(fmt " d\n", days);
285 printf(fmt " w\n", weeks);
286 printf(fmt " mo\n", months);
296 | nc
127.0.0.1 6600 \
303 state = status["state:"]
305 if (state == "play") {
307 } else if (state == "pause") {
309 } else if (state == "stop") {
325 C=[$cpu ${temp}°C ${fan}rpm]\
331 $SYMBOL_WIFI [$wifi $(echo "$io_net" | awk '/^wlp3s0/ {print $2, $3}')]\
337 S=$screen_brightness\
344 $signal_last_msg_age\