-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathvolume-icon.sh
executable file
·33 lines (27 loc) · 1.08 KB
/
volume-icon.sh
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
32
33
#!/bin/sh
# This script display an appropriate volume icon according to the volume level
# Authors: Piotr Miller, @natemaia
# e-mail: [email protected]
# Website: http://nwg.pl
# Project: https://github.com/nwg-piotr/tint2-executors
# License: GPL3
# Dependencies: `alsa-utils`
if [[ "$(amixer sget Master | awk -F'[][]' '/Right:|Mono:/ && NF > 1 {print $4}')" = "on" ]]; then
# search for the lines containing 'Right:' or 'Mono:', when more than 1 field exists
# we strip the trailing '%' and round it up with printf "%0.0f" just in case
vol=$(amixer sget Master | awk -F'[][]' '/Right:|Mono:/ && NF > 1 {sub(/%/, ""); printf "%0.0f\n", $2}')
if [[ ${vol} -ge 90 ]]; then
echo ~/tint2-executors/images/vol-full.svg
elif [[ ${vol} -ge 40 ]]; then
echo ~/tint2-executors/images/vol-medium.svg
elif [[ ${vol} -ge 10 ]]; then
echo ~/tint2-executors/images/vol-low.svg
else
echo ~/tint2-executors/images/vol-lowest.svg
fi
if [[ $1 = "-l" ]]; then
echo ${vol}%
fi
else
echo ~/tint2-executors/images/vol-muted.svg
fi