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" {
49 prev_file = "/home/siraaj/var/run/status/disk_space_used_percentage";
50 getline prev < prev_file;
51 print curr > prev_file;
54 } else if (curr < prev) {
59 printf("%s%d%%", direction, curr);
69 device = $1; sub(":$", "", device);
73 prev_file_prefix = "/home/siraaj/var/run/status/io_net_" device;
74 prev_read_file = prev_file_prefix "_read";
75 prev_write_file = prev_file_prefix "_write";
77 getline prev_read < prev_read_file;
78 getline prev_write < prev_write_file;
80 diff_read = (curr_read - prev_read ) / bytes_per_unit;
81 diff_write = (curr_write - prev_write) / bytes_per_unit;
83 print curr_read > prev_read_file;
84 print curr_write > prev_write_file;
86 printf("%s %0.0f▲ %0.0f▼\n", device, diff_write, diff_read);
96 /^ +percentage: +/ {percentage=$2}
97 /^ +state: +/ {state=$2}
99 if (state == "discharging") {
100 direction_of_change = "<"
101 } else if (state == "charging") {
102 direction_of_change = ">"
104 direction_of_change = "="
106 printf("%s%s", direction_of_change, percentage)
109 datetime
=$
(date +'%a, %b %d, %H:%M:%S')
112 # amixer get Master \
117 # sub("^\\[", "", level);
118 # sub("\\]$", "", level);
124 # amixer get Master \
126 # | awk '{print $4}' \
137 for (i=2; i<=NF; i++) printf(" %s", $i);
140 /^[ \t]*Mute:/ {mute = $2}
141 /^[ \t]*front-left:/ {left = $4}
142 /^[ \t]*front-right:/ {right = $4}
147 printf("%s %s", left, right)
153 volume
="[$volume_pactl]"
155 wifi
=$
(cat $STATUS_FILE__WIFI)
158 max
=$
(cat /sys
/class
/backlight
/acpi_video
0/max_brightness
)
159 cur
=$
(cat /sys
/class
/backlight
/acpi_video
0/brightness
)
160 awk -v max
=$max -v cur
=$cur 'BEGIN {printf("%d%%", cur/max*100)}'
164 # grep '^status:' /proc/acpi/ibm/bluetooth \
166 # $2 == "disabled" {printf "off"}
167 # $2 == "enabled" {printf "on"}
172 echo -e 'show \n quit' \
177 controllers[++ctrl_count] = controller;
179 /^\t[A-Z][A-Za-z]+:/ {
183 for (i=3; i<=NF; i++) {
185 data[controller, key] = val;
188 # Using the 1st seen controller. Should we select specific instead?
189 power_status = data[controllers[1], "Powered"];
190 if (ctrl_count > 0) {
191 if (power_status == "no") {
193 } else if (power_status == "yes") {
196 printf("Unexpected bluetooth power status: %s\n", power_status)\
198 power_status = "ERROR"
201 power_status = "off" # TODO: Perhaps use differentiated marker?
203 printf("%s", power_status);
208 # xinput list-props 12 \
210 # /^\tDevice Enabled \([0-9]+\):/ {
212 # printf("%s", status);
217 #color_on_bg_gray='\033[m\033[40m'
219 energy_direction
=$
(echo "$energy" | cut
-b 1)
220 energy_percentage
=$
(echo "$energy" |
tr -d '<>=%')
221 if [[ "$energy_direction" = '<' ]]
223 if [[ $energy_percentage -le 5 ]]
225 DISPLAY
=:0.0 notify-send \
227 "Energy CRITICALLY low: $energy" \
228 'CHARGE NOW!!! GO GO GO!!!'
229 elif [[ $energy_percentage -le 10 ]]
231 DISPLAY
=:0.0 notify-send \
233 "Energy VERY low: $energy" \
235 elif [[ $energy_percentage -le 15 ]]
237 DISPLAY
=:0.0 notify-send \
239 "Energy low: $energy" \
241 elif [[ $energy_percentage -le 50 ]]
243 if [[ ! -a "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF" ]]
245 DISPLAY
=:0.0 notify-send \
247 "Energy bellow half: $energy" \
248 'Where is the charger?'
249 touch "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF"
253 rm -f "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF"
256 weather
=$
(awk 'NR == 1 {printf("%d°F", $1)}' ~
/var
/run
/metar-KJFK-decoded-temp-fahrenheit
)
258 signal_last_msg_age
=$
(
259 ls -lt --time-style=+%s
$HOME/var
/lib
/signal
/latest_message.json \
260 |
awk -v now_seconds
=$
(date +%s
) \
263 seconds = now_seconds - mtime_seconds;
264 minutes = seconds / 60;
265 hours = minutes / 60;
271 #printf(fmt " s\n", seconds);
272 printf(fmt " m\n", minutes);
273 printf(fmt " h\n", hours);
274 printf(fmt " d\n", days);
275 printf(fmt " w\n", weeks);
276 printf(fmt " mo\n", months);
295 C=[$cpu ${temp}°C ${fan}rpm]\
298 S=$screen_brightness\
307 W:[$wifi $(echo "$io_net" | awk '/^wlp3s0/ {print $2, $3}')]\
310 $signal_last_msg_age\