eww; lyrics widget

This commit is contained in:
2025-06-23 06:16:58 +02:00
parent fbe156fa6c
commit e769385bcf
11 changed files with 654 additions and 1 deletions

53
eww/Lyrics/eww.scss Normal file
View File

@@ -0,0 +1,53 @@
* {
all: unset;
transition: 200ms ease-out;
}
.lyrics-window {
background-color: $bg;
border-radius: 16px;
border: 2px solid $blue;
}
.lyrics-box {
margin: 20px;
min-width: 500px;
}
.lyrics-text {
color: $fg;
font-size: 16px;
font-family: 'Maple Mono Normal NF CN', 'Maple Mono CN', monospace;
}
.control-box {
margin: 10px;
min-height: 90px;
}
.offset-minus,
.offset-reset,
.offset-plus,
.offset-clear {
padding: 0px 6px;
margin: 0px 4px 0px 4px;
font-family: 'MesloLGM Nerd Font Mono';
font-size: 20px;
min-width: 16px;
}
.offset-minus {
color: $blue;
}
.offset-plus {
color: $yellow;
}
.offset-reset {
color: $green;
}
.offset-clear {
color: $red;
}

31
eww/Lyrics/eww.yuck Normal file
View File

@@ -0,0 +1,31 @@
(defpoll lyriclines :interval "500ms" "Lyrics/scripts/lyric-lines.sh")
(defwidget lyrics []
(box :class "lyrics-window" :space-evenly "false" :orientation "h"
(box :class "lyrics-box" :vexpand "false" :hexpand "false" :valign "center" :space-evenly "false" :orientation "v"
(label :class "lyrics-text"
:vexpand "false" :hexpand "false" :space-evenly "false"
:halign "start"
:text lyriclines
)
)
(box :class "control-box" :vexpand "false" :hexpand "false" :space-evenly "true" :orientation "v"
(box :class "control-row-1" :space-evenly "false" :orientation "h"
(button :class "offset-minus" :onclick "Lyrics/scripts/lyric-offset.py -500" "󰓅")
(button :class "offset-plus" :onclick "Lyrics/scripts/lyric-offset.py +500" "󰾆")
)
(box :class "control-row-1" :space-evenly "false" :orientation "h"
(button :class "offset-reset" :onclick "Lyrics/scripts/lyric-offset.py" "󰾅")
(button :class "offset-clear" :onclick "spotify-lyrics clear" "󰑙")
)
)
)
)
(defwindow lyrics
:windowtype "normal"
:wm-ignore false
:monitor 0
:geometry (geometry :anchor "top center")
(lyrics)
)

View File

@@ -0,0 +1,6 @@
#!/bin/sh
killall spotify-lyrics
sleep 0.1
spotify-lyrics clear
notify-send -a "spotify-lyrics" "Lyrics Cleared" "The lyrics have been cleared."

View File

@@ -0,0 +1,13 @@
#!/bin/sh
STATE_DIR="$HOME/.local/state/eww/lyrics"
if [ ! -d $STATE_DIR ]; then
mkdir -p $STATE_DIR
fi
OFFSET_FILE="$STATE_DIR/offset"
if [ ! -f "$OFFSET_FILE" ]; then
echo "0" > "$OFFSET_FILE"
fi
spotify-lyrics print -l 3 -O $(cat "$OFFSET_FILE")

View File

@@ -0,0 +1,43 @@
APP_NAME = "spotify-lyrics"
STATE_DIR_NAME = "~/.local/state/eww/lyrics"
STATE_FILE_NAME = "offset"
def notify_send(title, message):
import subprocess
subprocess.run(["notify-send", "-a", APP_NAME, title, message], check=True)
def main():
import sys
import os
state_dir = os.path.expanduser(STATE_DIR_NAME)
if not os.path.exists(state_dir):
os.makedirs(state_dir)
offset_file = os.path.join(state_dir, STATE_FILE_NAME)
if not os.path.exists(offset_file):
with open(offset_file, "w") as f:
f.write("0")
if len(sys.argv) < 2:
new_offset = 0
else:
try:
increment = int(sys.argv[1])
with open(offset_file, "r") as f:
current_offset = int(f.read().strip())
new_offset = current_offset + increment
except ValueError:
print("Invalid input. Please provide an integer value.")
return
with open(offset_file, "w") as f:
f.write(str(new_offset))
notify_send("Lyrics Speed Changed", f"The offset has been changed to {new_offset} ms.")
if __name__ == "__main__":
main()