From 36680fd035d742e1db88d763bc5c40b2291c335a Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 22 Nov 2016 19:47:30 +0100 Subject: [PATCH] Added cmus script --- README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ cmus | 25 +++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100755 cmus diff --git a/README.md b/README.md index 549273e..47a08e9 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,48 @@ color=#00FF00 interval=30 ``` +# cmus + +## Description +Prints current song playing in [cmus](https://cmus.github.io/) + +## Source +```shell +#!/bin/sh + +ICON_PLAY="➤" +ICON_PAUSE="Ⅱ" +ICON_STOP="≠" +CUR_ICON="" + +INFO_ARTIST=$(cmus-remote -Q | grep ' artist ' | cut -d ' ' -f3-) +INFO_ALBUM=$(cmus-remote -Q | grep ' album ' | cut -d ' ' -f3-) +INFO_TITLE=$(cmus-remote -Q | grep ' title ' | cut -d ' ' -f3-) + +PLAYER_STATUS=$(cmus-remote -Q | grep 'status' | cut -d ' ' -f2-) + +if [[ "${PLAYER_STATUS}" = "paused" ]]; then + CUR_ICON="${ICON_PAUSE}" +elif [[ "${PLAYER_STATUS}" = "playing" ]]; then + CUR_ICON="${ICON_PLAY}" +else + CUR_ICON="${ICON_STOP}" +fi + +if [[ "${INFO_TITLE}" != "" ]] && [[ "${INFO_ARTIST}" != "" ]]; then + echo "${INFO_ARTIST} - ${INFO_TITLE} ${CUR_ICON}" + echo "${INFO_ARTIST} - ${INFO_TITLE} ${CUR_ICON}" +fi +``` + +## i3blocks config +```shell +[cmus] +label= +command=~/i3blocks/cmus +interval=5 +``` + # License This theme is released under the MIT License. For more information read the [license][license]. diff --git a/cmus b/cmus new file mode 100755 index 0000000..3815c75 --- /dev/null +++ b/cmus @@ -0,0 +1,25 @@ +#!/bin/sh + +ICON_PLAY="➤" +ICON_PAUSE="Ⅱ" +ICON_STOP="≠" +CUR_ICON="" + +INFO_ARTIST=$(cmus-remote -Q | grep ' artist ' | cut -d ' ' -f3-) +INFO_ALBUM=$(cmus-remote -Q | grep ' album ' | cut -d ' ' -f3-) +INFO_TITLE=$(cmus-remote -Q | grep ' title ' | cut -d ' ' -f3-) + +PLAYER_STATUS=$(cmus-remote -Q | grep 'status' | cut -d ' ' -f2-) + +if [[ "${PLAYER_STATUS}" = "paused" ]]; then + CUR_ICON="${ICON_PAUSE}" +elif [[ "${PLAYER_STATUS}" = "playing" ]]; then + CUR_ICON="${ICON_PLAY}" +else + CUR_ICON="${ICON_STOP}" +fi + +if [[ "${INFO_TITLE}" != "" ]] && [[ "${INFO_ARTIST}" != "" ]]; then + echo "${INFO_ARTIST} - ${INFO_TITLE} ${CUR_ICON}" + echo "${INFO_ARTIST} - ${INFO_TITLE} ${CUR_ICON}" +fi