-v GC_Interval=300 \
-f <(./bin/khatus_gen_bar_make_status \
-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▲ %s▼] E:%s:%s B=[%s %s] *=%s%% (%s) [%s] %s°F %s ' \
- -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_link:wlp4s0,@net_wifi:wlp4s0,@net_io_w:wlp4s0,@net_io_r:wlp4s0,@net_iface_status:enp0s31f6,@net_addr:enp0s31f6,@bluetooth_power,@bluetooth,@backlight_percent,@volume:0,@mpd,@weather_temp_f,@datetime' \
+ -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_link:wlp4s0,@net_wifi:wlp4s0,@net_io_w:wlp4s0,@net_io_r:wlp4s0,@net_iface_status:enp0s31f6,@net_addr:enp0s31f6,@bluetooth_power,@bluetooth,@backlight_percent,@volume,@mpd,@weather_temp_f,@datetime' \
) \
) \
>(stdbuf -o L ./bin/khatus_monitor_energy) \
# Volume
# -----------------------------------------------------------------------------
-function bar_make_status_volume_alsa_device(device, m, l, r, show) {
- cache_get(m, "khatus_sensor_volume", "mute" Kfs device, 5)
- cache_get(l, "khatus_sensor_volume", "vol_left" Kfs device, 5)
- cache_get(r, "khatus_sensor_volume", "vol_right" Kfs device, 5)
+function bar_make_status_volume( m, l, r, show) {
+ cache_get(m, "khatus_sensor_volume", "mute" , 5)
+ cache_get(l, "khatus_sensor_volume", "vol_left" , 5)
+ cache_get(r, "khatus_sensor_volume", "vol_right" , 5)
show = "--"
if (!m["is_expired"] && !l["is_expired"] && !r["is_expired"]) {
if (m["value"] == "yes")
show = l["value"] #" " r["value"]
else
msg_out_log_error(\
- "bar_make_status_volume_alsa_device: " device ". ", \
+ "bar_make_status_volume", \
"Unexpected value for 'mute' field: " m["value"] \
)
}
aliases["@backlight_percent"] = "bar_make_status_backlight_percent()"
- aliases["@volume"] = "bar_make_status_volume_alsa_device(%d)"
- params["@volume"] = 1
+ aliases["@volume"] = "bar_make_status_volume()"
aliases["@mpd"] = "bar_make_status_mpd()"
next
}
-/^\t[A-Z].+:/ {
- section = $1
-}
-
-section == "Properties:" {
- read_property()
-}
-
/\tState:/ {
state[sink] = $2
next
}
+/\tName:/ {
+ name[sink] = $2
+ next
+}
+
/\tMute:/ {
mute[sink] = $2
next
END {
for (sink in state) {
- device = properties[sink, "alsa.device"]
- print("state" Kfs device, state[sink])
- print("mute" Kfs device, mute[sink])
- print("vol_left" Kfs device, vol_left[sink])
- print("vol_right" Kfs device, vol_right[sink])
+ # default_sink set via CLI
+ if (name[sink] == default_sink) {
+ print("state" , state[sink])
+ print("mute" , mute[sink])
+ print("vol_left" , vol_left[sink])
+ print("vol_right" , vol_right[sink])
+ }
}
}
-
-function read_property() {
- key = $1
- # Yes, the sequence (x-1+1) is redundant, but it keeps the variable names
- # true to their meaning:
- val_begin = index($0, "\"") + 1 # +1 to exclude first quote
- val_end = length($0) - 1 # -1 to exclude last quote
- val_len = (val_end - val_begin) + 1 # +1 to include final character
- val = substr($0, val_begin, val_len)
- properties[sink, key] = val
-}
dir_bin="$1"
-pactl list sinks | "$dir_bin"/khatus_parse_pactl_list_sinks
+pactl list sinks \
+| "$dir_bin"/khatus_parse_pactl_list_sinks \
+ -v default_sink="$(pactl info | awk '/^Default Sink:/ {print $3}')"