eww: dashboard(fake) & spotify player
This commit is contained in:
40
eww/Player/scripts/cava
Executable file
40
eww/Player/scripts/cava
Executable file
@@ -0,0 +1,40 @@
|
||||
#! /bin/bash
|
||||
|
||||
|
||||
bar="▁▂▃▄▅▆▇█"
|
||||
dict="s/;//g;"
|
||||
|
||||
# creating "dictionary" to replace char with bar
|
||||
i=0
|
||||
while [ $i -lt ${#bar} ]
|
||||
do
|
||||
dict="${dict}s/$i/${bar:$i:1}/g;"
|
||||
i=$((i=i+1))
|
||||
done
|
||||
|
||||
# make sure to clean pipe
|
||||
pipe="/tmp/cava.fifo"
|
||||
if [ -p $pipe ]; then
|
||||
unlink $pipe
|
||||
fi
|
||||
mkfifo $pipe
|
||||
|
||||
# write cava config
|
||||
config_file="/tmp/waybar_cava_config"
|
||||
echo "
|
||||
[general]
|
||||
bars = 49
|
||||
[output]
|
||||
method = raw
|
||||
raw_target = $pipe
|
||||
data_format = ascii
|
||||
ascii_max_range = 7
|
||||
" > $config_file
|
||||
|
||||
# run cava in the background
|
||||
cava -p $config_file &
|
||||
|
||||
# reading data from fifo
|
||||
while read -r cmd; do
|
||||
echo $cmd | sed $dict
|
||||
done < $pipe
|
||||
4
eww/Player/scripts/change-music
Executable file
4
eww/Player/scripts/change-music
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
TRACK_ID=$(playerctl -p spotify metadata mpris:trackid)
|
||||
dbus-send --type=method_call --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.SetPosition objpath:/com/spotify/track/0LnS7aOdOdI1dNKZqdOLz4 int64:120000000
|
||||
11
eww/Player/scripts/equalizer
Executable file
11
eww/Player/scripts/equalizer
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
if pgrep easyeffects; then
|
||||
pkill easyeffects
|
||||
echo "Off" > $HOME/.config/eww/Player/status/eq-status
|
||||
exit 1
|
||||
else
|
||||
exec easyeffects --gapplication-service &
|
||||
echo "On" > $HOME/.config/eww/Player/status/eq-status
|
||||
fi
|
||||
exit
|
||||
32
eww/Player/scripts/music-album
Executable file
32
eww/Player/scripts/music-album
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set the source audio player here.
|
||||
# Players supporting the MPRIS spec are supported.
|
||||
# Examples: spotify, vlc, chrome, mpv and others.
|
||||
# Use `playerctld` to always detect the latest player.
|
||||
# See more here: https://github.com/altdesktop/playerctl/#selecting-players-to-control
|
||||
PLAYER="playerctld"
|
||||
|
||||
# Format of the information displayed
|
||||
# Eg. {{ artist }} - {{ album }} - {{ title }}
|
||||
# See more attributes here: https://github.com/altdesktop/playerctl/#printing-properties-and-metadata
|
||||
FORMAT="{{ album }}"
|
||||
|
||||
PLAYERCTL_STATUS=$(playerctl --player=$PLAYER status 2>/dev/null)
|
||||
EXIT_CODE=$?
|
||||
|
||||
if [ $EXIT_CODE -eq 0 ]; then
|
||||
STATUS=$PLAYERCTL_STATUS
|
||||
else
|
||||
STATUS="No Album"
|
||||
fi
|
||||
|
||||
if [ "$STATUS" = "Stopped" ]; then
|
||||
echo "No Album"
|
||||
elif [ "$STATUS" = "Paused" ]; then
|
||||
playerctl --player=$PLAYER metadata --format "$FORMAT"
|
||||
elif [ "$STATUS" = "No Alnum" ]; then
|
||||
echo "$STATUS"
|
||||
else
|
||||
playerctl --player=$PLAYER metadata --format "$FORMAT"
|
||||
fi
|
||||
22
eww/Player/scripts/music-art
Executable file
22
eww/Player/scripts/music-art
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
tmp_dir="$HOME/.config/eww/Main/images"
|
||||
tmp_cover_path=$tmp_dir/cover.png
|
||||
tmp_temp_path=$tmp_dir/temp.png
|
||||
|
||||
if [ ! -d $tmp_dir ]; then
|
||||
mkdir -p $tmp_dir
|
||||
fi
|
||||
|
||||
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')
|
||||
|
||||
if [ $(playerctl -p spotify,%any,firefox,chromium,brave,mpd metadata mpris:artUrl) ]; then
|
||||
curl -s "$artlink" --output $tmp_temp_path
|
||||
echo $tmp_temp_path
|
||||
elif [[ -n $artFromBrowser ]]; then
|
||||
cp $artFromBrowser $tmp_temp_path
|
||||
echo $tmp_temp_path
|
||||
else
|
||||
echo Main/images/default-music.svg
|
||||
fi
|
||||
32
eww/Player/scripts/music-artist
Executable file
32
eww/Player/scripts/music-artist
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set the source audio player here.
|
||||
# Players supporting the MPRIS spec are supported.
|
||||
# Examples: spotify, vlc, chrome, mpv and others.
|
||||
# Use `playerctld` to always detect the latest player.
|
||||
# See more here: https://github.com/altdesktop/playerctl/#selecting-players-to-control
|
||||
PLAYER="playerctld"
|
||||
|
||||
# Format of the information displayed
|
||||
# Eg. {{ artist }} - {{ album }} - {{ title }}
|
||||
# See more attributes here: https://github.com/altdesktop/playerctl/#printing-properties-and-metadata
|
||||
FORMAT="{{ artist }}"
|
||||
|
||||
PLAYERCTL_STATUS=$(playerctl --player=$PLAYER status 2>/dev/null)
|
||||
EXIT_CODE=$?
|
||||
|
||||
if [ $EXIT_CODE -eq 0 ]; then
|
||||
STATUS=$PLAYERCTL_STATUS
|
||||
else
|
||||
STATUS="No Artist"
|
||||
fi
|
||||
|
||||
if [ "$STATUS" = "Stopped" ]; then
|
||||
echo "No Artist"
|
||||
elif [ "$STATUS" = "Paused" ]; then
|
||||
playerctl --player=$PLAYER metadata --format "$FORMAT"
|
||||
elif [ "$STATUS" = "No Artist" ]; then
|
||||
echo "$STATUS"
|
||||
else
|
||||
playerctl --player=$PLAYER metadata --format "$FORMAT"
|
||||
fi
|
||||
32
eww/Player/scripts/music-length
Executable file
32
eww/Player/scripts/music-length
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set the source audio player here.
|
||||
# Players supporting the MPRIS spec are supported.
|
||||
# Examples: spotify, vlc, chrome, mpv and others.
|
||||
# Use `playerctld` to always detect the latest player.
|
||||
# See more here: https://github.com/altdesktop/playerctl/#selecting-players-to-control
|
||||
PLAYER="playerctld"
|
||||
|
||||
# Format of the information displayed
|
||||
# Eg. {{ artist }} - {{ album }} - {{ title }}
|
||||
# See more attributes here: https://github.com/altdesktop/playerctl/#printing-properties-and-metadata
|
||||
FORMAT="{{ duration(position) }} / {{ duration(mpris:length) }}"
|
||||
|
||||
PLAYERCTL_STATUS=$(playerctl --player=$PLAYER status 2>/dev/null)
|
||||
EXIT_CODE=$?
|
||||
|
||||
if [ $EXIT_CODE -eq 0 ]; then
|
||||
STATUS=$PLAYERCTL_STATUS
|
||||
else
|
||||
STATUS="--:-- / --:--"
|
||||
fi
|
||||
|
||||
if [ "$STATUS" = "Stopped" ]; then
|
||||
echo "--:-- / --:--"
|
||||
elif [ "$STATUS" = "Paused" ]; then
|
||||
playerctl --player=$PLAYER metadata --format "$FORMAT"
|
||||
elif [ "$STATUS" = "--:-- / --:--" ]; then
|
||||
echo "$STATUS"
|
||||
else
|
||||
playerctl --player=$PLAYER metadata --format "$FORMAT"
|
||||
fi
|
||||
32
eww/Player/scripts/music-length-info
Executable file
32
eww/Player/scripts/music-length-info
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set the source audio player here.
|
||||
# Players supporting the MPRIS spec are supported.
|
||||
# Examples: spotify, vlc, chrome, mpv and others.
|
||||
# Use `playerctld` to always detect the latest player.
|
||||
# See more here: https://github.com/altdesktop/playerctl/#selecting-players-to-control
|
||||
PLAYER="playerctld"
|
||||
|
||||
# Format of the information displayed
|
||||
# Eg. {{ artist }} - {{ album }} - {{ title }}
|
||||
# See more attributes here: https://github.com/altdesktop/playerctl/#printing-properties-and-metadata
|
||||
FORMAT="{{ duration(mpris:length) }}"
|
||||
|
||||
PLAYERCTL_STATUS=$(playerctl --player=$PLAYER status 2>/dev/null)
|
||||
EXIT_CODE=$?
|
||||
|
||||
if [ $EXIT_CODE -eq 0 ]; then
|
||||
STATUS=$PLAYERCTL_STATUS
|
||||
else
|
||||
STATUS="--:--"
|
||||
fi
|
||||
|
||||
if [ "$STATUS" = "Stopped" ]; then
|
||||
echo "--:--"
|
||||
elif [ "$STATUS" = "Paused" ]; then
|
||||
playerctl --player=$PLAYER metadata --format "$FORMAT"
|
||||
elif [ "$STATUS" = "--:--" ]; then
|
||||
echo "$STATUS"
|
||||
else
|
||||
playerctl --player=$PLAYER metadata --format "$FORMAT"
|
||||
fi
|
||||
4
eww/Player/scripts/music-position
Executable file
4
eww/Player/scripts/music-position
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
POS=$(playerctl -p spotify position)
|
||||
python -c "print(float($POS*1000000))"
|
||||
43
eww/Player/scripts/music-title
Executable file
43
eww/Player/scripts/music-title
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set the source audio player here.
|
||||
# Players supporting the MPRIS spec are supported.
|
||||
# Examples: spotify, vlc, chrome, mpv and others.
|
||||
# Use `playerctld` to always detect the latest player.
|
||||
# See more here: https://github.com/altdesktop/playerctl/#selecting-players-to-control
|
||||
PLAYER="playerctld"
|
||||
|
||||
# Format of the information displayed
|
||||
# Eg. {{ artist }} - {{ album }} - {{ title }}
|
||||
# See more attributes here: https://github.com/altdesktop/playerctl/#printing-properties-and-metadata
|
||||
FORMAT="{{ title }}"
|
||||
|
||||
|
||||
PLAYERCTL_STATUS=$(playerctl --player=$PLAYER status 2>/dev/null)
|
||||
EXIT_CODE=$?
|
||||
|
||||
if [ $EXIT_CODE -eq 0 ]; then
|
||||
STATUS=$PLAYERCTL_STATUS
|
||||
else
|
||||
STATUS="Nothing is playing"
|
||||
fi
|
||||
|
||||
if [ "$1" == "--status" ]; then
|
||||
if [ "$STATUS" = "Stopped" ]; then
|
||||
echo "Nothing is playing"
|
||||
elif [ "$STATUS" = "Paused" ]; then
|
||||
playerctl --player=$PLAYER metadata --format "$FORMAT"
|
||||
elif [ "$STATUS" = "Nothing is playing" ]; then
|
||||
echo "$STATUS"
|
||||
else
|
||||
playerctl --player=$PLAYER metadata --format "$FORMAT"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" == "--icon" ]; then
|
||||
if [[ $STATUS == "Playing" ]]; then
|
||||
echo ""
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
fi
|
||||
57
eww/Player/scripts/player
Executable file
57
eww/Player/scripts/player
Executable file
@@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ $1 == "--length" ]]; then
|
||||
playerctl -p spotify metadata mpris:length
|
||||
fi
|
||||
|
||||
if [[ $1 == "--open" ]]; then
|
||||
URL=$(playerctl -p spotify metadata xesam:url)
|
||||
echo "$URL?go=1&utm_medium=desktop"
|
||||
fi
|
||||
|
||||
if [[ $1 == "--artist" ]]; then
|
||||
"$HOME/.config/eww/Player/scripts/music-artist"
|
||||
fi
|
||||
|
||||
if [[ $1 == "--length-time" ]]; then
|
||||
"$HOME/.config/eww/Player/scripts/music-length"
|
||||
fi
|
||||
|
||||
if [[ $1 == "--length-info" ]]; then
|
||||
"$HOME/.config/eww/Player/scripts/music-length-info"
|
||||
fi
|
||||
|
||||
if [[ $1 == "--cover" ]]; then
|
||||
"$HOME/.config/eww/Player/scripts/music-art"
|
||||
fi
|
||||
|
||||
if [[ $1 == "--album" ]]; then
|
||||
"$HOME/.config/eww/Player/scripts/music-album"
|
||||
fi
|
||||
|
||||
if [[ $1 == "--current-volume" ]]; then
|
||||
VOLUME=$(playerctl -p spotify volume)
|
||||
echo $(python -c "print(float("$VOLUME")*100)")
|
||||
fi
|
||||
|
||||
if [[ $1 == "--volume" ]]; then
|
||||
CURRENT_VOLUME=$2
|
||||
NOW_VOLUME=$(python -c "print(float($CURRENT_VOLUME)/100)")
|
||||
playerctl -p spotify volume "$NOW_VOLUME"
|
||||
fi
|
||||
|
||||
if [[ $1 == "--shuffle" ]]; then
|
||||
if [[ $(playerctl -p spotify shuffle) == "On" ]]; then
|
||||
playerctl -p spotify shuffle off
|
||||
else
|
||||
playerctl -p spotify shuffle On
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $1 == "--current-pos" ]]; then
|
||||
playerctl -p spotify position --format '{{ duration(position) }}'
|
||||
fi
|
||||
|
||||
if [[ $1 == "--launch-lyrics" ]]; then
|
||||
eww open --toggle lyrics
|
||||
fi
|
||||
Reference in New Issue
Block a user