Sanitize MPRIS metadata newlines while keeping stacked label
This commit is contained in:
@@ -314,6 +314,19 @@ clockWidget =
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
singleLineMprisLabel :: Text -> Text
|
||||||
|
singleLineMprisLabel =
|
||||||
|
T.replace "\n" " " . T.replace "\r" " "
|
||||||
|
|
||||||
|
stackedMprisLabel :: Text -> Text
|
||||||
|
stackedMprisLabel raw =
|
||||||
|
let normalized = singleLineMprisLabel raw
|
||||||
|
(top, rest) = T.breakOn " - " normalized
|
||||||
|
in
|
||||||
|
if T.null rest
|
||||||
|
then normalized
|
||||||
|
else top <> "\n" <> T.drop 3 rest
|
||||||
|
|
||||||
mprisWidget :: TaffyIO Gtk.Widget
|
mprisWidget :: TaffyIO Gtk.Widget
|
||||||
mprisWidget =
|
mprisWidget =
|
||||||
mpris2NewWithConfig
|
mpris2NewWithConfig
|
||||||
@@ -323,9 +336,7 @@ mprisWidget =
|
|||||||
simplePlayerWidget
|
simplePlayerWidget
|
||||||
defaultPlayerConfig
|
defaultPlayerConfig
|
||||||
{ setNowPlayingLabel =
|
{ setNowPlayingLabel =
|
||||||
-- Upstream `playingText` uses "artist - title"; replace the
|
\np -> stackedMprisLabel <$> playingText 20 20 np
|
||||||
-- separator with a newline for a more compact widget.
|
|
||||||
\np -> T.replace " - " "\n" <$> playingText 20 20 np
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user