Add sound to waybar on FreeBSD.
This commit is contained in:
parent
0a49fc16b6
commit
d8049e932d
@ -2,29 +2,29 @@
|
||||
vars:
|
||||
ansible_become: True
|
||||
roles:
|
||||
# - sudo
|
||||
- sudo
|
||||
- users
|
||||
# - package_manager
|
||||
# - zrepl
|
||||
# - zsh
|
||||
# - network
|
||||
# - sshd
|
||||
# - base
|
||||
# - firewall
|
||||
# - cpu
|
||||
# - ntp
|
||||
# - build
|
||||
# - graphics
|
||||
# - gpg
|
||||
# - fonts
|
||||
# - alacritty
|
||||
# - sway
|
||||
# - emacs
|
||||
# - firefox
|
||||
# - devfs
|
||||
# - ssh_client
|
||||
- package_manager
|
||||
- zrepl
|
||||
- zsh
|
||||
- network
|
||||
- sshd
|
||||
- base
|
||||
- firewall
|
||||
- cpu
|
||||
- ntp
|
||||
- build
|
||||
- graphics
|
||||
- gpg
|
||||
- fonts
|
||||
- alacritty
|
||||
- sway
|
||||
- emacs
|
||||
- firefox
|
||||
- devfs
|
||||
- ssh_client
|
||||
- jail
|
||||
# - fuse
|
||||
# - autofs
|
||||
# - exfat
|
||||
- fuse
|
||||
- autofs
|
||||
- exfat
|
||||
- bhyve
|
||||
|
@ -53,6 +53,7 @@
|
||||
#custom-available_memory,
|
||||
#custom-battery,
|
||||
#custom-clock,
|
||||
#custom-sound,
|
||||
#idle_inhibitor,
|
||||
#memory,
|
||||
#mode,
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
// "height": 10, // Waybar height (to be removed for auto height)
|
||||
"modules-left": ["sway/workspaces", "sway/mode"],
|
||||
"modules-right": ["custom/available_memory", "custom/battery", "idle_inhibitor", "custom/clock", "tray"],
|
||||
"modules-right": ["custom/sound", "custom/available_memory", "custom/battery", "idle_inhibitor", "custom/clock", "tray"],
|
||||
"sway/workspaces": {
|
||||
"disable-scroll": true
|
||||
},
|
||||
@ -33,6 +33,10 @@
|
||||
"exec": "waybar_custom_available_memory",
|
||||
"return-type": "json",
|
||||
"restart-interval": 30
|
||||
},
|
||||
"custom/sound": {
|
||||
"exec": "waybar_custom_sound",
|
||||
"return-type": "json",
|
||||
"restart-interval": 30
|
||||
}
|
||||
|
||||
}
|
||||
|
36
ansible/roles/sway/files/waybar_sound_freebsd.bash
Normal file
36
ansible/roles/sway/files/waybar_sound_freebsd.bash
Normal file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Read volume status in FreeBSD
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
SLEEP_INTERVAL=${SLEEP_INTERVAL:-30}
|
||||
|
||||
while true; do
|
||||
current_vol_mixer=$(mixer -S vol)
|
||||
vol_left=$(cut -d ':' -f 2 <<<"$current_vol_mixer")
|
||||
vol_right=$(cut -d ':' -f 3 <<<"$current_vol_mixer")
|
||||
avg_vol=$(((vol_left + vol_right) / 2))
|
||||
tooltip="<tt>$(mixer)</tt>"
|
||||
class=""
|
||||
icon=""
|
||||
|
||||
if [ $avg_vol -eq 0 ]; then
|
||||
icon="🔇"
|
||||
elif [ $avg_vol -le 50 ]; then
|
||||
icon="🔉"
|
||||
else
|
||||
icon="🔊"
|
||||
fi
|
||||
|
||||
jq --unbuffered --compact-output <<EOF
|
||||
{
|
||||
"text":"${avg_vol}% ${icon}",
|
||||
"tooltip":"${tooltip//$'\n'/\\n}",
|
||||
"percentage":${avg_vol},
|
||||
"class":"${class}"
|
||||
}
|
||||
EOF
|
||||
sleep $SLEEP_INTERVAL
|
||||
done
|
@ -51,3 +51,5 @@
|
||||
dest: /usr/local/bin/waybar_custom_battery
|
||||
- src: waybar_available_memory_freebsd.bash
|
||||
dest: /usr/local/bin/waybar_custom_available_memory
|
||||
- src: waybar_sound_freebsd.bash
|
||||
dest: /usr/local/bin/waybar_custom_sound
|
||||
|
Loading…
Reference in New Issue
Block a user