Port connection-counting x4 bluetooth sensor to x2
[khatus.git] / x2 / src / awk / exe / gen_bar_make_status.awk
1 #! /usr/bin/awk -f
2
3 BEGIN {
4 aliases["@energy_percent"] = "bar_make_status_energy_percent()"
5 aliases["@energy_direction"] = "bar_make_status_energy_direction()"
6
7 aliases["@memory_percent"] = "bar_make_status_mem_percent()"
8
9 aliases["@processes_count_all"] = "bar_make_status_procs_count_all()"
10 aliases["@processes_count_r"] = "bar_make_status_procs_count_r()"
11 aliases["@processes_count_d"] = "bar_make_status_procs_count_d()"
12 aliases["@processes_count_t"] = "bar_make_status_procs_count_t()"
13 aliases["@processes_count_i"] = "bar_make_status_procs_count_i()"
14 aliases["@processes_count_z"] = "bar_make_status_procs_count_z()"
15
16 aliases["@cpu_loadavg"] = "bar_make_status_cpu_loadavg()"
17 aliases["@cpu_temp"] = "bar_make_status_cpu_temperature()"
18 aliases["@cpu_fan_speed"] = "bar_make_status_cpu_fan_speed()"
19
20 aliases["@disk_space"] = "bar_make_status_disk_space()"
21 aliases["@disk_io_w"] = "bar_make_status_disk_io_w()"
22 aliases["@disk_io_r"] = "bar_make_status_disk_io_r()"
23
24 aliases["@net_addr"] = "bar_make_status_net_addr(\"%s\")"
25 params["@net_addr"] = 1
26 aliases["@net_io_w"] = "bar_make_status_net_io_w(\"%s\")"
27 params["@net_io_w"] = 1
28 aliases["@net_io_r"] = "bar_make_status_net_io_r(\"%s\")"
29 params["@net_io_r"] = 1
30 aliases["@net_wifi"] = "bar_make_status_net_wifi(\"%s\")"
31 params["@net_wifi"] = 1
32 aliases["@net_wifi_link"] = "bar_make_status_net_wifi_link(\"%s\")"
33 params["@net_wifi_link"] = 1
34 aliases["@net_iface_status"] = "bar_make_status_net_iface_status(\"%s\")"
35 params["@net_iface_status"] = 1
36
37 aliases["@bluetooth"] = "bar_make_status_bluetooth()"
38 aliases["@bluetooth_power"] = "bar_make_status_bluetooth_power()"
39
40 aliases["@backlight_percent"] = "bar_make_status_backlight_percent()"
41
42 aliases["@volume"] = "bar_make_status_volume_alsa_device(%d)"
43 params["@volume"] = 1
44
45 aliases["@mpd"] = "bar_make_status_mpd()"
46
47 aliases["@weather_temp_f"] = "bar_make_status_weather_temp_f()"
48
49 aliases["@datetime"] = "bar_make_status_datetime()"
50
51 out = "function bar_make_status() {\n"
52 n_args = split(Status_Args, args_arr, ",")
53 for (i=1; i<=n_args; i++) {
54 arg = args_arr[i]
55 split(arg, arg_parts, ":")
56 alias = arg_parts[1]
57 n_expected_params = params[alias]
58 if (n_expected_params == 0) {
59 function_call = aliases[alias]
60 } else if (n_expected_params == 1) {
61 function_call = sprintf(aliases[alias], arg_parts[2])
62 # TODO: Support params > 1
63 } else {
64 printf(\
65 "Unsupported number of params: %d in %s\n",
66 n_expected_params, alias) \
67 > "/dev/stderr"
68 exit(1)
69 }
70 if (function_call) {
71 args_str = args_str ", " function_call
72 } else {
73 printf("Unexpected status bar component alias: \"%s\"\n", alias) \
74 > "/dev/stderr"
75 exit(1)
76 }
77 }
78 out = out " return sprintf(\"" Status_Fmt "\"" args_str ");\n}";
79 print out
80 }
This page took 0.107596 seconds and 5 git commands to generate.