From e8105a1c99d4bdf1a6a5397058a5dcd3a7440963 Mon Sep 17 00:00:00 2001 From: InigoGutierrez Date: Wed, 20 Mar 2019 16:27:50 +0100 Subject: Dunstified and changed temporal cover image path. --- musicMode.sh | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'musicMode.sh') diff --git a/musicMode.sh b/musicMode.sh index 574a58d..14b97ba 100755 --- a/musicMode.sh +++ b/musicMode.sh @@ -1,28 +1,30 @@ #!/bin/sh -[ "$(pgrep -x musicMode.sh)" != "$$" ] && notify-send -t 3000 "Already running! Exiting this new instance." && exit 0 #Check if already running -[ -z "$(pgrep -x cmus)" ] && notify-send -t 3000 "cmus not running. Open it first." && exit 0 #Check that cmus is running +[ "$(pgrep -x musicMode.sh)" != "$$" ] && dunstify -t 3000 "Already running! Exiting this new instance." && exit 0 #Check if already running +[ -z "$(pgrep -x cmus)" ] && dunstify -t 3000 "cmus not running. Open it first." && exit 0 #Check that cmus is running -mkdir /tmp/musicMode -coverPath="/tmp/musicMode/cover.jpg" +coverPath="/tmp/musicMode.png" i3-msg "workspace 6" >/dev/null #Switch to music workspace i3-msg "gaps inner current set 0; gaps outer current set 0; bar mode hide" i3-msg "exec urxvt -title 'noborder' -sh 100 -fn xft:monospace:size=4 -e vis -c ~/.config/vis/configMusicMode" # Start music visualizer -# Loop checking current song and checking background +# Loop checking current song and setting background file="" while [ true ] do + # Check if current file has changed if [ "$file" != "$(cmus-remote -Q | grep "^file" | cut -d' ' -f2-)" ]; then + # Set $file to current playing file if it has changed file="$(cmus-remote -Q | grep ^file | cut -d' ' -f2-)" rm $coverPath >/dev/null - title="$(cmus-remote -Q | grep "tag title " | cut -d' ' -f3-)" - [ -z "$title" ] && title="[$(basename "$(cmus-remote -Q | grep "file " | cut -d'/' -f5-)")]" - notify-send -h string:x-canonical-private-synchronous:musicMode -t 0 "$(~/scripts/i3blocks/i3music.sh)" - ffmpeg -i "$file" $coverPath >/dev/null - feh --no-fehbg --bg-max $coverPath >/dev/null - videoFile="$(ls -d ~/videos/music/* | grep "$title")" + # Get title. It is only used for video search. + title="$(cmus-remote -Q | grep "^tag title " | cut -d' ' -f3-)" + [ -z "$title" ] && title="$(basename "$(cmus-remote -Q | grep "^file" | cut -d' ' -f2- | cut -d'.' -f1 )")" + dunstify -r $(dunstifyIDs.sh musicMode) -t 0 "$(~/scripts/i3blocks/i3music.sh)" + ffmpeg -i "$file" "$coverPath" >/dev/null + feh --no-fehbg --bg-max "$coverPath" >/dev/null #|| feh --no-fehbg --bg-max $HOME/images/wallpapers/bg_* >/dev/null + videoFile="$(ls -d $HOME/videos/music/* | grep "$title")" if [ "$videoFile" ]; then # videoclip found cmus-remote -u mpv --fs "$videoFile" @@ -33,6 +35,6 @@ do cmus-remote -n fi fi - [ -z "$(pgrep -x cmus)" ] && notify-send "Cmus closed." && closeMusicMode.sh + [ -z "$(pgrep -x cmus)" ] && closeMusicMode.sh sleep 1 done -- cgit v1.2.1