better structure
This commit is contained in:
24
config/eww/Lyrics/scripts/colorize.sh
Executable file
24
config/eww/Lyrics/scripts/colorize.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
HIGHLIGHT_COLOR="#cdd6f4" # text
|
||||
NORMAL_COLOR="#7f849c" # overlay1
|
||||
TARGET_LINE=1
|
||||
[ -n "$1" ] && TARGET_LINE="$1"
|
||||
|
||||
mapfile -t lines
|
||||
|
||||
output=""
|
||||
for i in "${!lines[@]}"; do
|
||||
line_num=$((i + 1))
|
||||
escaped_line=$(echo "${lines[$i]}" | sed 's/&/\&/g; s/</\</g; s/>/\>/g')
|
||||
|
||||
[[ $i -gt 0 ]] && output+=$'\n' # +="\n" is not properly displayed in eww
|
||||
|
||||
if [[ $line_num -eq $TARGET_LINE ]]; then
|
||||
output+="<span color=\"$HIGHLIGHT_COLOR\">$escaped_line</span>"
|
||||
else
|
||||
output+="<span color=\"$NORMAL_COLOR\">$escaped_line</span>"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "$output"
|
||||
9
config/eww/Lyrics/scripts/lyric-clear.sh
Executable file
9
config/eww/Lyrics/scripts/lyric-clear.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
"spotify-lyrics" clear
|
||||
notify-send -a "spotify-lyrics" "Cache Cleared" "Lyrics cache have been cleared."
|
||||
else
|
||||
"spotify-lyrics" clear "$1"
|
||||
notify-send -a "spotify-lyrics" "Cache Cleared" "Lyrics cache for track $1 have been cleared."
|
||||
fi
|
||||
45
config/eww/Lyrics/scripts/lyric-offset.py
Executable file
45
config/eww/Lyrics/scripts/lyric-offset.py
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
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", "-t", "1000", "-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()
|
||||
2
config/eww/Lyrics/scripts/lyric-show.sh
Executable file
2
config/eww/Lyrics/scripts/lyric-show.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
|
||||
Reference in New Issue
Block a user