summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <rrbo@proton.me>2023-01-12 20:54:42 +0100
committerJoe <rrbo@proton.me>2023-01-12 20:54:42 +0100
commit3e5d88ea7ff249f343ef4b16e01954e2cb778bae (patch)
tree52c77f1a9dca4afb8e5652c5b183623eb41db054
parentup (diff)
downloaddotfiles-bsd-3e5d88ea7ff249f343ef4b16e01954e2cb778bae.tar.gz
dotfiles-bsd-3e5d88ea7ff249f343ef4b16e01954e2cb778bae.tar.bz2
dotfiles-bsd-3e5d88ea7ff249f343ef4b16e01954e2cb778bae.tar.xz
dotfiles-bsd-3e5d88ea7ff249f343ef4b16e01954e2cb778bae.tar.zst
dotfiles-bsd-3e5d88ea7ff249f343ef4b16e01954e2cb778bae.zip
up
-rw-r--r--.config/conkyrc6
-rw-r--r--.config/x11/xinitrc2
-rwxr-xr-x.local/bin/conky_cover.sh64
3 files changed, 70 insertions, 2 deletions
diff --git a/.config/conkyrc b/.config/conkyrc
index e36ff3a..53c2b7b 100644
--- a/.config/conkyrc
+++ b/.config/conkyrc
@@ -49,8 +49,10 @@ conky.text = [[
${color grey}${alignc}${time %A %e %B %Y : %Hh%M}
${hr}${if_mpd_playing}
${color grey}${alignc}MPD
-${font1}${color white}${mpd_status}: ${mpd_artist} - ${mpd_title}
-${mpd_elapsed}/${mpd_length} ${mpd_bar}${font}
+${font1}${color white}${goto 140}$mpd_artist
+${goto 140}$mpd_album
+${goto 140}${mpd_elapsed}/${mpd_length} ${mpd_bar}
+${execi 5 ~/.local/bin/conky_cover.sh >/dev/null 2>&1}${image /tmp/conkyCover.png -p 10,30 -n}
${hr}${endif}${if_up re0}
${font2}${color white}${alignc}${execi 1800 curl wttr.in/Lyon?T0 --silent --max-time 3}${font}
${hr}${endif}
diff --git a/.config/x11/xinitrc b/.config/x11/xinitrc
index 3840d88..e39cbd3 100644
--- a/.config/x11/xinitrc
+++ b/.config/x11/xinitrc
@@ -21,6 +21,8 @@ startif xscreensaver --no-splash
# startif sb-updatempd
startif tint2
startif idesk
+startif cairo-clock -x 900 -y 20 --width 300 --height 300 --theme zen &
+startif cairo-dock
startif conky -d -c "$HOME"/.config/conkyrc
# /compat/linux/usr/lib/protonmail/bridge/proton-bridge --noninteractive
# ekb
diff --git a/.local/bin/conky_cover.sh b/.local/bin/conky_cover.sh
new file mode 100755
index 0000000..43bc65c
--- /dev/null
+++ b/.local/bin/conky_cover.sh
@@ -0,0 +1,64 @@
+#!/usr/local/bin/bash
+#
+# cover.sh - Download cover from Last.fm and overlay with image
+#
+# Florian <floriandejonckheere.be>
+#
+# bug: it detects the artist change twice
+
+## CONFIGURATION ##
+# Folder for cached album art
+# Don't use ~, as conky will treat it as a regular directory name
+CACHE="$HOME/.cache/covers"
+# API Key for Last.fm
+APIKEY="b25b959554ed76058ac220b7b2e0a026"
+# Log file, only for debugging purposes
+LOG=/tmp/conky-mpd.log
+
+# Check for vital commands
+# CMD="mpc curl convert"
+# for CHECK in $CMD; do
+# [ ! "$CHECK" ] && echo "Command $CHECK not found. Exiting." && exit 1
+# done
+# [ ! -d "$CACHE" ] && mkdir -p "$CACHE"
+
+ARTIST="$(mpc --format %artist% | head -1)"
+ALBUM="$(mpc --format %album% | head -1)"
+
+TMP=/tmp/conkympd.tmp
+[ ! -f $TMP ] && touch $TMP
+[ "$(cat $TMP)" == "$ARTIST+$ALBUM" ] && echo "Same artist." >> $LOG && exit 0
+echo "Artist changed: $ALBUM by $ARTIST" >> $LOG
+
+#[ -f "/tmp/conkyCover.png" ] && rm "/tmp/conkyCover.png"
+cp $HOME/.config/conky-mpd/nocover.png /tmp/conkyCover.png
+echo "NoCover" >> $LOG
+
+COVER="$CACHE/$ARTIST - $ALBUM.jpg"
+# Is cover cached?
+if [ ! -f "$COVER" ]; then
+# Nope. Download.
+ echo "Downloading cover for $ARTIST - $ALBUM" >> $LOG
+ # Download XML info
+ curl --data-urlencode artist="$ARTIST" --data-urlencode album="$ALBUM" "http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=$APIKEY" -o /tmp/lastfm.xml &> /dev/null
+ echo "Exit: $?. Downloaded $(wc -l /tmp/lastfm.xml | cut -d' ' -f1) bytes." >> $LOG
+ # Strip XML and download mega large cover to cache
+ curl $(sed -n 's|<image size="mega">\(.*\)<\/image>|\1|p' /tmp/lastfm.xml) -o "$COVER" &> /dev/null
+ echo "Exit: $?" >> $LOG
+ echo "Downloaded to $COVER." >> $LOG
+fi
+# Copy cache for processing
+echo "Copying $COVER." >> $LOG
+cp "$COVER" /tmp/cover.jpg
+# Downscale to fit overlay
+convert /tmp/cover.jpg -resize 366 /tmp/cover.png >> $LOG
+# Enlarge canvas to fit overlay
+convert /tmp/cover.png -background none -extent 500x455-84-44 /tmp/cover.png >> $LOG
+# Overlay overlay over cover
+convert /tmp/cover.png $HOME/.config/conky-mpd/case.png -composite /tmp/cover.png >> $LOG
+# Resize for immediate use
+convert /tmp/cover.png -resize 120 /tmp/conkyCover.png >> $LOG
+# Set current artist
+echo "$ARTIST+$ALBUM" > $TMP
+#rm /tmp/cover.jpg /tmp/cover.png
+