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 file = "/home/siraaj/var/run/status/memory_used_percentage";
26 curr = round(used / total * 100);
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 file = "/home/siraaj/var/run/status/disk_space_used_percentage";
50 curr = round(used / total * 100);
55 } else if (curr < prev) {
60 printf("%s%d%%", direction, curr);
68 /^ +percentage: +/ {percentage=$2}
69 /^ +state: +/ {state=$2}
71 if (state == "discharging") {
72 direction_of_change = "<"
73 } else if (state == "charging") {
74 direction_of_change = ">"
76 direction_of_change = "="
78 printf("%s%s", direction_of_change, percentage)
81 datetime
=$
(date +'%a, %b %d, %H:%M:%S')
89 # sub("^\\[", "", level);
90 # sub("\\]$", "", level);
98 # | awk '{print $4}' \
109 for (i=2; i<=NF; i++) printf(" %s", $i);
112 /^[ \t]*Mute:/ {mute = $2}
113 /^[ \t]*front-left:/ {left = $4}
114 /^[ \t]*front-right:/ {right = $4}
119 printf("%s %s", left, right)
125 volume
="[$volume_pactl]"
127 wifi
=$
(cat $STATUS_FILE__WIFI)
130 max
=$
(cat /sys
/class
/backlight
/acpi_video
0/max_brightness
)
131 cur
=$
(cat /sys
/class
/backlight
/acpi_video
0/brightness
)
132 awk -v max
=$max -v cur
=$cur 'BEGIN {printf("%d%%", cur/max*100)}'
136 # grep '^status:' /proc/acpi/ibm/bluetooth \
138 # $2 == "disabled" {printf "off"}
139 # $2 == "enabled" {printf "on"}
144 echo -e 'show \n quit' \
149 controllers[++ctrl_count] = controller;
151 /^\t[A-Z][A-Za-z]+:/ {
155 for (i=3; i<=NF; i++) {
157 data[controller, key] = val;
160 # Using the 1st seen controller. Should we select specific instead?
161 power_status = data[controllers[1], "Powered"];
162 if (ctrl_count > 0) {
163 if (power_status == "no") {
165 } else if (power_status == "yes") {
168 printf("Unexpected bluetooth power status: %s\n", power_status)\
170 power_status = "ERROR"
173 power_status = "off" # TODO: Perhaps use differentiated marker?
175 printf("%s", power_status);
180 # xinput list-props 12 \
182 # /^\tDevice Enabled \([0-9]+\):/ {
184 # printf("%s", status);
189 #color_on_bg_gray='\033[m\033[40m'
191 energy_direction
=$
(echo "$energy" | cut
-b 1)
192 energy_percentage
=$
(echo "$energy" |
tr -d '<>=%')
193 if [[ "$energy_direction" = '<' ]]
195 if [[ $energy_percentage -le 5 ]]
197 DISPLAY
=:0.0 notify-send \
199 "Energy CRITICALLY low: $energy" \
200 'CHARGE NOW!!! GO GO GO!!!'
201 elif [[ $energy_percentage -le 10 ]]
203 DISPLAY
=:0.0 notify-send \
205 "Energy VERY low: $energy" \
207 elif [[ $energy_percentage -le 15 ]]
209 DISPLAY
=:0.0 notify-send \
211 "Energy low: $energy" \
213 elif [[ $energy_percentage -le 50 ]]
215 if [[ ! -a "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF" ]]
217 DISPLAY
=:0.0 notify-send \
219 "Energy bellow half: $energy" \
220 'Where is the charger?'
221 touch "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF"
225 rm -f "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF"
228 weather
="$(cat ~/var/run/metar-KJFK-decoded-temp-fahrenheit)°F"
230 signal_last_msg_age
=$
(
231 ls -lt --time-style=+%s
$HOME/var
/lib
/signal
/latest_message.json \
232 |
awk -v now_seconds
=$
(date +%s
) \
235 seconds = now_seconds - mtime_seconds;
236 minutes = seconds / 60;
237 hours = minutes / 60;
243 #printf(fmt " s\n", seconds);
244 printf(fmt " m\n", minutes);
245 printf(fmt " h\n", hours);
246 printf(fmt " d\n", days);
247 printf(fmt " w\n", weeks);
248 printf(fmt " mo\n", months);
261 C=[$cpu ${temp}°C ${fan}rpm]\
263 S=$screen_brightness\