(Solved) Volumettf behaviour (vol icon disappears when on bluetooth)

Is it normal behaviour :

  • When i activate bluetooth (headphone) or when i start let say an equalizer like Jamesdsp, the unicode icon (volumettf) disappears.
  • when i exit bluetooth or equalizer, the unicode appears again.

When i use just a normal gtk icon, the icon stays.
I created a toggle script to switch between unicode and gtk icon theme.

SOMETIMES: Play video twice to see whats happening. Video does not start from beginning or so…

EDIT:
ps: I played with the volume icon (ttf) as you can see. (dots).
The same happens with the original volumettf script for tint2.

Hi @muzqs

Can you check if other tint2 executors will work in your case?
I found two.

Hi @napcok ,

UPDATED SCRIPT: function mute-icon should work now.

Finaly this script works for me. Using pipewire.

I discoverd that on a new installed mabox system, i encounter the same issue.

ISSUE: Volumettf Icon goes to mute when activate bluetooth / jamedsp / etc. Sound stay’s on.

I have been puzzeling a lot. With pulseaudio and pipewire…

Because i prefer pipewire, i played/searched for a solution using wireplumber (wpctl).

~/.config/tint2/scripts/volumettf

#!/bin/bash
# Tint2 volume executor with ttf icons

muted=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | grep -F "[MUTED]")
vol=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print $2}' | cut -d'.' -f2)

if [[ -n "$muted" ]]; then
        # Show mute icon if muted
        echo "婢<sup><span size='xx-small'> 0%</span></sup>"
    else  
    # If not muted, check the volume level and display the corresponding icon
    if [[ $vol -ge 80 ]]; then
        echo "墳<sup><span size='xx-small'> $vol%</span></sup>"
    elif [[ $vol -ge 70 ]]; then
        echo "墳<sup><span size='xx-small'> $vol%</span></sup>"
    elif [[ $vol -ge 60 ]]; then
        echo "奔<sup><span size='xx-small'> $vol%</span></sup>"
    elif [[ $vol -ge 50 ]]; then
        echo "奔<sup><span size='xx-small'> $vol%</span></sup>"
    elif [[ $vol -ge 30 ]]; then
        echo "奔<sup><span size='xx-small'> $vol%</span></sup>"
    elif [[ $vol -ge 10 ]]; then
        echo "奄<sup><span size='xx-small'> $vol%</span></sup>"
    elif [[ $vol -ge 0 ]]; then
        echo "婢<sup><span size='xx-small'> $vol%</span></sup>"
    else
        # Fallback if volume is somehow outside expected ranges
        echo "奄<sup><span size='xx-small'> 0%</span></sup>"
    fi
fi

I can now run bluetooth (headset) and/or jamesdsp without the volumettf icon goes on mute .

Controling click tint2

execp_mclick_command = wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle
execp_uwheel_command = wpctl set-volume @DEFAULT_SINK@ .05+
execp_dwheel_command = wpctl set-volume @DEFAULT_SINK@ .05-

:bird:

1 Like

To zero and click mute : mute icon shows now.

:bird:

Hi guys.

While analyzing @muzqs solution I realized there is a scenario where you can have more than 100% volume. (my system, for example, gives up to 150% [meaning 1.50 decimal]). Then, I came up with this follow up:

Edit: fixed in order to detect the muted case. Thank you @muzqs :sunglasses:

#!/bin/bash

vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@ \
       | awk '{if (NF==3) {print "00"} else {split($2,a,"."); if (a[1] != 1) {print a[2]} else {print a[1]a[2]}}}')"

case $vol in
   00                ) vol_icon="婢" ;; # cero volume or muted
   0[1-9]|[1-2][0-9] ) vol_icon="奄" ;; # 01-29
   [3-6][0-9]        ) vol_icon="奔" ;; # 30-69
   *                 ) vol_icon="墳" ;; # any other (70+) is max volume
esac
echo "${vol_icon}<sup><span size='xx-small'> $vol%</span></sup>"
1 Like

I did’t realize it too that it can be more than 100% .

Will have a look later at your script. :slight_smile:

A quick test.

  • When mute no mute icon is shown.
  • Volume still goes higher than 100%.
  • I like the simplicitie

:bird:

1 Like

I found the MUTED case detail. Fixing… :nerd_face:

Done. Try again please. :grin:

You were right. You can have X volume and still being mute. My first approach was just moving the volume slider but not muting the output.

The change was to count Fields (NF variable) inside AWK; only when muted has a value of 3. I did it on purpose in order to avoid a language depending solution.

1 Like

Its quit a chalange to find a solution for over 100% loudeness with wpctl.

Reading different posts around the net.
Cannot find a solution against over 100% volume yet.

  • I tested it how high i could get with volume. My amp volume very low.
    It feels not right to do and it isn’t, but still it goes controled in little steps.

For me the main issue was that the icon went on mute when i ran bluetooth audio. Volume icon didn’t showing other volume %.
With wpctl the icon stays.
I suspect how the output is given when more than one sink running.

Using pactl - 2 versions

version 1 - Default audio sink on when mute is off .

output mute status

Mute : no

$ no

Volume icon shown fine.

version 2 - output mute off status with bluetooth on.

output mute status 2 sinks running

Mute : no  
Mute : no 

$ no
$ no

Volume icon not shown.

It gives more then one no.

I am quessing the script can only handle one output as result.

For now i am fine, i think, overcoming the volume overkill thing.

  • It get’s the right value for mute to manage icons.
    Independed how many sinks running.
  • I can run bluetooth or/and jamesdsp without icon issues.

For the volumettf icon management.
Iam trying to stay close with the original.
And i use another volume icon.
This has about 8 different icons.

