diff --git a/.gitignore b/.gitignore index 7a60b85..5a8460d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ __pycache__/ *.pyc +.codex/ diff --git a/configs/waybar/config b/configs/waybar/config index 4e3bdab..7151ca3 100644 --- a/configs/waybar/config +++ b/configs/waybar/config @@ -9,7 +9,7 @@ "modules-left": ["hyprland/workspaces", "cava"], "modules-center": ["custom/ac", "clock"], "modules-right": [ - "mpris", + "custom/spotify", "network", "bluetooth", "pulseaudio", @@ -152,23 +152,16 @@ "scroll-step": 5, "format-icons": ["󰃛", "󰃜", "󰃝", "󰃞", "󰃟", "󰃠"] }, - "mpris": { - "format": "{player_icon} {dynamic}", - "format-paused": "{status_icon} {dynamic}", - "tooltip-format": "{status_icon} {dynamic}", - "player-icons": { - "default": "", - "mpv": "🎵" - }, - "status-icons": { - "paused": "" - }, - "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-" + "custom/spotify": { + "exec": "~/.config/waybar/spotify_status.sh", + "interval": 2, + "format": "{}", + "return-type": "text", + "on-click": "playerctl -p $(playerctl -l | rg '^spotifyd\\.instance' -m1) play-pause", + "on-click-middle": "playerctl -p $(playerctl -l | rg '^spotifyd\\.instance' -m1) previous", + "on-click-right": "playerctl -p $(playerctl -l | rg '^spotifyd\\.instance' -m1) next", + "on-scroll-up": "playerctl -p $(playerctl -l | rg '^spotifyd\\.instance' -m1) volume 0.1+", + "on-scroll-down": "playerctl -p $(playerctl -l | rg '^spotifyd\\.instance' -m1) volume 0.1-" }, "battery": { "format": "{icon} ", diff --git a/configs/waybar/spotify_status.sh b/configs/waybar/spotify_status.sh new file mode 100644 index 0000000..bdfce24 --- /dev/null +++ b/configs/waybar/spotify_status.sh @@ -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 diff --git a/configs/waybar/style.css b/configs/waybar/style.css index 9d3633b..68a1875 100644 --- a/configs/waybar/style.css +++ b/configs/waybar/style.css @@ -42,7 +42,7 @@ #custom-exit, #custom-sleep, #custom-poweroff, -#mpris, +#custom-spotify, #battery, #pulseaudio, #bluetooth, @@ -50,7 +50,7 @@ #network { padding: 0 1rem; } -#mpris { +#custom-spotify { font-family: "GohuFont 11 Nerd Font Mono"; font-weight: 700; letter-spacing: 1.5px; @@ -71,7 +71,7 @@ } #custom-exit, -#mpris, +#custom-spotify, #pulseaudio, #backlight { color: @yellow; diff --git a/home/ltadeu6.nix b/home/ltadeu6.nix index 74442f4..b165ecd 100644 --- a/home/ltadeu6.nix +++ b/home/ltadeu6.nix @@ -311,6 +311,37 @@ source = ../configs/waybar/air_control.py; 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" = { source = ../configs/waybar/launch.sh; executable = true; @@ -371,6 +402,14 @@ fi ''; + services.spotifyd = { + enable = true; + settings.global = { + backend = "pulseaudio"; + use_mpris = true; + }; + }; + systemd.user.services.openclaw-gateway = { Service.EnvironmentFile = "${config.home.homeDirectory}/.config/openclaw/gateway.env";