Bash script für cmus-remote 2011-07-04 22:56:13 #/bin/bash # pgrep gets the process id, returns an empty string if not running if [ "$(pgrep cmus)" ]; then # Converting total seconds into minutes:seconds # if statement just adds a zero in front of the term when needed position=$(cmus-remote -Q | grep "position " | cut -c 10-) possecs=$(($position%60)) if [ $possecs -lt 10 ]; then possecs="0$possecs"; fi posmins=$(($position/60)) if [ $posmins -lt 10 ]; then posmins="0$posmins"; fi # Converting total seconds into minutes:seconds # if statement just adds a zero in front of the term when needed duration=$(cmus-remote -Q | grep "duration " | cut -c 10-) dursecs=$(($duration%60)) if [ $dursecs -lt 10 ]; then dursecs="0$dursecs"; fi durmins=$(($duration/60)) if [ $durmins -lt 10 ]; then durmins="0$durmins"; fi # sed command needed to capitalize first letter of the status status=$(cmus-remote -Q | grep "status " | cut -c 8- | sed 's/^./\u&/') artist=$(cmus-remote -Q | grep " artist " | cut -c 12-) #album=$(cmus-remote -Q | grep " album " | cut -c 11-) title=$(cmus-remote -Q | grep " title " | cut -c 11-) #year=$(cmus-remote -Q | grep " date " | cut -c 10-) echo "$status: $artist - $title ($posmins:$possecs / $durmins:$dursecs)" fi