diff options
author | Tom Smeding <tom.smeding@gmail.com> | 2020-05-17 11:58:34 +0200 |
---|---|---|
committer | Tom Smeding <tom.smeding@gmail.com> | 2020-05-17 11:58:34 +0200 |
commit | c1872f0fc911c5f27ae774af0155af4787e9ca8b (patch) | |
tree | 797f4e1fb4766a8291e1d1ed2455fdb890cdaf92 | |
parent | 246af172cc61ceb5e81cd7f5c058e3a1fd0645bc (diff) |
Better handle mono devices/sink inputs
-rw-r--r-- | inter.py | 22 |
1 files changed, 14 insertions, 8 deletions
@@ -91,7 +91,7 @@ def mainloop(): thing = get_selected() kind = "sink" if type(thing) == pa.Sink else "input" vol = thing.volume() - if vol[0] != vol[1]: + if len(vol) >= 2 and vol[0] != vol[1]: show_message( "Warning: current volume of this " + kind + " is asymmetric!") @@ -140,7 +140,8 @@ def mainloop(): T.bel() continue - vol = sum(thing.volume()) / 2 + vol = thing.volume() + vol = sum(vol) / len(vol) vol = min(1, max(0, vol + incr)) wrap_pacmd(lambda: thing.set_volume(vol)) @@ -249,13 +250,18 @@ def print_prefix(thing, selected): T.tprint(" ") def fmt_volume(vol): - res = ["", ""] - for i in range(2): - res[i] = str(round(100 * vol[i])) + "%" - if vol[0] == vol[1]: - return res[0] + res = [str(round(100 * value)) + "%" for value in vol] + if len(vol) > 2: + return res[0] + "/" + res[1] + " (? len(vol)==" + str(len(vol)) + ")" + elif len(vol) == 2: + if vol[0] == vol[1]: + return res[0] + else: + return res[0] + "/" + res[1] + elif len(vol) == 1: + return res[0] + " (mono)" else: - return res[0] + "/" + res[1] + return "? (len(vol)==0)" def print_volume(thing): T.setfg(6) |