refactor: extract ignored player sources to array

This commit is contained in:
2024-08-23 10:03:22 -04:00
parent 25143ee857
commit a6e251fe2a
+16 -1
View File
@@ -3,6 +3,21 @@
# Separator variable # Separator variable
separator="␟" separator="␟"
# Ignored player sources for music
ignored_players=(
"chromium"
"firefox"
"kdeconnect"
"haruna"
"plasma-browser-integration"
)
# Convert array to a comma-separated string with no spaces
ignored_sources=$(
IFS=,
echo "${ignored_players[*]}"
)
# Lock file path # Lock file path
lock_file="/tmp/music_wakatime_update.lock" lock_file="/tmp/music_wakatime_update.lock"
@@ -23,7 +38,7 @@ trap cleanup EXIT
# Update the music cache file every second # Update the music cache file every second
while true; do while true; do
playerctl --ignore-player firefox,kdeconnect,haruna,plasma-browser-integration metadata --format "{{ artist }}${separator}{{ title }}${separator}{{ album }}${separator}{{ status }}${separator}{{ volume }}${separator}{{ loop }}${separator}{{ shuffle }}" >~/.cache/music_cache.txt playerctl --ignore-player ${ignored_sources} metadata --format "{{ artist }}${separator}{{ title }}${separator}{{ album }}${separator}{{ status }}${separator}{{ volume }}${separator}{{ loop }}${separator}{{ shuffle }}" >~/.cache/music_cache.txt
sleep 1 sleep 1
done & # Run this loop in the background done & # Run this loop in the background