add eww config

This commit is contained in:
matt1432 2023-05-28 18:05:51 -04:00
commit 85dde2e9aa
34 changed files with 2112 additions and 0 deletions

13
eww/scripts/music/control.sh Executable file
View file

@ -0,0 +1,13 @@
#!/usr/bin/env bash
if [[ $1 == "prev" ]]; then
playerctl previous
fi
if [[ $1 == "play-pause" ]]; then
playerctl play-pause
fi
if [[ $1 == "next" ]]; then
playerctl next
fi

45
eww/scripts/music/songart.sh Executable file
View file

@ -0,0 +1,45 @@
#!/bin/bash
# thanks to kizu
get_song_art () {
TMP_DIR="$HOME/.cache/eww"
TMP_COVER_PATH=$TMP_DIR/cover.png
TMP_TEMP_PATH=$TMP_DIR/temp.png
if [[ ! -d $TMP_DIR ]]; then
mkdir -p $TMP_DIR
fi
ART_FROM_SPOTIFY="$(playerctl -p %any,spotify metadata mpris:artUrl | sed -e 's/open.spotify.com/i.scdn.co/g')"
ART_FROM_BROWSER="$(playerctl -p %any,mpd,firefox,chromium,brave metadata mpris:artUrl | sed -e 's/file:\/\///g')"
if [[ $(playerctl -p spotify,%any,firefox,chromium,brave,mpd metadata mpris:artUrl) ]]; then
curl -s "$ART_FROM_SPOTIFY" --output $TMP_TEMP_PATH
elif [[ -n $ART_FROM_BROWSER ]]; then
cp $ART_FROM_BROWSER $TMP_TEMP_PATH
else
cp $HOME/.config/eww/assets/fallback.png $TMP_TEMP_PATH
fi
cp $TMP_TEMP_PATH $TMP_COVER_PATH
# an epic effekt
# convert $TMP_TEMP_PATH -alpha set -channel A -evaluate multiply 1.0 $TMP_COVER_PATH
# convert $TMP_TEMP_PATH -gravity center +repage -alpha set -channel A \
# -sparse-color Barycentric '%[fx:w*2/32],0 transparent %[fx:w+0.5],0 opaque' \
# -evaluate multiply 0.45 \
# $TMP_COVER_PATH
}
echo_song_art_url () {
echo "$HOME/.cache/eww/cover.png"
}
if [[ $1 == "echo" ]]; then
echo_song_art_url
fi
if [[ $1 == "get" ]]; then
get_song_art
fi

36
eww/scripts/music/songdata.sh Executable file
View file

@ -0,0 +1,36 @@
#!/usr/bin/env bash
capitalize () {
toshow="$1"
maxlen="$2"
sufix=""
if test $(echo $toshow | wc -c) -ge $maxlen ; then
sufix=" ..."
fi
echo "${toshow:0:$maxlen}$sufix"
}
withSafe () {
local txt="$1"
local safe="$2"
if [[ $txt == "" ]]; then
echo $safe
else
echo $txt
fi
}
if [[ $1 == "title" ]]; then
capitalize "$(playerctl metadata --format "{{title}}" || echo "Nothing playing")" 18
fi
if [[ $1 == "artist" ]]; then
withSafe "$(capitalize "$(playerctl metadata --format "{{artist}}" || echo "No artist")" 18)" "No artist detected"
fi
if [[ $1 == "status" ]]; then
playerctl status || echo 'Paused'
fi