10 To copy everything from `./bin` to `$HOME/bin`:
16 In my `~/.xinitrc` I have something like the following:
20 --wifi_interface 'wlp3s0' \
21 --interval_bluetooth 5 \
22 --interval_net_wifi 5 \
23 --interval_disk_space 5 \
25 >(stdbuf -o L "$BIN"/khatus_bar \
26 -v Opt_Mpd_Song_Max_Chars=10 \
27 -v Opt_Pulseaudio_Sink=0 \
29 -f <("$BIN"/khatus_gen_bar_make_status \
30 -v Status_Fmt=' E=%s%% M=%d%% P=[%s %sr %sd %st %si %sz] C=[%s %s°C %srpm] D=[%s%% %s▲ %s▼] W=[%s %s▲ %s▼] B=%s *=%s%% (%s) [%s] %s°F %s ' \
31 -v Status_Args='@energy_percent,@memory_percent,@processes_count_all,@processes_count_r,@processes_count_d,@processes_count_t,@processes_count_i,@processes_count_z,@cpu_loadavg,@cpu_temp,@cpu_fan_speed,@disk_space,@disk_io_w,@disk_io_r,@net_wifi:wlp3s0,@net_io_w:wlp3s0,@net_io_r:wlp3s0,@bluetooth_power,@backlight_percent,@volume_pa_device:0,@mpd,@weather_temp_f,@datetime' \
33 | "$BIN"/khatus_actuate_status_bar_to_xsetroot_name \
35 >(stdbuf -o L "$BIN"/khatus_monitor_energy \
36 | "$BIN"/khatus_actuate_alert_to_notify_send \
38 >(stdbuf -o L "$BIN"/khatus_monitor_errors \
39 | "$BIN"/khatus_actuate_alert_to_notify_send \
41 >(stdbuf -o L "$BIN"/khatus_monitor_devices \
42 | "$BIN"/khatus_actuate_alert_to_notify_send \
44 >(stdbuf -o L "$BIN"/khatus_actuate_device_add_to_automount \
45 | "$BIN"/khatus_actuate_alert_to_notify_send \
48 2> >($BIN/twrap >> $KHATUS_LOGS_DIR/main.log) \
52 (where `twrap` is a simple script which prefixes a timestamp to each line)
54 The idea is to support appending any number of ad-hoc, experimental monitors by
55 giving maximum flexibility for what to do with the sensor outputs, while
56 maintaining some uniformity of msg formats (again, to ease ad-hoc combinations
57 (e.g. Does the CPU get hotter when MPD is playing Wu-Tang?)). `khatus_bar`,
58 `khatus_monitor_energy` and `khatus_monitor_errors` are just some initial
66 In an effort to simplify the components and their interfaces, I removed the
67 concept of a global controller from the previous design (which, at least for
68 now, is superfluous), so now it is essentially a pub-sub - parallel publishers
69 (sensors) write to a pipe, which is then copied to any number of interested
70 subscribers that can filter-out what they need and then do whatever they want
71 with the data. Status bar is one such subscriber:
73 `P1 > pipe&; P2 > pipe&; ... PN > pipe&; tail -f pipe | tee >(S1) >(S2) ... >(SN) > /dev/null`
75 The cool thing is that, because the pipe is always read (`tail -f ... > /dev/null`),
76 the publishers are never blocked, so we get a live stream of events to which we
77 can attach any number of interested subscribers (` ... tee ... `) and, because
78 the pipe is named, if a subscriber needs to - it too can publish something to
79 the pipe without being blocked.
82 parallel +----------+ +----------+ +----------+
83 stateless | sensor_1 | | sensor_2 | ... | sensor_n |
84 collectors +----------+ +----------+ +----------+
89 multiplexing +-------------+-----------+---------+
93 copying to +-------------+-+---------+---------+
96 +------------+ ... +----------------+
97 any number of | status bar | | energy monitor |
98 parallel +------------+ +----------------+
101 +----------------+ +-------------+
102 | xsetroot -name | | notify-send |
103 +----------------+ +-------------+
108 This was an improvement of having everything in one script, but the controller
109 was still way too complicated for no good reason.
112 parallel +----------+ +----------+ +----------+
113 stateless | sensor_1 | | sensor_2 | ... | sensor_n |
114 collectors +----------+ +----------+ +----------+
119 serial +----------------------------------------------+
120 stateful | controller |
121 observer +----------------------------------------------+
133 +-------------+-+---------+---------+
136 parallel +------------+ +------------+ +------------+
137 stateless | filter_1 | | filter_2 | ... | filter_n |
138 filters +------------+ +------------+ +------------+
141 parallel +------------+ +------------+ +------------+
142 stateless | actuator_1 | | actuator_2 | ... | actuator_n |
143 executors +------------+ +------------+ +------------+
145 commands commands commands commands
148 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
149 ~~~~~~~~~~~~~ operating system ~~~~~~~~~~~~~~~~~
150 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
154 Actuator is anything that takes action upon controller messages. A few generic
157 - `khatus_actuate_alert_to_notify_send`
158 - `khatus_actuate_status_bar_to_xsetroot_name`
160 and, by default, are left disconnected from the data feed, so if desired - need
161 to be manually attached when starting `khatus`. See usage section.
164 Any errors encountered by any sensor are propagated as alerts by the
165 controller, which are in turn actualized as desktop notifications by the
166 `khatus_actuate_alert_to_notify_send` actuator:
168 ![screenshot-self-error-propagation](screenshot-self-error-propagation.jpg)
173 - controller should not do formatting
174 - need in-memory db for diskless feedback/throttling and cache
175 - decouple sensor execution from sleep, i.e. a sensor is blocked not by sleep
176 process directly, but by reading of a pipe, to where a sleep process will
177 write a message announcing interval completion and thus signaling execution.
178 This will allow us to manually signal a sensor to update (concretely - I just
179 openned my laptop from sleep and want to force the weather to update
180 immediately); likewise, the sleep process should be blocked on pipe-read
181 until sensor execution is complete - this will allow us to reconfigure
182 intervals at runtime (which seems like a better idea than the above in-memory