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 15 forks source link

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

Open shadow-absorber opened 11 months ago

shadow-absorber commented 11 months 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 7 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" {} \;