Last active
March 23, 2018 11:50
-
-
Save thymbahutymba/0d3b9e88e6ff90c1938e7fe12f212490 to your computer and use it in GitHub Desktop.
Cmus current track's display script with kdialog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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