-
-
Notifications
You must be signed in to change notification settings - Fork 653
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
376 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#pragma once | ||
|
||
#include <iostream> | ||
#include <string> | ||
|
||
#include "ALabel.hpp" | ||
#include "glibconfig.h" | ||
#include "gtkmm/box.h" | ||
#include "gtkmm/label.h" | ||
|
||
extern "C" { | ||
#include <playerctl/playerctl.h> | ||
} | ||
|
||
namespace waybar::modules::mpris { | ||
|
||
class Mpris : public AModule { | ||
public: | ||
Mpris(const std::string&, const Json::Value&); | ||
~Mpris(); | ||
auto update() -> void; | ||
bool handleToggle(GdkEventButton* const&); | ||
|
||
private: | ||
const std::string DEFAULT_FORMAT = "{player} ({status}): {dynamic}"; | ||
|
||
static void nameAppeared_cb(PlayerctlPlayerManager*, PlayerctlPlayerName*, gpointer); | ||
static void playerVanished_cb(PlayerctlPlayerManager*, PlayerctlPlayer*, gpointer); | ||
static void playerPlay_cb(PlayerctlPlayer*, gpointer); | ||
static void playerMetadata_cb(PlayerctlPlayer*, GVariant*, gpointer); | ||
PlayerctlPlayer* get_top_player(PlayerctlPlayerManager*); | ||
std::string getIcon(const std::string &); | ||
|
||
Gtk::Box box_; | ||
Gtk::Label label_; | ||
|
||
// config | ||
std::string format = DEFAULT_FORMAT; | ||
std::string format_playing = ""; | ||
std::string format_paused = ""; | ||
std::string format_stopped = ""; | ||
|
||
PlayerctlPlayerManager *manager; | ||
std::string lastStatus; | ||
std::string lastPlayer; | ||
}; | ||
|
||
} // namespace waybar::modules::mpris |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
waybar-upower(5) | ||
|
||
# NAME | ||
|
||
waybar - MPRIS module | ||
|
||
# DESCRIPTION | ||
|
||
The *mpris* module displays currently playing media via libplayerctl.++ | ||
By default the following actions use libplayerctl to interact with the player: | ||
|
||
*on-click*: play-pause++ | ||
*on-middle-click*: previous track++ | ||
*on-right-click*: next track | ||
|
||
# CONFIGURATION | ||
|
||
*format*: ++ | ||
typeof: string ++ | ||
default: {player} ({status}) {dynamic} ++ | ||
The text format. | ||
|
||
*format-[status]*: ++ | ||
typeof: string ++ | ||
The text status-specific format. | ||
|
||
*format-icons*: ++ | ||
typeof: map[string]string | ||
Allows setting "{status-icon}" and "{player-icon}" | ||
|
||
*on-click*: ++ | ||
typeof: string | ||
Overwrite default action toggles | ||
|
||
# FORMAT REPLACEMENTS | ||
|
||
*{player}*: The name of the current media player | ||
|
||
*{status}*: The current status (playing, paused, stopped) | ||
|
||
*{artist}*: The artist of the current track | ||
|
||
*{album}*: The album title of the current track | ||
|
||
*{title}*: The title of the current track | ||
|
||
*{dynamic}*: Dynamically concatenates "{artist} - {album} - {title}", based++ | ||
on if the values are populated by the player | ||
|
||
*{player-icon}*: Chooses an icon from "format-icons" based on "{player}" | ||
|
||
*{status-icon}*: Chooses an icon from "format-icons" based on "{status}" | ||
|
||
# EXAMPLES | ||
|
||
``` | ||
"mpris": { | ||
"format": "{player_icon} {dynamic}", | ||
"format-paused": "{status_icon} <i>{dynamic}</i>", | ||
"format-icons": { | ||
"default": "♫", | ||
"paused": "⏸", | ||
"playing": "⏵", | ||
"stopped": "⏹", | ||
} | ||
} | ||
``` | ||
|
||
# STYLE | ||
|
||
- *#mpris* | ||
- *#mpris.[status]* | ||
- *#mpris.[player]* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.