if [[ $vol -ge 80 ]]; then
            echo "⣟<sup><span size='xx-small'> $vol%</span></sup>"
        elif [[ $vol -ge 70 ]]; then
            echo "⣏<sup><span size='xx-small'> $vol%</span></sup>"
        elif [[ $vol -ge 60 ]]; then
            echo "⣇<sup><span size='xx-small'> $vol%</span></sup>"
        elif [[ $vol -ge 50 ]]; then
            echo "⣃<sup><span size='xx-small'> $vol%</span></sup>"
        elif [[ $vol -ge 30 ]]; then
            echo "⣂<sup><span size='xx-small'> $vol%</span></sup>"
        elif [[ $vol -ge 10 ]]; then
            echo "⣀<sup><span size='xx-small'> $vol%</span></sup>"
        elif [[ $vol -ge 0 ]]; then
            echo "X<sup><span size='xx-small'> $vol%</span></sup>"
        else

:bird:

1 Like

@M0nst3r … FYI : This is what i use as volumettf script.

#!/bin/bash
# Display volume with Icon (gtk themes) or Unicode.

# Config file for icon theme name
CONFIG_FILE="$HOME/.config/mabox/tint2_vol_theme.conf"

if [ ! -f "$CONFIG_FILE" ]; then
    cat <<EOF > "${CONFIG_FILE}"
# Edit volumettf icon theme: works with themes from share/icons or .icons.
ICON_THEME=Papirus-Dark
FONT_SIZE=xx-small
# Foreground
CLR1=red
CLR2=yellow
CLR3=grey
# Background
CLRBG1=yellow
CLRBG2=black
CLRBG3=black
#################################################################################################################
### TINT2RC - volumettf-EXECUTER - NEEDS TO HAVE THE NAME : execp_name = TTFVOL   ### Otherwise it won't work ###
#################################################################################################################
# xx-small
# x-small
# small
# medium
### ANSI escape codes for color output:
# Black
# Red	
# Green	
# Brown 	
# Blue    	
# Purple	
# Cyan	
# Light Gray
### Themes that should work:
# Papirus
# Papirus-Dark
# Papirus-Light
# Buuf
# buuf-nestort
# Gruvbox-Material-Dark
# Adwaita
# Tango
# tango-icon-theme-extras
# Numix
EOF
fi

# Read the icon theme from the config file
source "$CONFIG_FILE"

# Function to find the icon file
find_icon() {
    local icon="$1"
    local paths=(
        "status/$icon.png"
        "status/$icon.svg"
        "status/24/$icon.svg"
        "actions/scalable/$icon.svg"
        "status/symbolic/$icon-symbolic.svg"
        "actions/24/$icon.svg"
        "scalable/status/$icon-symbolic.svg"
        "scalable/status/$icon.svg"
        "symbolic/status/$icon-symbolic.svg"
        "24/status/$icon.svg"
        "24x24/status/$icon.png"
        "24x24/status/$icon.svg"
        "base/22x22/status/$icon.png"
    )

    for path in "${paths[@]}"; do
        local full_path="$icon_path/$path"
        if [ -e "$full_path" ]; then
            echo "$full_path"
            return
        fi
    done

    echo "Icon not found."
}

# Check path to the icon theme directory
if [ -d "/usr/share/icons/$ICON_THEME" ]; then
    icon_path="/usr/share/icons/$ICON_THEME"
elif [ -d "$HOME/.icons/$ICON_THEME" ]; then
    icon_path="$HOME/.icons/$ICON_THEME"
else
    echo "Icon Theme Path not found."
    exit 1
fi

# Function to display volume and mute icons
display_volume() {
    vol=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print $2}' | cut -d'.' -f2)
    muted=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | grep -F "[MUTED]")


    if [[ -n "$muted" ]]; then
        # Show mute icon if muted
        echo "X<sup><span size='$FONT_SIZE'> 0%</span></sup>"
    else
    # Proceed with normal volume display logic
    vol=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print $2}' | cut -d'.' -f2)
    
        # Show appropriate icon based on volume percentage
        if [[ $vol -ge 80 ]]; then
            echo "⣟<sup><span size='$FONT_SIZE'> $vol%</span></sup>"
        elif [[ $vol -ge 70 ]]; then
            echo "⣏<sup><span size='$FONT_SIZE'> $vol%</span></sup>"
        elif [[ $vol -ge 60 ]]; then
            echo "⣇<sup><span size='$FONT_SIZE'> $vol%</span></sup>"
        elif [[ $vol -ge 50 ]]; then
            echo "⣃<sup><span size='$FONT_SIZE'> $vol%</span></sup>"
        elif [[ $vol -ge 30 ]]; then
            echo "⣂<sup><span size='$FONT_SIZE'> $vol%</span></sup>"
        elif [[ $vol -ge 10 ]]; then
            echo "⣀<sup><span size='$FONT_SIZE'> $vol%</span></sup>"
        elif [[ $vol -ge 0 ]]; then
            echo "X<sup><span size='$FONT_SIZE'> $vol%</span></sup>"
        else
            # Fallback if volume is somehow outside expected ranges
            echo "奄<sup><span size='$FONT_SIZE'> 0%</span></sup>"
        fi
    fi
}

# Check the current icon state
if [[ -e "$HOME/.temp/toggle_icon_state" && $(cat "$HOME/.temp/toggle_icon_state") == "icon" ]]; then
    # Display theme-based icon
    display_volume
else
    # Text-based output iffor icon is not enabled
    display_volume
fi

I use a toggle script to be able to toggle between gtk/unicode.

:bird:

Update : pactl solution.

muted=$(pactl list sinks | awk '/State: RUNNING/,/Mute/ { if (/Mute/) print $2 }')


if [[ "$muted" == "yes" ]];

Back to pactl : checking only the running sink for mute. One output.

With this change the volume icon works for me like it should.