eww: remove player window

This commit is contained in:
2025-06-18 14:21:27 +02:00
parent 285f7a37b7
commit 656573db82
21 changed files with 75 additions and 477 deletions

View File

@@ -163,6 +163,47 @@
background: linear-gradient(to right, $bg-alt, transparent);
}
.player-cover-box {
background-size: 140px;
min-height: 140px;
min-width: 140px;
border-radius: 20px;
background-repeat: no-repeat;
background-position: center;
}
.player-box {
margin: 40px 30px 30px 50px;
}
.player-info-box {
font-size: 14px;
}
.player-info-title,
.player-info-artist {
color: $blue;
font-weight: bold;
}
.player-info-album,
.player-info-length {
color: $fg-alt;
}
.player-info-button {
background-color: $gray-alt;
padding: 15px;
border-radius: 20px;
font-weight: bold;
margin-top: 10px;
}
.cavabar {
font-size: 14px;
color: $lavender;
}
.music-controls-box {
margin: 20px 20px 0px 20px;
background-color: $gray-alt;

View File

@@ -26,6 +26,12 @@
(defpoll volume :interval "1s" "Main/scripts/system --vol")
(defpoll brightness :interval "1s" "Main/scripts/system --bri")
(defpoll fortune :interval "1h" "Main/scripts/fortune.py 32 9")
(deflisten cava "Main/scripts/cava")
(defpoll title :interval "1s" "Main/scripts/music-title --status")
(defpoll artist :interval "1s" "Main/scripts/player --artist")
(defpoll album :interval "1s" "Main/scripts/player --album")
(defpoll length-info :interval "1s" "Main/scripts/player --length-info")
(defpoll art :interval "1s" "Main/scripts/player --cover")
;; widgets
@@ -60,9 +66,18 @@
(box :class "third-row" :orientation "h" :space-evenly "false"
(box :class "music-art-box" :space-evenly "false" :orientation "v" :hexpand "false" :vexpand "false" :style "background-image: url(\"${music-art}\");"
(box :class "music-stuff-box" :space-evenly "false" :hexpand "false" :vexpand "false" :orientation "v"
(label :class "music-title" :text music-title :halign "start" :limit-width 22 :tooltip music-title)
(label :class "music-artist" :text music-artist :halign "start" :limit-width 22 :tooltip music-artist)
(label :class "music-length" :text music-length :halign "start" :valign "end")))
(box :class "player-box" :hexpand "false" :vexpand "false" :space-evenly "true"
(box :class "player-info-box" :hexpand "false" :vexpand "false" :space-evenly "false" :orientation "v" :spacing 15
(label :class "player-info-title" :text "󰝚 Title: ${title}" :halign "start" :limit-width 30 :tooltip "${title}")
(label :class "player-info-artist" :text "󰠃 Artist: ${artist}" :halign "start" :limit-width 30 :tooltip "${artist}")
(label :class "player-info-album" :text "󰀥 Album: ${album}" :halign "start" :limit-width 30 :tooltip "${album}")
(label :class "player-info-length" :text "󰦚 Length: ${length-info}" :halign "start" :tooltip "${length-info}"))
(box :class "player-cover-box" :hexpand "false" :halign "end" :vexpand "false" :space-evenly "false" :style "background-image: url('${art}');"))
(box :class "cava-box" :hexpand "false" :vexpand "false"
(label :vexpand "false" :hexpand "false" :space-evenly "false"
:class "cavabar"
:text cava
))))
(box :class "music-controls-box" :space-evenly "true" :hexpand "true" :vexpand "false" :orientation "v"
(button :class "music-previous" :halign "center" :onclick "playerctl previous" "󰒮")
(button :class "music-pp" :halign "center" :onclick "playerctl play-pause" "${music-pp}")

40
eww/Main/scripts/cava Executable file
View 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 = 33
[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

View 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

View File

@@ -0,0 +1,4 @@
#!/bin/bash
POS=$(playerctl -p spotify position)
python -c "print(float($POS*1000000))"

57
eww/Main/scripts/player Executable file
View 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/Main/scripts/music-artist"
fi
if [[ $1 == "--length-time" ]]; then
"$HOME/.config/eww/Main/scripts/music-length"
fi
if [[ $1 == "--length-info" ]]; then
"$HOME/.config/eww/Main/scripts/music-length-info"
fi
if [[ $1 == "--cover" ]]; then
"$HOME/.config/eww/Main/scripts/music-art"
fi
if [[ $1 == "--album" ]]; then
"$HOME/.config/eww/Main/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