taffybar-4.0.2: A desktop bar similar to xmobar, but with more GUI

Copyright | (c) Ivan A. Malison
License | BSD3-style (see LICENSE)
Maintainer | Ivan A. Malison
Stability | unstable
Portability | unportable
Safe Haskell | Safe-Inferred
Language | Haskell2010

System.Taffybar.Widget.MPRIS2

Description

This is a "Now Playing" widget that listens for MPRIS2 events on DBus. You can find the MPRIS2 specification here at (https://specifications.freedesktop.org/mpris-spec/latest/).

Synopsis

- mprisLog :: (MonadIO m, Show t) => Priority -> String -> t -> m ()
- type WidgetAdder a m = (IsDescendantOf Widget a, MonadIO m, GObject a) => a -> m ()
- type UpdateMPRIS2PlayerWidget a = (forall w. WidgetAdder w IO) -> Maybe a -> Maybe NowPlaying -> TaffyIO a
- data MPRIS2Config a = MPRIS2Config {
  - mprisWidgetWrapper :: Widget -> IO Widget
  - updatePlayerWidget :: UpdateMPRIS2PlayerWidget a
  }
- defaultMPRIS2Config :: MPRIS2Config MPRIS2PlayerWidget
- data MPRIS2PlayerWidget = MPRIS2PlayerWidget {
  - playerLabel :: Label
  - playerWidget :: Widget
  }
- data SimpleMPRIS2PlayerConfig = SimpleMPRIS2PlayerConfig {
  - setNowPlayingLabel :: NowPlaying -> IO Text
  - showPlayerWidgetFn :: NowPlaying -> IO Bool
  }
- defaultPlayerConfig :: SimpleMPRIS2PlayerConfig
- makeExcept :: String -> (a -> IO (Maybe b)) -> a -> ExceptT String IO b
- loadIconAtSize :: Client -> BusName -> Int32 -> IO Pixbuf
- simplePlayerWidget :: SimpleMPRIS2PlayerConfig -> UpdateMPRIS2PlayerWidget MPRIS2PlayerWidget
- mpris2New :: TaffyIO Widget
- mpris2NewWithConfig :: MPRIS2Config a -> TaffyIO Widget
- playingText :: MonadIO m => Int -> Int -> NowPlaying -> m Text

# Documentation

mprisLog :: (MonadIO m, Show t) => Priority -> String -> t -> m () Source #

type WidgetAdder a m = (IsDescendantOf Widget a, MonadIO m, GObject a) => a -> m () Source #

A type representing a function that produces an IO action that adds the provided widget to some container.

type UpdateMPRIS2PlayerWidget a = (forall w. WidgetAdder w IO) -> Maybe a -> Maybe NowPlaying -> TaffyIO a Source #

The type of a customization function that is used to update a widget with the provided now playing info. The type a should be the internal state used for the widget (typically just references to the child widgets that may need to be updated ). When the provided value is nothing, it means that the widget does not exist yet and it should be instantiated. When the provided NowPlaying value is Nothing, the dbus client is no longer, and typically the widget should be hidden.

data MPRIS2Config a Source #

Configuration for an MPRIS2 Widget

Constructors

MPRIS2Config |

Fields

- mprisWidgetWrapper :: Widget -> IO Widget

  A function that will be used to wrap the outer MPRIS2 grid widget

- updatePlayerWidget :: UpdateMPRIS2PlayerWidget a

  This function will be called to instantiate and update the player widgets of each dbus player client. See the docstring for `UpdateMPRIS2PlayerWidget` for more details.

defaultMPRIS2Config :: MPRIS2Config MPRIS2PlayerWidget Source #

data MPRIS2PlayerWidget Source #

Constructors

MPRIS2PlayerWidget |

Fields

- playerLabel :: Label
- playerWidget :: Widget

data SimpleMPRIS2PlayerConfig Source #

Constructors

SimpleMPRIS2PlayerConfig |

Fields

- setNowPlayingLabel :: NowPlaying -> IO Text
- showPlayerWidgetFn :: NowPlaying -> IO Bool

#### Instances

Instances details

Default SimpleMPRIS2PlayerConfig Source # |
Instance details Defined in System.Taffybar.Widget.MPRIS2 Methods def :: SimpleMPRIS2PlayerConfig #

defaultPlayerConfig :: SimpleMPRIS2PlayerConfig Source #

makeExcept :: String -> (a -> IO (Maybe b)) -> a -> ExceptT String IO b Source #

loadIconAtSize :: Client -> BusName -> Int32 -> IO Pixbuf Source #

simplePlayerWidget :: SimpleMPRIS2PlayerConfig -> UpdateMPRIS2PlayerWidget MPRIS2PlayerWidget Source #

This is the default player widget constructor that is used to build mpris widgets. It provides only an icon and NowPlaying text.

mpris2New :: TaffyIO Widget Source #

Construct a new MPRIS2 widget using the `simplePlayerWidget` constructor.

mpris2NewWithConfig :: MPRIS2Config a -> TaffyIO Widget Source #

Construct a new MPRIS2 widget with the provided configuration.

playingText :: MonadIO m => Int -> Int -> NowPlaying -> m Text Source #

Generate now playing text with the artist truncated to a maximum given by the first provided int, and the song title truncated to a maximum given by the second provided int.