From 202f94f122e90e107f8b28e4c40f832af54ebdab Mon Sep 17 00:00:00 2001 From: Benjamin Palko Date: Sat, 5 Apr 2025 15:40:03 -0400 Subject: [PATCH] play/pause --- widget/Mpris.tsx | 53 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/widget/Mpris.tsx b/widget/Mpris.tsx index 653d373..1009057 100644 --- a/widget/Mpris.tsx +++ b/widget/Mpris.tsx @@ -1,5 +1,7 @@ import { bind, derive, Variable } from "astal"; +import { Gdk } from "astal/gtk4"; import AstalMpris from "gi://AstalMpris"; +import { Mathf } from "../util/Mathf"; function IntegerToMinuteSeconds(value: number) { const minutes = Math.floor(value / 60); @@ -12,8 +14,9 @@ function FormatLabel(player: { artist: string; position: number; length: number; + status: AstalMpris.PlaybackStatus; }) { - return `${player.title} - ${player.artist} [${IntegerToMinuteSeconds(player.position)}/${IntegerToMinuteSeconds(player.length)}]`; + return `${player.status === AstalMpris.PlaybackStatus.PLAYING ? "" : ""} ${player.title} - ${player.artist} [${IntegerToMinuteSeconds(player.position)}/${IntegerToMinuteSeconds(player.length)}]`; } const Mpris = function () { @@ -33,20 +36,40 @@ const Mpris = function () { const activePlayer = players[index]; return ( -