Waybar
Waybar copied to clipboard
Add mpris module
I have used a custom playerctl
(the binary) based module for a while now. And had constant issues where it doesn't update and I find the process just hanging (maybe due to my awk pipeline used to filter the output)
I just threw this together and I wanted to give it some more testing on my machine... but just to feel out what you folks think I'm opening the PR already :)
updates on this?
I've been running this module ever since opening the PR. made a lot of improvements along the way and now also added a manpage.
it let's you select a specific MPRIS player to attach to, but defaults to playerctld
as a sane default for most use-cases since it automatically follows the most recently active player.
LGTM, can you also add the man to the github wiki?
This is causing a lot of build issues for me:
│[116/139] Compiling C++ object waybar.p/src_modules_mpris_mpris.cpp.o │
│FAILED: waybar.p/src_modules_mpris_mpris.cpp.o │
│g++ -Iwaybar.p -I. -I.. -I../include -Iprotocol -I/nix/store/hyibz7klw5i16jmhmp0qvv1lylyl4svc-wayland-1.21.0-dev/include -I/nix/store/r64f9dmdqisb7ry9qxvs7daypwaaka1a-fmt-8.1.1-dev/include -I/nix/store/2qs3czmbnsx>│
│In file included from ../src/modules/mpris/mpris.cpp:1: │
│../include/modules/mpris/mpris.hpp:38:10: error: 'optional' in namespace 'std' does not name a template type │
│ 38 | std::optional<std::string> artist; │
│ | ^~~~~~~~ │
│../include/modules/mpris/mpris.hpp:15:1: note: 'std::optional' is defined in header '<optional>'; did you forget to '#include <optional>'? │
│ 14 | #include "util/sleeper_thread.hpp" │
│ +++ |+#include <optional> │
│ 15 | │
│../include/modules/mpris/mpris.hpp:39:10: error: 'optional' in namespace 'std' does not name a template type │
│ 39 | std::optional<std::string> album; │
│ | ^~~~~~~~ │
│../include/modules/mpris/mpris.hpp:39:5: note: 'std::optional' is defined in header '<optional>'; did you forget to '#include <optional>'? │
│ 39 | std::optional<std::string> album; │
│ | ^~~ │
│../include/modules/mpris/mpris.hpp:40:10: error: 'optional' in namespace 'std' does not name a template type │
│ 40 | std::optional<std::string> title; │
│ | ^~~~~~~~ │
│../include/modules/mpris/mpris.hpp:40:5: note: 'std::optional' is defined in header '<optional>'; did you forget to '#include <optional>'? │
│ 40 | std::optional<std::string> title; │
│ | ^~~ │
│../include/modules/mpris/mpris.hpp:41:10: error: 'optional' in namespace 'std' does not name a template type │
│ 41 | std::optional<std::string> length; // as HH:MM:SS │
│ | ^~~~~~~~ │
│../include/modules/mpris/mpris.hpp:41:5: note: 'std::optional' is defined in header '<optional>'; did you forget to '#include <optional>'? │
│ 41 | std::optional<std::string> length; // as HH:MM:SS │
│ | ^~~ │
│../include/modules/mpris/mpris.hpp:44:32: error: 'optional' in namespace 'std' does not name a template type │
│ 44 | auto getPlayerInfo() -> std::optional<PlayerInfo>; │
│ | ^~~~~~~~ │
│../include/modules/mpris/mpris.hpp:44:27: note: 'std::optional' is defined in header '<optional>'; did you forget to '#include <optional>'? │
│ 44 | auto getPlayerInfo() -> std::optional<PlayerInfo>; │
│ | ^~~ │
│../include/modules/mpris/mpris.hpp:44:32: error: expected ';' at end of member declaration │
│ 44 | auto getPlayerInfo() -> std::optional<PlayerInfo>; │
│ | ^~~~~~~~ │
│ | ; │
│../include/modules/mpris/mpris.hpp:44:40: error: expected unqualified-id before '<' token │
│ 44 | auto getPlayerInfo() -> std::optional<PlayerInfo>; │
│ | ^ │
│../src/modules/mpris/mpris.cpp:205:6: error: no declaration matches 'std::optional<waybar::modules::mpris::Mpris::PlayerInfo> waybar::modules::mpris::Mpris::getPlayerInfo()' │
│ 205 | auto Mpris::getPlayerInfo() -> std::optional<PlayerInfo> { │
│ | ^~~~~ │
│../src/modules/mpris/mpris.cpp:205:6: note: no functions named 'std::optional<waybar::modules::mpris::Mpris::PlayerInfo> waybar::modules::mpris::Mpris::getPlayerInfo()' │
│In file included from ../src/modules/mpris/mpris.cpp:1: │
│../include/modules/mpris/mpris.hpp:18:7: note: 'class waybar::modules::mpris::Mpris' defined here │
│ 18 | class Mpris : public AModule { │
│ | ^~~~~ │
│../src/modules/mpris/mpris.cpp:205:37: error: 'struct waybar::modules::mpris::Mpris::PlayerInfo' is private within this context │
│ 205 | auto Mpris::getPlayerInfo() -> std::optional<PlayerInfo> { │
│ | ^~~~~~~~~~~~~~~~~~~~ │
│In file included from ../src/modules/mpris/mpris.cpp:1: │
│../include/modules/mpris/mpris.hpp:33:10: note: declared private here │
│ 33 | struct PlayerInfo { │
│ | ^~~~~~~~~~ │
│../src/modules/mpris/mpris.cpp: In member function 'virtual bool waybar::modules::mpris::Mpris::handleToggle(GdkEventButton* const&)': │
│../src/modules/mpris/mpris.cpp:288:15: error: 'getPlayerInfo' was not declared in this scope; did you mean 'PlayerInfo'? │
│ 288 | auto info = getPlayerInfo(); │
│ | ^~~~~~~~~~~~~ │
│ | PlayerInfo │
│../src/modules/mpris/mpris.cpp: In member function 'virtual void waybar::modules::mpris::Mpris::update()': │
│../src/modules/mpris/mpris.cpp:323:14: error: 'getPlayerInfo' was not declared in this scope; did you mean 'PlayerInfo'? │
│ 323 | auto opt = getPlayerInfo(); │
│ | ^~~~~~~~~~~~~ │
│ | PlayerInfo │
│[117/139] Compiling C++ object waybar.p/src_modules_pulseaudio.cpp.o │
│[118/139] Compiling C++ object waybar.p/src_modules_hyprland_submap.cpp.o │
│[119/139] Compiling C++ object waybar.p/src_modules_hyprland_language.cpp.o │
│[120/139] Compiling C++ object waybar.p/src_modules_jack.cpp.o │
│[121/139] Compiling C++ object waybar.p/src_modules_wireplumber.cpp.o │
│[122/139] Compiling C++ object waybar.p/src_modules_hyprland_window.cpp.o │
│[123/139] Compiling C++ object waybar.p/src_modules_gamemode.cpp.o │
│[124/139] Compiling C++ object waybar.p/src_modules_network.cpp.o │
│In file included from ../src/modules/network.cpp:1: │
│../include/modules/network.hpp: In constructor 'waybar::modules::Network::Network(const string&, const Json::Value&)': │
│../include/modules/network.hpp:86:16: warning: 'waybar::modules::Network::rfkill_' will be initialized after [-Wreorder] │
│ 86 | util::Rfkill rfkill_; │
│ | ^~~~~~~ │
│../include/modules/network.hpp:80:9: warning: 'float waybar::modules::Network::frequency_' [-Wreorder] │
│ 80 | float frequency_; │
│ | ^~~~~~~~~~ │
│../src/modules/network.cpp:80:1: warning: when initialized here [-Wreorder] │
│ 80 | waybar::modules::Network::Network(const std::string &id, const Json::Value &config) │
│ | ^~~~~~ │
│[125/139] Compiling C++ object waybar.p/src_modules_sni_tray.cpp.o │
│[126/139] Compiling C++ object waybar.p/src_modules_sni_watcher.cpp.o │
│[127/139] Compiling C++ object waybar.p/src_modules_sni_host.cpp.o │
│ninja: build stopped: subcommand failed.
looks like it's missing
diff --git a/include/modules/mpris/mpris.hpp b/include/modules/mpris/mpris.hpp
index 4f8ddb16..040401f8 100644
--- a/include/modules/mpris/mpris.hpp
+++ b/include/modules/mpris/mpris.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <iostream>
+#include <optional>
#include <string>
#include "gtkmm/box.h"
I didn't see those errors with clang