Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mpris module #1520

Merged
merged 1 commit into from
Jan 6, 2023
Merged

Add mpris module #1520

merged 1 commit into from
Jan 6, 2023

Conversation

robertgzr
Copy link
Contributor

No description provided.

@robertgzr
Copy link
Contributor Author

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 :)

@Suyashtnt
Copy link

updates on this?

@robertgzr robertgzr force-pushed the mpris-module branch 5 times, most recently from ac9ebfc to d9bcfa6 Compare December 13, 2022 23:52
@robertgzr robertgzr force-pushed the mpris-module branch 2 times, most recently from 9f9ed15 to 069cdcd Compare January 6, 2023 19:08
@robertgzr robertgzr marked this pull request as ready for review January 6, 2023 19:09
@robertgzr robertgzr force-pushed the mpris-module branch 2 times, most recently from 250fbf7 to 207b462 Compare January 6, 2023 19:50
@robertgzr
Copy link
Contributor Author

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.

Uses libplayerctl to use the MPRIS dbus protocol to query, listen and
control media players.

Signed-off-by: Robert Günzler <r@gnzler.io>
@Alexays
Copy link
Owner

Alexays commented Jan 6, 2023

LGTM, can you also add the man to the github wiki?

@Alexays Alexays merged commit 86850f5 into Alexays:master Jan 6, 2023
@colemickens
Copy link
Contributor

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.                                    

@robertgzr
Copy link
Contributor Author

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

robertgzr added a commit to robertgzr/Waybar that referenced this pull request Jan 7, 2023
to address Alexays#1520 (comment)

Signed-off-by: Robert Günzler <r@gnzler.io>
ldelossa pushed a commit to ldelossa/Waybar that referenced this pull request Feb 24, 2023
to address Alexays#1520 (comment)

Signed-off-by: Robert Günzler <r@gnzler.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants