~tardypad/dotfiles

ref: 7dd5e02494e2821ff6b4fd5758a590ef03b5403b dotfiles/packages/i3blocks/scripts/volume -rwxr-xr-x 675 bytes
7dd5e024 — Damien Tardy-Panis add mako package config 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#! /usr/bin/env zsh

VOLUME_INFO=$(
  amixer get Master \
    | grep \
        --extended-regex \
        --max-count 1 \
        --only-matching '\[[0-9]{1,3}%\] \[(on|off)\]' \
)

echo "${VOLUME_INFO}" | grep --quiet 'on'
IS_VOLUME_MUTED=$?

VOLUME_PERCENT=$(
  echo "${VOLUME_INFO}" \
    | sed --regexp-extended 's/\[([0-9]+)%\].*/\1/'
)

if [[ "${VOLUME_PERCENT}" -lt 50 ]]; then
  VOLUME_ICON=''
else
  VOLUME_ICON=''
fi

if [[ "${IS_VOLUME_MUTED}" -eq 1 ]]; then
  echo "<span foreground='#{color/base0A/hex}'></span> Muted"
  echo
  echo '#{color/warning/hex}'
else
  echo "<span foreground='#{color/base0A/hex}'>${VOLUME_ICON}</span> ${VOLUME_PERCENT}%"
fi