mirror of
https://github.com/szymon-jozef/amazing-dotfiles.git
synced 2026-09-07 20:20:43 +02:00
move stuff to nix lol
This commit is contained in:
34
dotfiles/waybar/scripts/mediaplayer.sh
Executable file
34
dotfiles/waybar/scripts/mediaplayer.sh
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Użycie: $0 <nazwa_odtwarzacza>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
player="$1"
|
||||
playerctl -p "$player" metadata --format "{{status}} {{artist}} - {{title}}" --follow | while read -r line; do
|
||||
current_status=$(playerctl --player="$player" status 2>/dev/null)
|
||||
case "$current_status" in
|
||||
"Playing")
|
||||
text=""
|
||||
;;
|
||||
"Paused")
|
||||
text=""
|
||||
;;
|
||||
*)
|
||||
text=""
|
||||
;;
|
||||
esac
|
||||
tooltip=$(playerctl --player="$player" metadata --format "{{artist}} - {{title}}" 2>/dev/null)
|
||||
|
||||
tooltip=$(echo "$tooltip" | jq -R .)
|
||||
|
||||
json_text="{\"text\": \"$text\", \"tooltip\": $tooltip }"
|
||||
echo "$json_text"
|
||||
|
||||
if [[ -n "$text" ]]; then
|
||||
pkill -SIGRTMIN+1 waybar
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user