Index volume by alsa.device property
[khatus.git] / 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
33 aliases["@bluetooth_power"] = "bar_make_status_bluetooth_power()"
34
35 aliases["@backlight_percent"] = "bar_make_status_backlight_percent()"
36
37 aliases["@volume"] = "bar_make_status_volume_alsa_device(%d)"
38 params["@volume"] = 1
39
40 aliases["@mpd"] = "bar_make_status_mpd()"
41
42 aliases["@weather_temp_f"] = "bar_make_status_weather_temp_f()"
43
44 aliases["@datetime"] = "bar_make_status_datetime()"
45
46 out = "function bar_make_status() {\n"
47 n_args = split(Status_Args, args_arr, ",")
48 for (i=1; i<=n_args; i++) {
49 arg = args_arr[i]
50 split(arg, arg_parts, ":")
51 alias = arg_parts[1]
52 n_expected_params = params[alias]
53 if (n_expected_params == 0) {
54 function_call = aliases[alias]
55 } else if (n_expected_params == 1) {
56 function_call = sprintf(aliases[alias], arg_parts[2])
57 } else {
58 printf(\
59 "Unsupported number of params: %d in %s\n",
60 n_expected_params, alias) \
61 > "/dev/stderr"
62 exit(1)
63 }
64 if (function_call) {
65 args_str = args_str ", " function_call
66 } else {
67 printf("Unexpected status bar component alias: \"%s\"\n", alias) \
68 > "/dev/stderr"
69 exit(1)
70 }
71 }
72 out = out " return sprintf(\"" Status_Fmt "\"" args_str ");\n}";
73 print out
74 }
This page took 0.101764 seconds and 5 git commands to generate.