aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2023-02-17 08:29:47 -0300
committerEuAndreh <eu@euandre.org>2023-02-17 08:36:30 -0300
commit89bdbe02747ec6c69dba0b44d3d07f2e1e5088be (patch)
treee7e254eb4ff39c381501a92f015e05b45a1dcab8
parentetc/{xmonad,xmobar}: Add working simplified configurations (diff)
downloaddotfiles-89bdbe02747ec6c69dba0b44d3d07f2e1e5088be.tar.gz
dotfiles-89bdbe02747ec6c69dba0b44d3d07f2e1e5088be.tar.xz
bin/wms: Add "mpris" action
-rwxr-xr-xbin/wms25
1 files changed, 25 insertions, 0 deletions
diff --git a/bin/wms b/bin/wms
index d0a4d7c..d541438 100755
--- a/bin/wms
+++ b/bin/wms
@@ -19,6 +19,7 @@ help() {
- uuid
- date
- clear-notification
+ - mpris
Helper script to launch CLI commands, without having complex
@@ -77,6 +78,24 @@ copy_and_notify() {
"$STR" "$LABEL copied to clipboard"
}
+format_player_name() {
+ if echo "$1" | grep -Eq ^firefox\.instance.*; then
+ echo 'firefox'
+ else
+ echo "$PLAYER"
+ fi
+}
+
+format_player_title() {
+ TITLE="$(playerctl --player="$PLAYER" metadata xesam:title)"
+ LEN="$(echo "$TITLE" | wc -c)"
+ if [ "$LEN" -gt 82 ]; then
+ printf '%s...\n' "$(echo "$TITLE" | head -c 80)"
+ else
+ echo "$TITLE"
+ fi
+}
+
case "$ACTION" in
uuid)
copy_and_notify "$(uuid)" 'UUID'
@@ -87,6 +106,12 @@ case "$ACTION" in
clear-notification)
dunstctl close
;;
+ mpris)
+ PLAYER="$(cat "$XDG_CACHE_HOME"/euandreh-mpris-player.txt)"
+ PLAYER_NAME="$(format_player_name "$PLAYER")"
+ PLAYER_TITLE="$(format_player_title "$PLAYER")"
+ printf '%s: %s\n' "$PLAYER_NAME" "$PLAYER_TITLE"
+ ;;
*)
printf 'Bad ACTION: %s.\n\n' "$ACTION" >&2
usage >&2