Skip to content

Instantly share code, notes, and snippets.

@thymbahutymba
Last active March 23, 2018 11:50
Show Gist options
  • Save thymbahutymba/0d3b9e88e6ff90c1938e7fe12f212490 to your computer and use it in GitHub Desktop.
Save thymbahutymba/0d3b9e88e6ff90c1938e7fe12f212490 to your computer and use it in GitHub Desktop.
Cmus current track's display script with kdialog
#!/bin/sh
timeout=2
time=""
# Take input argument
while [ "$1" != "" ]; do
case "$1" in
title)
title="$2" ;;
artist)
artist="$2" ;;
duration)
duration=$2 ;;
album)
album="$2" ;;
status)
status="$2" ;;
file)
file="$2" ;;
esac
shift
shift
done
# Adjust time output
[ "$((duration/60))" -lt 10 ] && time=$time"0"
time=$time"$((duration/60)):"
[ "$((duration%60))" -lt 10 ] && time=$time"0"
time=$time"$((duration%60))"
# Extract cover from mp3 file
yes | ffmpeg -i "$file" /tmp/cover.jpg > /dev/null 2> /dev/null && \
icon=/tmp/cover.jpg || icon=$HOME/.config/cmus/icon.svg
# Set title and message
top="Cmus $status"
msg="<b>$title</b> by <b>$artist</b> on <b>$album</b> ($time)"
kdialog --passivepopup "$msg" $timeout --title "$top" --icon "$icon"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment