-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Output *only* ONE lyric line to the pipe? #27
Comments
Hello!! This idea has certainly crossed my mind, but there are some visible limitations. What I suggest you do is use the current pipe implementation to run it in the background. And then use another script on your panel to access this "daemon" to get the current line. |
Here's a Python script that will do just that. It uses a named unix pipe to prevent writing to disk. import os
import subprocess
pipe_path = "/tmp/lyrics"
try:
os.mkfifo(pipe_path)
except FileExistsError:
pass
process = subprocess.Popen(["sptlrx", "pipe"], stdout=subprocess.PIPE)
for line in iter(process.stdout.readline, ""):
with open(pipe_path, "wb") as pipe:
pipe.write(line) Leave it running in the background. Then in your panel you will need to do something like Original code (writing to disk)import subprocess
process = subprocess.Popen(["sptlrx", "pipe"], stdout=subprocess.PIPE)
for line in iter(process.stdout.readline, ""):
with open("/tmp/lyrics", "wb") as file:
file.write(line) |
Hey just wanted to say I was trying to the same thing and this was really helpful! I wanted to display lyrics "lyric-by-lyric" in my polybar bar. Here is my bash solution: #!/bin/bash
# Simple script that determines what my polybar music module prints
# If spotify is playing it prints each lyric, if not then it prints
# last sources title
STATUS=$(playerctl -p spotify status)
# Check if programs installed
if ! command -v "playerctl" &> /dev/null && ! command -v "sptlrx" &> /dev/null ; then
echo "Proper programs not installed!"
exit
fi
# Check if pipe is running
if [ -z "$(ps aux | grep -v 'grep' | grep 'sptlrx pipe' )" ]; then
sptlrx pipe >> /tmp/lyrics &
fi
# Script's logic
if [ "$STATUS" == "Paused" ]; then
echo "$(playerctl metadata title | cut -c -50)"
elif [ "$STATUS" == "Playing" ]; then
echo "$(tail -1 /tmp/lyrics)"
else
echo "Issue, check out script"
fi
|
Hi! I'm trying to use this application in a setup where I would like to only show the current line to terminal then exit.
I can't seem to get this working because the application never exits.
I would like to suggest the following improvements:
Only output the current line then exit
An option to output the next lyric line alone then exit, like above, BUT slightly in advance (Think: Karaoke). I like to sing along but sometimes I forget the lyrics.
My current actual use case is the following:
I have several other use cases I can think about, that would be solved by making this behaviour work.
Related: #1, #8
The text was updated successfully, but these errors were encountered: