final version to get the values >= 100% 

#!/bin/bash
mute=$(pactl list sinks | grep "Description: WH-1000XM3" -A 6 | grep Mute | 
grep "yes") 
volume=$(pactl list sinks | grep "Description: WH-1000XM3" -A 6 | grep -E 
-m1 -o "...%" | head -n1 | tr -d " ") 
if [ ! -z "$mute" ] 
then 
     echo "[M]" 
else 
     echo "[$volume]" 
fi 
exit 0

On Sunday, May 16, 2021 at 1:05:57 PM UTC+2 Seph IZ wrote:

> Oh ! You are right ! I didn't realised the format need brackets ! thank 
> you very much.
> Do you mind explaining me why bracket are needed ?
>
> For future user with same issue, this is the final script to get the 
> correct output when muted and when volume is changed 
>
> #!/bin/bash 
> mute=$(pactl list sinks | grep "Description: WH-1000XM3" -A 6 | grep Mute 
> | grep "yes") 
> volume=$(pactl list sinks | grep "Description: WH-1000XM3" -A 6 | grep % | 
> cut -d " " -f 6) 
> if [ -z $mute] 
> then 
>         echo "[M]" 
> else 
>        echo "[$volume]" 
> fi 
>
> exit 0
>
> On Sunday, May 16, 2021 at 12:36:40 PM UTC+2 Fabien-Bernard wrote:
>
>> Ok, so the percent sign is already there, you are just missing the 
>> brackets.
>> By adding them around the volume variable in the echo command it should 
>> be good.
>>
>>
>> Le 16/05/2021 à 12:17, Seph IZ a écrit :
>>
>> to this script : 
>>
>> #!/bin/bash 
>> volume=$(pactl list sinks | grep "Description: WH-1000XM3" -A 6 | grep % 
>> | cut -d " " -f 6) 
>> echo "$volume" 
>> exit 0
>>
>>
>> I have the following result : 
>>
>> 35%
>> On Sunday, May 16, 2021 at 11:55:25 AM UTC+2 Fabien-Bernard wrote:
>>
>>> I might have been wrong with my guess on the result of the command.
>>>
>>> What is the exact output of your command in the terminal?
>>>
>>>
>>> Le 16/05/2021 à 11:11, Seph IZ a écrit :
>>>
>>> Hello Fabien,
>>>
>>> I tried your solution, As a result the plugin print "M" I guess 
>>> something is wrong M must be interpreted as Muted.
>>>
>>> On Friday, May 14, 2021 at 2:50:09 PM UTC+2 Fabien-Bernard wrote:
>>>
>>>> Hello,
>>>>
>>>> Have you tried to put your command in an executable script that mimic 
>>>> the output of amixer?
>>>>
>>>> Something like :
>>>>
>>>> *#!/bin/bash*
>>>>
>>>> *my_volume=$(pactl list sinks | grep "Description: WH-1000XM3" -A 6 | 
>>>> grep % | cut -d " " -f 6)*
>>>>
>>>> *echo "["$my_volume"%]"*
>>>>
>>>> *exit 0*
>>>>
>>>> I don't know the output of pactl, so it's just a guess that you only 
>>>> get a number with your command.
>>>>
>>>> Then you just have to replace your command by the script in the 
>>>> get_volume_command assignment of the widget :
>>>>
>>>> *get_volume_command = '/path/to/your_script.bash'*
>>>>
>>>>
>>>> Le 11/05/2021 à 10:15, Seph IZ a écrit :
>>>>
>>>> Hi,
>>>>
>>>> I'm using a bluetooth headset and try to get the volume with Volume 
>>>> widget.
>>>> amixer seems not compatible with bluetooth headset.
>>>>
>>>> Therefore I'm trying to get the volume with pactl piped to different 
>>>> commands : 
>>>>
>>>> pactl list sinks | grep "Description: WH-1000XM3" -A 6 | grep % | cut 
>>>> -d " " -f 6 
>>>>
>>>> This command run in the terminal will success to get the volume of my 
>>>> headset.
>>>> I try then to use this command in the widget : 
>>>>
>>>>
>>>> widget.Volume(   
>>>>  foreground = colors[9],   
>>>> background = colors[0],   
>>>> padding = 5,   
>>>> get_volume_command = 'pactl list sinks | grep "Description: WH-1000XM3" 
>>>> -A 6 | grep % | cut -d " " -f 6'   
>>>> ),
>>>>
>>>> Unfortunately it doesn't works.
>>>> Do you have a solution to get the volume of my bluetooth headset ?
>>>>
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "qtile-dev" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email protected].
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/qtile-dev/6c176ccd-951e-4958-9158-f66d6a881707n%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/qtile-dev/6c176ccd-951e-4958-9158-f66d6a881707n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "qtile-dev" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to [email protected].
>>>
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/qtile-dev/6cb70f6f-664f-493c-ad6f-c69e053eb50fn%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/qtile-dev/6cb70f6f-664f-493c-ad6f-c69e053eb50fn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "qtile-dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>>
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/qtile-dev/83ca12a8-b802-440e-8567-ef2fffa94091n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/qtile-dev/83ca12a8-b802-440e-8567-ef2fffa94091n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"qtile-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qtile-dev/3e2cc60f-c114-44b6-91ce-7b8d73e7b4cbn%40googlegroups.com.

Reply via email to