mirror of
https://git.adityakumar.xyz/dwmbar.git
synced 2024-11-21 18:12:53 +00:00
Added volume module
This commit is contained in:
parent
032d16e9ae
commit
bb788dddf6
4 changed files with 43 additions and 12 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
# Prints out the number of pacman updates (Arch Linux)
|
# Prints out the number of pacman updates (Arch Linux)
|
||||||
# Requires an internet connection
|
# Requires an internet connection
|
||||||
|
# Depends on yay and checkupdates (pacman-contrib)
|
||||||
|
|
||||||
PREFIX=' Updates:'
|
PREFIX=' Updates:'
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,40 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Prints out battery percentage
|
||||||
|
|
||||||
|
CHARGING_ICON=''
|
||||||
|
WARNING_ICON=''
|
||||||
|
BATTERY_FULL_ICON=''
|
||||||
|
BATTERY_2_ICON=''
|
||||||
|
BATTERY_3_ICON=''
|
||||||
|
BATTERY_4_ICON=''
|
||||||
|
|
||||||
get_battery()
|
get_battery()
|
||||||
{
|
{
|
||||||
if [ -d /sys/class/power_supply/BAT? ]; then
|
if [ -d /sys/class/power_supply/BAT? ]; then
|
||||||
ac_adapter=$(cat /sys/class/power_supply/BAT?/status)
|
ac_adapter=$(cat /sys/class/power_supply/BAT?/status)
|
||||||
if [ "$ac_adapter" == "Charging" ]; then
|
if [ "$ac_adapter" == "Charging" ]; then
|
||||||
echo ""
|
echo "$CHARGING_ICON"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Will show all batteries with approximate icon for remaining power.
|
# Will show all batteries with approximate icon for remaining power.
|
||||||
for x in /sys/class/power_supply/BAT?/capacity;
|
for x in /sys/class/power_supply/BAT?/capacity;
|
||||||
do
|
do
|
||||||
case "$(cat $x)" in
|
case "$(cat $x)" in
|
||||||
100) echo "" ;;
|
100) echo "$BATTERY_FULL_ICON" ;;
|
||||||
9[0-9]) echo " $(cat $x)%" ;;
|
9[0-9]) echo "$BATTERY_FULL_ICON $(cat $x)%" ;;
|
||||||
8[0-9]|7[0-9]) echo " $(cat $x)%" ;;
|
8[0-9]|7[0-9]) echo "$BATTERY_2_ICON $(cat $x)%" ;;
|
||||||
6[0-9]|5[0-9]) echo " $(cat $x)%" ;;
|
6[0-9]|5[0-9]) echo "$BATTERY_3_ICON $(cat $x)%" ;;
|
||||||
4[0-9]|3[0-9]) echo " $(cat $x)%" ;;
|
4[0-9]|3[0-9]) echo "$BATTERY_4_ICON $(cat $x)%" ;;
|
||||||
2[0-9]|1[0-9]) if [ "$ac_adapter" == "Charging" ]; then
|
2[0-9]|1[0-9]) if [ "$ac_adapter" == "Charging" ]; then
|
||||||
echo " $(cat $x)%"
|
echo "$BATTERY_4_ICON $(cat $x)%"
|
||||||
else
|
else
|
||||||
echo " $(cat $x)%"
|
echo "$WARNING_ICON $BATTERY_4_ICON $(cat $x)%"
|
||||||
fi ;;
|
fi ;;
|
||||||
[0-9]) if [ "$ac_adapter" == "Charging" ]; then
|
[0-9]) if [ "$ac_adapter" == "Charging" ]; then
|
||||||
echo " $(cat $x)%"
|
echo "$BATTERY_4_ICON $(cat $x)%"
|
||||||
else
|
else
|
||||||
echo " $(cat $x)%"
|
echo "$WARNING_ICON $BATTERY_4_ICON $(cat $x)%"
|
||||||
fi ;;
|
fi ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
|
@ -11,10 +11,10 @@ get_bluetooth()
|
||||||
|
|
||||||
if [ "$status" == "active" ]
|
if [ "$status" == "active" ]
|
||||||
then
|
then
|
||||||
echo ""
|
echo "$BLUETOOTH_ON_ICON"
|
||||||
else
|
else
|
||||||
:
|
:
|
||||||
#echo ""
|
#echo "$BLUETOOTH_OFF_ICON"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
21
modules/volume
Executable file
21
modules/volume
Executable file
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Prints out the volume percentage
|
||||||
|
|
||||||
|
VOLUME_ON_ICON=''
|
||||||
|
VOLUME_MUTED_ICON=''
|
||||||
|
|
||||||
|
get_volume(){
|
||||||
|
active_sink=$(pacmd list-sinks | awk '/* index:/{print $3}')
|
||||||
|
curStatus=$(pacmd list-sinks | grep -A 15 "index: $active_sink$" | awk '/muted/{ print $2}')
|
||||||
|
volume=$(pacmd list-sinks | grep -A 15 "index: $active_sink$" | grep 'volume:' | grep -E -v 'base volume:' | awk -F : '{print $3}' | grep -o -P '.{0,3}%'| sed s/.$// | tr -d ' ')
|
||||||
|
|
||||||
|
if [ "${curStatus}" = 'yes' ]
|
||||||
|
then
|
||||||
|
echo "$VOLUME_MUTED_ICON $volume%"
|
||||||
|
else
|
||||||
|
echo "$VOLUME_ON_ICON $volume%"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
get_volume
|
Loading…
Reference in a new issue