feat: adds ncspot module for waybar

This commit is contained in:
Ahwx 2025-05-05 23:08:52 +02:00
parent 1d755b2d52
commit 1dc166065b
2 changed files with 472 additions and 433 deletions

View file

@ -29,6 +29,7 @@
"modules-left": [ "modules-left": [
"privacy", "privacy",
"group/network", "group/network",
"custom/spotify",
"tray", "tray",
], ],
@ -91,6 +92,14 @@
"tooltip-format-disconnected": "Disconnected" "tooltip-format-disconnected": "Disconnected"
}, },
"custom/spotify": {
"interval": 1,
"return-type": "json",
"exec": "~/.local/bin/waybar-music",
"on-click": "playerctl play-pause",
"escape": true
},
// "custom/vpn": { // "custom/vpn": {
// "format": "{icon} VPN <span color='#aaaaaa'>{}</span>", // "format": "{icon} VPN <span color='#aaaaaa'>{}</span>",
// "format-icons": { // "format-icons": {
@ -464,6 +473,11 @@
background: #f9409d; background: #f9409d;
} }
#custom-spotify {
color: #ffffff;
padding-right: 10px;
}
''; '';
}; };
}; };

View file

@ -152,10 +152,35 @@
echo $(( (24 - $(date +%H)) * 60 - $(date +%M) )) echo $(( (24 - $(date +%H)) * 60 - $(date +%M) ))
''; '';
}; };
"/home/${username}/.local/bin/waybar-music" = {
executable = true;
text = ''
#!/usr/bin/env bash
class=$(playerctl metadata --player=ncspot --format '{{lc(status)}}')
if [[ $class == "playing" ]]; then
info=$(playerctl metadata --player=ncspot --format '{{artist}} - {{title}}')
if [[ $\{#info} > 40 ]]; then
info=$(echo $info | cut -c1-40)"..."
fi
text="$info"
elif [[ $class == "paused" ]]; then
info=$(playerctl metadata --player=ncspot --format '{{artist}} - {{title}}')
if [[ $\{#info} > 40 ]]; then
info=$(echo $info | cut -c1-40)"..."
fi
text=" $info"
elif [[ $class == "stopped" ]]; then
text=""
fi
echo -e "{\"text\":\""$text"\", \"class\":\""$class"\"}"
'';
};
}; };
home.packages = with pkgs; [ home.packages = with pkgs; [
wf-recorder wf-recorder
bemenu bemenu
]; ];
} }