From abecdcec8f3d50755b2c0cdb6b7f9b4d87f8c122 Mon Sep 17 00:00:00 2001 From: Caroline Larimore Date: Sun, 26 May 2024 01:13:27 -0700 Subject: Update music widget data fetching --- assets/SOURCES.md | 6 +++- assets/album_art_placeholder.png | Bin 0 -> 10274 bytes home/eww.nix | 71 ++++++++++++++++++++++++++------------- 3 files changed, 53 insertions(+), 24 deletions(-) create mode 100644 assets/album_art_placeholder.png diff --git a/assets/SOURCES.md b/assets/SOURCES.md index 4abf17f..06e034a 100644 --- a/assets/SOURCES.md +++ b/assets/SOURCES.md @@ -6,5 +6,9 @@ - `shinobu.png`: Kizumonogatari I: Tekketsu (Edited) - `skull.png`: [Akiakane](https://akiakane.net) +## Fastfetch +- `nonon.png`: Kill la Kill (Unknown) +- `ryo.png`: Bocchi the Rock! (Unknown, Edited) + ## Misc -- `nonon.png`: Kill la Kill (Unknown) \ No newline at end of file +- `album_art_placeholder.png`: Me and my legendary artistic talent \ No newline at end of file diff --git a/assets/album_art_placeholder.png b/assets/album_art_placeholder.png new file mode 100644 index 0000000..2cdcbab Binary files /dev/null and b/assets/album_art_placeholder.png differ diff --git a/home/eww.nix b/home/eww.nix index c06dedc..eec2417 100644 --- a/home/eww.nix +++ b/home/eww.nix @@ -13,6 +13,43 @@ ${pkgs.eww}/bin/eww open $@ fi '') + + (writeShellScriptBin "get-album-art"'' + #!/usr/bin/env bash + + OUTFILE=".mpris-art" + + while read -r line; do + if [[ -n $line ]]; then + rm -f ~/$OUTFILE + + cmus_path=$(cmus-remote -Q | grep file | cut -c 6-) + if [[ -n $cmus_path ]]; then + if [[ -f $(dirname "$cmus_path")/cover.jpg ]]; then + cp "$(dirname "$cmus_path")/cover.jpg" ~/$OUTFILE + else + ffmpeg -y -v quiet -i "$cmus_path" -c:v copy -f mjpeg ~/$OUTFILE + fi + else + mpris=$(playerctl --player=cmus,firefox,%any metadata mpris:artUrl) + + if [[ $mpris == data:image* ]]; then + echo $mpris | sed s/.*,//g | base64 --decode > ~/$OUTFILE + elif [[ -n $mpris ]]; then + curl -s -o ~/$OUTFILE $mpris + fi + fi + + if [[ -f ~/$OUTFILE ]]; then + : + else + cp ${../assets/album_art_placeholder.png} ~/$OUTFILE + fi + + echo ~/$OUTFILE + fi + done + '') ]; xdg.configFile."eww/colors.css".text = let c = config.theme.colors; in '' @@ -133,7 +170,7 @@ :height {128 + 16} (image - :path { substring(song-cover, 7, 255) } + :path song-cover :image-width 128 :image-height 128 ) @@ -150,15 +187,15 @@ :valign "center" (label :class "song-title" - :text song-title + :text {song.title} :halign "start" ) (label :class "song-album" - :text song-album + :text {song.album} :halign "start" ) (label :class "song-artist" - :text song-artist + :text {song.artist} :halign "start" ) ) @@ -169,15 +206,15 @@ :valign "end" (button - :onclick `playerctl previous` + :onclick `playerctl --player=cmus,firefox,%any previous` "󰒮" ) (button - :onclick `playerctl play-pause` - { song-status == "Playing" ? "󰏤" : "󰐊" } + :onclick `playerctl --player=cmus,firefox,%any play-pause` + { song.status == "Playing" ? "󰏤" : "󰐊" } ) (button - :onclick `playerctl next` + :onclick `playerctl --player=cmus,firefox,%any next` "󰒭" ) @@ -188,24 +225,12 @@ ) ) - (deflisten song-title - `playerctl -F metadata title` - ) - - (deflisten song-album - `playerctl -F metadata album` - ) - - (deflisten song-artist - `playerctl -F metadata artist` - ) - (deflisten song-cover - `playerctl -F metadata mpris:artUrl` + `playerctl --player=cmus,firefox,%any -F metadata title | get-album-art` ) - (deflisten song-status - `playerctl -F status` + (deflisten song + `playerctl --player=cmus,firefox,%any -F metadata --format='{"title": "{{title}}", "album": "{{album}}", "artist": "{{artist}}", "status": "{{status}}"}'` ) ''; } -- cgit v1.2.3