From dde9c3f8284d6d425b0ba6d11c19f1ae74db5127 Mon Sep 17 00:00:00 2001 From: winston Date: Thu, 4 Aug 2022 05:31:12 +0200 Subject: [PATCH] fix(polybar): fix mullvad/music modules --- dot_local/bin/executable_media-status | 23 +++++++++++++++++++++++ dot_local/bin/executable_mullvad-status | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 dot_local/bin/executable_media-status diff --git a/dot_local/bin/executable_media-status b/dot_local/bin/executable_media-status new file mode 100644 index 0000000..8e89b0b --- /dev/null +++ b/dot_local/bin/executable_media-status @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +if ! [[ -x "$(command -v playerctl)" ]]; then + echo "install playerctl" + exit 1 +fi + +while read -r LINE; do + if [[ $LINE == "No players found" ]]; then + ICON="" + OUTPUT="" + else + STATE=$(echo "$LINE" | cut -d " " -f1) + OUTPUT=$(echo "$LINE" | cut -d " " -f2-) + if [[ $STATE == "Paused" ]]; then + ICON="" + else + ICON="" + fi + fi + + echo "$ICON" "${OUTPUT}" +done < <(playerctl metadata -f '{{status}} {{artist}} - {{title}}' -F) diff --git a/dot_local/bin/executable_mullvad-status b/dot_local/bin/executable_mullvad-status index 3c6d254..5f3a2e9 100644 --- a/dot_local/bin/executable_mullvad-status +++ b/dot_local/bin/executable_mullvad-status @@ -9,7 +9,7 @@ fi while read -r LINE; do if echo "$LINE" | grep -q 'Connected'; then # regex grep the relay, e.g. se7 for sweden-7 - OUTPUT=$(echo "$LINE" | grep -oE "\w{2}\d+") + OUTPUT=$(echo "$LINE" | grep -oP "\w{2}\d+") ICON=" " else ICON=" "