Configure spotifyd waybar

This commit is contained in:
ltadeu6 2026-04-19 12:50:55 -03:00
parent 5a00da9239
commit c2e851fbcf
5 changed files with 80 additions and 21 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
__pycache__/ __pycache__/
*.pyc *.pyc
.codex/

View file

@ -9,7 +9,7 @@
"modules-left": ["hyprland/workspaces", "cava"], "modules-left": ["hyprland/workspaces", "cava"],
"modules-center": ["custom/ac", "clock"], "modules-center": ["custom/ac", "clock"],
"modules-right": [ "modules-right": [
"mpris", "custom/spotify",
"network", "network",
"bluetooth", "bluetooth",
"pulseaudio", "pulseaudio",
@ -152,23 +152,16 @@
"scroll-step": 5, "scroll-step": 5,
"format-icons": ["󰃛", "󰃜", "󰃝", "󰃞", "󰃟", "󰃠"] "format-icons": ["󰃛", "󰃜", "󰃝", "󰃞", "󰃟", "󰃠"]
}, },
"mpris": { "custom/spotify": {
"format": "{player_icon} {dynamic}", "exec": "~/.config/waybar/spotify_status.sh",
"format-paused": "{status_icon} {dynamic}", "interval": 2,
"tooltip-format": "{status_icon} {dynamic}", "format": "{}",
"player-icons": { "return-type": "text",
"default": "", "on-click": "playerctl -p $(playerctl -l | rg '^spotifyd\\.instance' -m1) play-pause",
"mpv": "🎵" "on-click-middle": "playerctl -p $(playerctl -l | rg '^spotifyd\\.instance' -m1) previous",
}, "on-click-right": "playerctl -p $(playerctl -l | rg '^spotifyd\\.instance' -m1) next",
"status-icons": { "on-scroll-up": "playerctl -p $(playerctl -l | rg '^spotifyd\\.instance' -m1) volume 0.1+",
"paused": "" "on-scroll-down": "playerctl -p $(playerctl -l | rg '^spotifyd\\.instance' -m1) volume 0.1-"
},
"dynamic-len": 40,
"dynamic-order": ["title", "artist", "album"],
"player": "spotify",
"ignored-players": ["firefox*"],
"on-scroll-up": "playerctl -i firefox volume 0.1+",
"on-scroll-down": "playerctl -i firefox volume 0.1-"
}, },
"battery": { "battery": {
"format": "{icon} ", "format": "{icon} ",

View file

@ -0,0 +1,26 @@
#!/usr/bin/env sh
player="$(playerctl -l 2>/dev/null | rg '^spotifyd\.instance' -m1 || true)"
if [ -z "$player" ]; then
exit 0
fi
status="$(playerctl -p "$player" status 2>/dev/null || true)"
text="$(playerctl -p "$player" metadata --format '{{artist}} - {{title}}' 2>/dev/null || true)"
if [ -z "$text" ]; then
exit 0
fi
case "$status" in
Playing)
printf ' %s\n' "$text"
;;
Paused)
printf ' %s\n' "$text"
;;
*)
exit 0
;;
esac

View file

@ -42,7 +42,7 @@
#custom-exit, #custom-exit,
#custom-sleep, #custom-sleep,
#custom-poweroff, #custom-poweroff,
#mpris, #custom-spotify,
#battery, #battery,
#pulseaudio, #pulseaudio,
#bluetooth, #bluetooth,
@ -50,7 +50,7 @@
#network { #network {
padding: 0 1rem; padding: 0 1rem;
} }
#mpris { #custom-spotify {
font-family: "GohuFont 11 Nerd Font Mono"; font-family: "GohuFont 11 Nerd Font Mono";
font-weight: 700; font-weight: 700;
letter-spacing: 1.5px; letter-spacing: 1.5px;
@ -71,7 +71,7 @@
} }
#custom-exit, #custom-exit,
#mpris, #custom-spotify,
#pulseaudio, #pulseaudio,
#backlight { #backlight {
color: @yellow; color: @yellow;

View file

@ -311,6 +311,37 @@
source = ../configs/waybar/air_control.py; source = ../configs/waybar/air_control.py;
executable = true; executable = true;
}; };
".config/waybar/spotify_status.sh" = {
executable = true;
text = ''
#!/usr/bin/env sh
player="$(playerctl -l 2>/dev/null | rg '^spotifyd\.instance' -m1 || true)"
if [ -z "$player" ]; then
exit 0
fi
status="$(playerctl -p "$player" status 2>/dev/null || true)"
text="$(playerctl -p "$player" metadata --format '{{artist}} - {{title}}' 2>/dev/null || true)"
if [ -z "$text" ]; then
exit 0
fi
case "$status" in
Playing)
printf ' %s\n' "$text"
;;
Paused)
printf ' %s\n' "$text"
;;
*)
exit 0
;;
esac
'';
};
".config/waybar/launch.sh" = { ".config/waybar/launch.sh" = {
source = ../configs/waybar/launch.sh; source = ../configs/waybar/launch.sh;
executable = true; executable = true;
@ -371,6 +402,14 @@
fi fi
''; '';
services.spotifyd = {
enable = true;
settings.global = {
backend = "pulseaudio";
use_mpris = true;
};
};
systemd.user.services.openclaw-gateway = { systemd.user.services.openclaw-gateway = {
Service.EnvironmentFile = Service.EnvironmentFile =
"${config.home.homeDirectory}/.config/openclaw/gateway.env"; "${config.home.homeDirectory}/.config/openclaw/gateway.env";