Add sound to waybar on linux.
This commit is contained in:
parent
d8049e932d
commit
161b7c1354
37
ansible/roles/sway/files/waybar_sound_linux.bash
Normal file
37
ansible/roles/sway/files/waybar_sound_linux.bash
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#!/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_decimal=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | sed 's/Volume: //g')
|
||||||
|
current_vol_percent=$(bc -s <<<"$current_vol_decimal * 100")
|
||||||
|
current_vol_percent=${current_vol_percent%.*} # Remove decimal
|
||||||
|
tooltip="<tt>$(wpctl status)</tt>"
|
||||||
|
tooltip=${tooltip//$'\n'/\\n}
|
||||||
|
tooltip=${tooltip//$'\t'/\\t}
|
||||||
|
class=""
|
||||||
|
icon=""
|
||||||
|
|
||||||
|
if [ $current_vol_percent -eq 0 ]; then
|
||||||
|
icon="🔇"
|
||||||
|
elif [ $current_vol_percent -le 50 ]; then
|
||||||
|
icon="🔉"
|
||||||
|
else
|
||||||
|
icon="🔊"
|
||||||
|
fi
|
||||||
|
|
||||||
|
jq --unbuffered --compact-output <<EOF
|
||||||
|
{
|
||||||
|
"text":"${current_vol_percent}% ${icon}",
|
||||||
|
"tooltip":"${tooltip}",
|
||||||
|
"percentage":${current_vol_percent},
|
||||||
|
"class":"${class}"
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
sleep $SLEEP_INTERVAL
|
||||||
|
done
|
@ -1,3 +1,9 @@
|
|||||||
|
- name: Install packages
|
||||||
|
package:
|
||||||
|
name:
|
||||||
|
- bc # For waybar sound script
|
||||||
|
state: present
|
||||||
|
|
||||||
- name: Install scripts
|
- name: Install scripts
|
||||||
copy:
|
copy:
|
||||||
src: "files/{{ item.src }}"
|
src: "files/{{ item.src }}"
|
||||||
@ -12,3 +18,5 @@
|
|||||||
dest: /usr/local/bin/waybar_custom_battery
|
dest: /usr/local/bin/waybar_custom_battery
|
||||||
- src: waybar_available_memory_linux.bash
|
- src: waybar_available_memory_linux.bash
|
||||||
dest: /usr/local/bin/waybar_custom_available_memory
|
dest: /usr/local/bin/waybar_custom_available_memory
|
||||||
|
- src: waybar_sound_linux.bash
|
||||||
|
dest: /usr/local/bin/waybar_custom_sound
|
||||||
|
Loading…
Reference in New Issue
Block a user