trizen / clyrics

An extensible lyrics fetcher, with daemon support for cmus and mocp.
https://trizenx.blogspot.com/2013/02/mocp-lyrics.html
GNU General Public License v3.0
56 stars 16 forks source link

insert new line and title when song changes using cmus daemon #22

Open shadow-absorber opened 1 year ago

shadow-absorber commented 1 year ago

currently if you run clyrics in tmux the new lyrics gets kinda merged with the old lyrics when a new song starts/changes to a new song meaning it gets quickly confusing to find where the lyrics start and where it ends for songs

mzivic7 commented 9 months ago

This will not insert newline and title, but just clear lyrics from previous song, as clyrics does outside tmux.

The problem is here: reset -Q clears terminal but not tmux's buffer. Tmux buffer is cleared with tmux clear-history but there also must be specified on what pane to clear So the command becomes: tmux clear-history -t $TMUX_PANE Now if tmux is not installed $TMUX_PANE variable will not exist, so to skip error messages: if [ -z ${TMUX_PANE} ]; then :; else tmux clear-history -t $TMUX_PANE; fi

Finally this line should be changed to: system('reset -Q; if [ -z ${TMUX_PANE} ]; then :; else tmux clear-history -t $TMUX_PANE; fi') == 0 or print "\e[H\e[J\e[H";

This command will patch clyrics script in /usr/bin: sudo find /usr/bin/clyrics -type f -exec sed -i "s/system('reset -Q')/system('reset -Q; if [ -z \${TMUX_PANE} ]; then :; else tmux clear-history -t \$TMUX_PANE; fi')/g" {} \;

shadow-absorber commented 1 week ago

thanks @mzivic7 this solves the problem decently for now... still would be nice to get a title output

mzivic7 commented 1 week ago

@shadow-absorber I made my own cmus-only lyrics display in python with ncurses, check it out if you want, its called cmus-auto-lyrics on github. It even scrolls lyrics automatically, and can read them from tags.