eww: fix: music-art
This commit is contained in:
@@ -3,44 +3,66 @@
|
||||
tmp_dir="$HOME/.config/eww/Main/images"
|
||||
tmp_temp_path=$tmp_dir/temp.png
|
||||
tmp_blur_path="$tmp_dir/temp-blur.png"
|
||||
cache_path="$tmp_dir/temp.txt"
|
||||
cache_path="$tmp_dir/cache.conf"
|
||||
default_path="$tmp_dir/default-music.svg"
|
||||
default_blur_path="$tmp_dir/default-music-blur.png"
|
||||
|
||||
if [ ! -d $tmp_dir ]; then
|
||||
mkdir -p $tmp_dir
|
||||
fi
|
||||
mkdir -p "$tmp_dir"
|
||||
|
||||
artlink="$(playerctl -p spotify,$any,mpd,firefox,chromium,brave metadata mpris:artUrl | sed -e 's/open.spotify.com/i.scdn.co/g')"
|
||||
artFromBrowser=$(playerctl metadata mpris:artUrl | sed 's/file:\/\///g')
|
||||
cached=$(cat $cache_path 2>/dev/null)
|
||||
artlink="$(playerctl metadata mpris:artUrl)"
|
||||
[ -f "$cache_path" ] && . "$cache_path"
|
||||
|
||||
if [ $(playerctl -p spotify,%any,firefox,chromium,brave,mpd metadata mpris:artUrl) ]; then
|
||||
# avoid unnecessary downloads
|
||||
if [[ $cached != $artlink ]]; then
|
||||
echo $artlink > $cache_path
|
||||
curl -s "$artlink" --output $tmp_temp_path
|
||||
outputUrl=$tmp_temp_path
|
||||
magick $tmp_temp_path -blur 0x8 $tmp_blur_path
|
||||
else
|
||||
outputUrl=$cached
|
||||
# if [[ "$artlink" =~ ^https?:// ]]; then
|
||||
# # avoid unnecessary downloads
|
||||
# if [[ "$cached" != "$artlink" ]]; then
|
||||
# echo "$artlink" > "$cache_path"
|
||||
# curl -s "$artlink" --output "$tmp_temp_path" || exit 1
|
||||
# outputUrl="$tmp_temp_path"
|
||||
# magick "$tmp_temp_path" -blur 0x8 "$tmp_blur_path"
|
||||
# else
|
||||
# outputUrl="$cached"
|
||||
# fi
|
||||
# elif [[ "$artlink" =~ ^file:// ]]; then
|
||||
# if [[ §cached != "$artlink" ]]; then
|
||||
# echo "$artlink" > "$cache_path"
|
||||
# cp "$artFromBrowser" "$tmp_temp_path"
|
||||
# magick "$tmp_temp_path" -blur 0x8 "$tmp_blur_path"
|
||||
# outputUrl="$tmp_temp_path"
|
||||
# else
|
||||
# outputUrl="$cached"
|
||||
# fi
|
||||
# else
|
||||
# outputUrl="$default_path"
|
||||
# tmp_blur_path="$default_blur_path"
|
||||
# fi
|
||||
|
||||
# avoid unnecessary downloads
|
||||
if [ -z "$artlink" ]; then
|
||||
# No art URL, use default
|
||||
outputUrl="$default_path"
|
||||
tmp_blur_path="$default_blur_path"
|
||||
echo "$outputUrl" > "$cache_path"
|
||||
elif [[ "$cachedlink" != "$artlink" ]]; then
|
||||
echo "cachedlink=$artlink" > "$cache_path"
|
||||
|
||||
if [[ "$artlink" == "file://"* ]]; then
|
||||
# Handle local file URLs
|
||||
local_file_path="${artlink#file://}"
|
||||
if [[ -f "$local_file_path" ]]; then
|
||||
magick "$local_file_path" "$tmp_temp_path" || exit 1
|
||||
fi
|
||||
elif [[ "$artlink" =~ ^https?:// ]]; then
|
||||
# Handle HTTP/HTTPS URLs
|
||||
curl -s "$artlink" --output "$tmp_temp_path"_orig || exit 1
|
||||
magick "$tmp_temp_path"_orig "$tmp_temp_path" || exit 1
|
||||
fi
|
||||
elif [[ -n $artFromBrowser ]]; then
|
||||
if [[ §cached != $artFromBrowser ]]; then
|
||||
echo $artFromBrowser > $cache_path
|
||||
cp $artFromBrowser $tmp_temp_path
|
||||
magick $tmp_temp_path -blur 0x8 $tmp_blur_path
|
||||
outputUrl=$tmp_temp_path
|
||||
else
|
||||
outputUrl=$cached
|
||||
fi
|
||||
else
|
||||
outputUrl=$default_path
|
||||
tmp_blur_path=$default_blur_path
|
||||
|
||||
outputUrl="$tmp_temp_path"
|
||||
magick "$tmp_temp_path" -blur 0x8 "$tmp_blur_path"
|
||||
fi
|
||||
|
||||
if [[ $1 == "--blur" ]]; then
|
||||
echo $tmp_blur_path
|
||||
echo "$tmp_blur_path"
|
||||
else
|
||||
echo $outputUrl
|
||||
echo "$tmp_temp_path"
|
||||
fi
|
||||
Reference in New Issue
Block a user