From 3edc080e0f2d8972ab6ff56bc17e22fb66da561b Mon Sep 17 00:00:00 2001 From: retrozinndev Date: Fri, 10 Jan 2025 20:02:18 -0300 Subject: [PATCH] :recycle: eww(scripts/mediaplayer): handle artUrl type on script instead of yuck --- eww/scripts/mediaplayer.py | 7 ++++++- eww/variables.yuck | 5 ----- eww/widgets/big-media.yuck | 4 ++-- eww/widgets/control-center/tiles.yuck | 10 +++++----- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/eww/scripts/mediaplayer.py b/eww/scripts/mediaplayer.py index 6415442..038b886 100755 --- a/eww/scripts/mediaplayer.py +++ b/eww/scripts/mediaplayer.py @@ -127,12 +127,17 @@ class PlayerManager: def write_output(self, text, player): logger.debug(f"Writing output: {text}") + artUrl = player.print_metadata_prop("mpris:artUrl") + + if artUrl is not None and not artUrl.startswith("file://") and not artUrl.startswith("http://") and not artUrl.startswith("https://") and artUrl != "null": + artUrl = f"file://{artUrl}" + output = { "status": player.props.status.lower(), "title": player.get_title(), "artist": player.get_artist(), "player": player.props.player_name.lower(), - "artUrl": player.print_metadata_prop("mpris:artUrl"), + "artUrl": artUrl, "length": player.print_metadata_prop("mpris:length"), "url": player.print_metadata_prop("xesam:url") } diff --git a/eww/variables.yuck b/eww/variables.yuck index cc037bb..6b4893b 100644 --- a/eww/variables.yuck +++ b/eww/variables.yuck @@ -52,11 +52,6 @@ (defpoll notification_modes :interval "1s" `makoctl mode | xargs`) -(defpoll media_shuffle_status :interval "1.5s" - :run-while { json_media.player != "" - && json_media.player != "null" } -`playerctl shuffle`) - (defpoll is_recording :interval "1s" `sh -c "[[ -f $HOME/.cache/recording.lock ]] && echo true || echo false"`) diff --git a/eww/widgets/big-media.yuck b/eww/widgets/big-media.yuck index 02b11de..0fc4abf 100644 --- a/eww/widgets/big-media.yuck +++ b/eww/widgets/big-media.yuck @@ -1,6 +1,6 @@ (defwidget big-media [ show-album-bg show-album-image ?album-image-size ?style ?visible ] (box :class "big-media ${ show-album-bg ? 'album-bg' : '' } ${ show-album-image ? 'album-image' : '' }" - :style "${ show-album-bg ? "background-image: url(\"${ json_media.artUrl =~ "^(http(.*)://(.*))$" ? json_media.artUrl : "${ "${ json_media.artUrl =~ "^(file://(.*))$" ? '' : 'file://' }" + json_media.artUrl }" }\")" : "" }; ${style}" + :style "${ show-album-bg ? "background-image: url(\"${ json_media.artUrl != "null" ? json_media.artUrl : '' }\")" : "" }; ${style}" :visible { visible == false ? false : true } :space-evenly false :orientation "vertical" @@ -12,7 +12,7 @@ (box :class "album-image" :width { album-image-size != "" ? album-image-size : 98 } :height { album-image-size != "" ? "${album-image-size - 11}" : 87 } - :style "background-image: url('${ json_media.artUrl =~ "^(http(.*)://(.*))$" ? json_media.artUrl : "${ "${ json_media.artUrl =~ "^(file://(.*))$" ? '' : 'file://' }" + json_media.artUrl }" }');" + :style "background-image: url(\"${ json_media.artUrl != "null" ? json_media.artUrl : "" }\");" :valign "center" :visible { json_media.artUrl == "null" || !show-album-image ? false : true }) diff --git a/eww/widgets/control-center/tiles.yuck b/eww/widgets/control-center/tiles.yuck index a5359e8..9c31824 100644 --- a/eww/widgets/control-center/tiles.yuck +++ b/eww/widgets/control-center/tiles.yuck @@ -5,17 +5,17 @@ (tile :icon '󰤨' :label "Network" :enabled { network_status == "full" ? true : false } - :onenable "nmcli n on" - :ondisable "nmcli n off" + :onenable "nmcli n on > /dev/null" + :ondisable "nmcli n off > /dev/null" :visible true :class "network") (tile :icon '󰂯' :label "Bluetooth" :enabled { bluetooth_powered == "yes" ? true : false } - :onenable "bluetoothctl power on" - :ondisable "bluetoothctl power off" - :visible true) + :onenable "bluetoothctl power on > /dev/null" + :ondisable "bluetoothctl power off > /dev/null" + :visible { bluetooth_powered == "" ? false : true }) (tile :icon '󰍶' :label "Do Not Disturb"