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";
54 } else if (curr < prev) {
59 printf("%s%d%%", direction, curr);
67 /^ +percentage: +/ {percentage=$2}
68 /^ +state: +/ {state=$2}
70 if (state == "discharging") {
71 direction_of_change = "<"
72 } else if (state == "charging") {
73 direction_of_change = ">"
75 direction_of_change = "="
77 printf("%s%s", direction_of_change, percentage)
80 datetime
=$
(date +'%a, %b %d, %H:%M:%S')
88 # sub("^\\[", "", level);
89 # sub("\\]$", "", level);
97 # | awk '{print $4}' \
108 for (i=2; i<=NF; i++) printf(" %s", $i);
111 /^[ \t]*Mute:/ {mute = $2}
112 /^[ \t]*front-left:/ {left = $4}
113 /^[ \t]*front-right:/ {right = $4}
118 printf("%s %s", left, right)
124 volume
="[$volume_pactl]"
126 wifi
=$
(cat $STATUS_FILE__WIFI)
129 max
=$
(cat /sys
/class
/backlight
/acpi_video
0/max_brightness
)
130 cur
=$
(cat /sys
/class
/backlight
/acpi_video
0/brightness
)
131 awk -v max
=$max -v cur
=$cur 'BEGIN {printf("%d%%", cur/max*100)}'
135 # grep '^status:' /proc/acpi/ibm/bluetooth \
137 # $2 == "disabled" {printf "off"}
138 # $2 == "enabled" {printf "on"}
143 echo -e 'show \n quit' \
148 controllers[++ctrl_count] = controller;
150 /^\t[A-Z][A-Za-z]+:/ {
154 for (i=3; i<=NF; i++) {
156 data[controller, key] = val;
159 # Using the 1st seen controller. Should we select specific instead?
160 power_status = data[controllers[1], "Powered"];
161 if (ctrl_count > 0) {
162 if (power_status == "no") {
164 } else if (power_status == "yes") {
167 printf("Unexpected bluetooth power status: %s\n", power_status)\
169 power_status = "ERROR"
172 power_status = "off" # TODO: Perhaps use differentiated marker?
174 printf("%s", power_status);
179 # xinput list-props 12 \
181 # /^\tDevice Enabled \([0-9]+\):/ {
183 # printf("%s", status);
188 #color_on_bg_gray='\033[m\033[40m'
190 energy_direction
=$
(echo "$energy" | cut
-b 1)
191 energy_percentage
=$
(echo "$energy" |
tr -d '<>=%')
192 if [[ "$energy_direction" = '<' ]]
194 if [[ $energy_percentage -le 5 ]]
196 DISPLAY
=:0.0 notify-send \
198 "Energy CRITICALLY low: $energy" \
199 'CHARGE NOW!!! GO GO GO!!!'
200 elif [[ $energy_percentage -le 10 ]]
202 DISPLAY
=:0.0 notify-send \
204 "Energy VERY low: $energy" \
206 elif [[ $energy_percentage -le 15 ]]
208 DISPLAY
=:0.0 notify-send \
210 "Energy low: $energy" \
212 elif [[ $energy_percentage -le 50 ]]
214 if [[ ! -a "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF" ]]
216 DISPLAY
=:0.0 notify-send \
218 "Energy bellow half: $energy" \
219 'Where is the charger?'
220 touch "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF"
224 rm -f "$STATUS_FILE__ENERGY_NOTIFIED_BELLOW_HALF"
227 weather
="$(cat ~/var/run/metar-KJFK-decoded-temp-fahrenheit)°F"
229 signal_last_msg_age
=$
(
230 ls -lt --time-style=+%s
$HOME/var
/lib
/signal
/latest_message.json \
231 |
awk -v now_seconds
=$
(date +%s
) \
234 seconds = now_seconds - mtime_seconds;
235 minutes = seconds / 60;
236 hours = minutes / 60;
242 #printf(fmt " s\n", seconds);
243 printf(fmt " m\n", minutes);
244 printf(fmt " h\n", hours);
245 printf(fmt " d\n", days);
246 printf(fmt " w\n", weeks);
247 printf(fmt " mo\n", months);
266 C=[$cpu ${temp}°C ${fan}rpm]\
269 S=$screen_brightness\