eonpatapon / gnome-shell-extension-caffeine

Disable screensaver and auto suspend
GNU General Public License v2.0
572 stars 107 forks source link

Enable when playback is detected via MPRIS #217

Open carlocastoldi opened 1 year ago

carlocastoldi commented 1 year ago

MPRIS is a D-Bus API which aims to provide a common programmatic API for controlling media players. In our case, it is interesting because it provides a mechanism for querying compliant media players, including music players and browsers.

Using the MPRIS API to determine if there currently is any media playing sounds like good option for this extension!

eonpatapon commented 1 year ago

Not sure to understand what you are proposing ?

I don't see how MPRIS/music players would interact with Caffeine

eonpatapon commented 1 year ago

Ah you mean maybe an option to enable Caffeine when some player is 'play' status ?

carlocastoldi commented 1 year ago

Ah you mean maybe an option to enable Caffeine when some player is 'play' status ?

yes, correct! Similar to the option that enables caffeine for fullscreen apps

snoopdouglas commented 7 months ago

This feature would be incredibly useful to me, given that I use HDMI audio - so screen off = audio off too.

I've never done any work on GNOME extensions but would be happy to start work on a PR for this. Any pointers would be appreciated.

eonpatapon commented 7 months ago

Excerpts from snoopdouglas's message of February 13, 2024 9:49 am:

This feature would be incredibly useful to me, given that I use HDMI audio - so screen off = audio off too.

I've never done any work on GNOME extensions but would be happy to start work on a PR for this. Any pointers would be appreciated.

MPRIS status is exposed via dbus, so the extension would need to track via DBUS if some player is in playing state.

I think you can look for media player extensions and see how they use the MPRIS Dbus API.

Not the simplest change to do, will add quite some code to the extension.

-- Reply to this email directly or view it on GitHub: https://github.com/eonpatapon/gnome-shell-extension-caffeine/issues/217#issuecomment-1940784815 You are receiving this because you commented.

Message ID: @.***>

carlocastoldi commented 7 months ago

I implemented MPRIS trigger in caffeine-ng. You might want to take a hint on the dbus calls I used. It can be useful: https://codeberg.org/WhyNotHugo/caffeine-ng/src/commit/1c638ba251124adb7e4812b717735f4c35fc3784/caffeine/triggers.py#L248

The PRs are !127 and !146