@@ -8,6 +8,7 @@ function M.volume_job()
88 cmd_right = " amixer sget Master | grep 'Right:' | awk -F'[][]' '{ print $2 }'"
99 cmd_left = " amixer sget Master | grep 'Left:' | awk -F'[][]' '{ print $2 }'"
1010 mute = " amixer get Master | sed 5q | grep -q '[on]'"
11+ -- mute = "amixer sget Master | grep 'Right:' | awk -F'[][]' '{ print $4 }'"
1112 elseif vim .fn .executable (" pulsemixer" ) == 1 then
1213 cmd_right = " pulsemixer --get-volume | awk -F ' ' '{ print $1 }'"
1314 cmd_left = " pulsemixer --get-volume | awk -F ' ' '{ print $2 }'"
@@ -54,24 +55,41 @@ function M.volume_job()
5455 vim .fn .jobwait ({ mute_job_id }, 0 )
5556end
5657
58+ function M .select_icon (volume_level )
59+ local lvl = tonumber (volume_level )
60+ if lvl < 33 then
61+ return volume .icons .low
62+ elseif lvl >= 33 and lvl < 66 then
63+ return volume .icons .medium
64+ else
65+ return volume .icons .high
66+ end
67+ end
68+
5769function M .volume ()
5870 M .volume_job ()
59- local result = volume . icon .. " "
71+ local result = " "
6072 if vim .g .volume_left then
61- result = result .. vim .g .volume_left .. " "
73+ result = result .. M .select_icon (vim .g .volume_left ) .. " "
74+ if volume .show_percentage then
75+ result = result .. vim .g .volume_left .. " "
76+ end
6277 else
6378 result = result .. " ..."
6479 end
6580
6681 result = result .. " "
6782 if vim .g .volume_right then
68- result = result .. vim .g .volume_right .. " "
83+ result = result .. M .select_icon (vim .g .volume_right ) .. " "
84+ if volume .show_percentage then
85+ result = result .. vim .g .volume_right .. " "
86+ end
6987 else
7088 result = result .. " ..."
7189 end
7290 local muted = vim .g .mute == " 1" and true or false
7391
74- return muted and " " or result
92+ return muted and volume . icons . mute or result
7593end
7694
7795require (" pigeon.commands.volume" ).volume_commands ()
0 commit comments