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

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()