Just use default pulseaudio sink for volume
authorSiraaj Khandkar <siraaj@khandkar.net>
Thu, 28 Mar 2019 10:55:01 +0000 (06:55 -0400)
committerSiraaj Khandkar <siraaj@khandkar.net>
Thu, 28 Mar 2019 10:55:01 +0000 (06:55 -0400)
x2/sanity_check
x2/src/awk/exe/bar.awk
x2/src/awk/exe/gen_bar_make_status.awk
x2/src/awk/exe/parse_pactl_list_sinks.awk
x2/src/bash/exe/khatus_sensor_volume.sh

index a6783d6..0f028a6 100755 (executable)
@@ -11,7 +11,7 @@
         -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) \
index 1868f0e..48e00f2 100644 (file)
@@ -220,10 +220,10 @@ function bar_make_status_backlight_percent(    src) {
 # 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")
@@ -232,7 +232,7 @@ function bar_make_status_volume_alsa_device(device,    m, l, r, show) {
             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"] \
             )
     }
index ea82f09..80cbc6f 100644 (file)
@@ -39,8 +39,7 @@ BEGIN {
 
     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()"
 
index 017a17e..5177d72 100644 (file)
@@ -4,19 +4,16 @@
     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
@@ -40,21 +37,12 @@ section == "Properties:" {
 
 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
-}
index 6f69829..a5f6c64 100644 (file)
@@ -4,4 +4,6 @@ set -e
 
 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}')"
This page took 0.036219 seconds and 4 git commands to generate.