-v Opt_Mpd_Song_Max_Chars=10 \
-v Opt_Net_Interfaces_To_Show=wlp3s0 \
-v Opt_Pulseaudio_Sink=0 \
+ -f <(./bin/khatus_gen_make_status_bar \
+ -v Status_Bar='@energy,@memory,@processes,@cpu,@disk,@net,@bluetooth,@backlight,@volume,@mpd,@weather,@datetime' \
+ ) \
| "$BIN"/khatus_actuate_status_bar_to_xsetroot_name \
) \
>(stdbuf -o L "$BIN"/khatus_monitor_energy \
$1 == "OK" && \
$2 == "khatus_sensor_datetime" {
+ # Code for make_status_bar definition is expected to be passed as an
+ # additional source file, using -f flag.
print_msg_ok("status_bar", make_status_bar())
}
# Status bar
# -----------------------------------------------------------------------------
-function make_status_bar( position, bar, sep, i, j) {
- position[++i] = ""
- position[++i] = make_status_energy()
- position[++i] = make_status_mem()
- position[++i] = make_status_procs()
- position[++i] = make_status_cpu()
- position[++i] = make_status_disk()
- position[++i] = make_status_net()
- position[++i] = make_status_bluetooth()
- position[++i] = make_status_screen_brightness()
- position[++i] = make_status_volume()
- position[++i] = make_status_mpd()
- position[++i] = make_status_weather()
- position[++i] = make_status_datetime()
- position[++i] = ""
- bar = ""
- sep = ""
- for (j = 1; j <= i; j++) {
- bar = bar sep position[j]
- sep = " "
- }
- return bar
-}
-
function make_status_energy( state, charge, direction_of_change) {
cache_get(state , "khatus_sensor_energy", "battery_state" , 0)
cache_get(charge, "khatus_sensor_energy", "battery_percentage", 0)
--- /dev/null
+#! /usr/bin/awk -f
+
+BEGIN {
+ aliases["@energy"] = "make_status_energy()"
+ aliases["@memory"] = "make_status_mem()"
+ aliases["@processes"] = "make_status_procs()"
+ aliases["@cpu"] = "make_status_cpu()"
+ aliases["@disk"] = "make_status_disk()"
+ aliases["@net"] = "make_status_net()"
+ aliases["@bluetooth"] = "make_status_bluetooth()"
+ aliases["@backlight"] = "make_status_screen_brightness()"
+ aliases["@volume"] = "make_status_volume()"
+ aliases["@mpd"] = "make_status_mpd()"
+ aliases["@weather"] = "make_status_weather()"
+ aliases["@datetime"] = "make_status_datetime()"
+ out = "function make_status_bar( position, bar, sep, i, j) {\n"
+ n = split(Status_Bar, s, ",")
+ for (i=1; i<=n; i++) {
+ alias = s[i]
+ function_call = aliases[alias]
+ if (function_call) {
+ out = out " position[++i] = " function_call ";\n"
+ } else {
+ printf("Unexpected status bar component alias: \"%s\"\n", alias) \
+ > "/dev/stderr"
+ exit(1)
+ }
+ }
+ out = out "\
+ bar = \"\";\
+ sep = \"\";\
+ for (j = 1; j <= i; j++) {\
+ bar = bar sep position[j];\
+ sep = \" \";\
+ }\
+ return bar;\
+ }";
+ print out
+}
-v Opt_Net_Interfaces_To_Show=wlp3s0 \
-v Opt_Pulseaudio_Sink=0 \
-v GC_Interval=300 \
+ -f <(./bin/khatus_gen_make_status_bar \
+ -v Status_Bar='@energy,@memory,@processes,@cpu,@disk,@net,@bluetooth,@backlight,@volume,@mpd,@weather,@datetime' \
+ ) \
) \
>(stdbuf -o L ./bin/khatus_monitor_energy) \
>(stdbuf -o L ./bin/khatus_monitor_errors) \