caffeine-ng
caffeine-ng copied to clipboard
Caffeine activates automatically and can't be deactivated
I recently decided to upgrade from the old version 2.5 of caffeine that I'd been using to caffeine-ng, on the understanding that caffeine-ng was supposed to work like caffeine used to. However, it doesn't -- when I'm playing music or watching a video or something, caffeine activates by itself, unbidden. If I click the icon and tell it to deactivate, it does briefly, but then reactivates itself again after a second or so.
How can I make caffeine genuinely, truly, completely, absolutely, 100% manually selected and never ever do anything at all under any circumstances whatsoever except for when I have specifically and manually ordered it to do so? Thank you!
I'm facing a similar issue with 3.5.1. After some debugging, and running in terminal to see what's happening, I saw this:
INFO:caffeine.core:Audio playback detected (firefox). Inhibiting.
It seems like it sees Firefox's sound indicator, even though Firefox is playing no sounds, and thinks this means there's something playing. Firefox upon playing any sound will open a pulseaudio channel and keep it open.
It seems like this commit is at fault here :/ I like the idea, but we should have the option to either disable this pulseaudio detection, or blacklist apps, or blacklist activating on audio only.
Hmmm... is firefox not corking nor pausing nor disconnecting streams when there's no playback?
Unfortunately not. The volume icon stays permanently on the FF icon. In KMix, the applications tab, FF will stay there all the time. Not sure if this is standard FF behaviour or unique to my setup, using Firefox on Archlinux with latest KDE/Plasma.
I'd also prefer caffeine to ignore audio. I can confirm a similar behaviour in Firefox, but also I usually just have music playing when at the computer. For me, this doesn't indicate that I want my system to stay awake.
Seems like audio has been controversial. I think it makes sense to have an extra setting to caffeinate when audio is playing
.
Thanks @WhyNotHugo. That sounds like a good compromise to me! Cheers.
I'm facing a similar issue with 3.5.1. After some debugging, and running in terminal to see what's happening, I saw this:
INFO:caffeine.core:Audio playback detected (firefox). Inhibiting.
It seems like it sees Firefox's sound indicator, even though Firefox is playing no sounds, and thinks this means there's something playing. Firefox upon playing any sound will open a pulseaudio channel and keep it open.
I can report the same issue. In my case it's not firefix, it's pavucontrol.
INFO:caffeine.core:Audio playback detected (pavucontrol, pavucontrol, pavucontrol). Inhibiting.
Another false positive: Microsoft Teams. There is no audio playing but it still activates caffeine.
INFO:caffeine.core:Audio playback detected (teams). Inhibiting.
Firefox does not properly cork when not playing, hence, it's picked up as playing. Upstream issue here: https://bugzilla.mozilla.org/show_bug.cgi?id=1638685
Opening pavucontrol also interferes with the status of streams, as mentioned here: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/892#note_502138
I suspect that Discord is on the same page. I still think putting this feature behind a setting caffeinate when audio is playing
is the best option. Regrettably, I don't really have the time or setup any more to address this myself.
Thanks @WhyNotHugo for clarification.
Currently I have pavucontrol open 24/7 to easily switch my configurations e.g. enabling mics only when entering meetings and disabling them afterwards. Does this mean that I have to quit pavucontrol while not using it until a feature like caffeinate when audio is playing
or a sort of ignore applications
feature is developed?
Regrettably, I don't really have the time or setup any more to address this myself.
No worries @WhyNotHugo, that is totally understandable.
Unfortunately for me however, I've had to totally stop using caffeine because of the false positives, especially with Microsoft Teams. I find caffeine super-useful, but my system was just never suspending. I looked at the commit mentioned above, but it looks like this is only a part of the changes, and it couldn't be reversed now anyway, at least with the latest caffeine 3.5.1.
I had a bit of hack through core.py
, and removed some chunks, and I think I've stopped it activating on audio.
--- a/core.py 2021-01-23 16:28:31.000000000 +1100
+++ b/core.py 2021-03-06 17:45:55.606335770 +1100
@@ -67,11 +67,6 @@
# Inhibition has been requested (though it may not yet be active).
self.__inhibition_manually_requested = False
- # Number of procs playing audio but nothing visual. This is a special
- # case where we want the screen to turn off while still preventing
- # the computer from suspending
- self.music_procs = 0
-
# Inhibition has successfully been activated.
self.__inhibition_successful = False
@@ -131,62 +126,9 @@
elif not self.get_activated():
logger.info("Fullscreen app detected. Inhibiting.")
- # Let's look for playing audio:
- # Number of supposed audio only streams. We can turn the screen off
- # for those:
- self.music_procs = 0
- # Number of all audio streams including videos. We keep the screen on
- # here:
- screen_relevant_procs = 0
- # Applications currently playing audio.
- active_applications = []
-
- if not process_running and not fullscreen:
- # Get all audio playback streams
- # Music players seem to use the music role. We can turn the screen
- # off there. Keep the screen on for audio without music role,
- # as they might be videos
- with Pulse() as pulseaudio:
- for application_output in pulseaudio.sink_input_list():
- if (
- not application_output.mute # application audio is not muted
- and not application_output.corked # application audio is not paused
- and not pulseaudio.sink_info(application_output.sink).mute # system audio is not muted
- ):
- if application_output.proplist.get("media.role") == "music":
- # seems to be audio only
- self.music_procs += 1
- else:
- # Video or other audio source
- screen_relevant_procs += 1
- # Save the application's process name
- application_name = application_output.proplist["application.process.binary"]
- active_applications.append(application_name)
-
- # Get all audio recording streams
- for application_input in pulseaudio.source_output_list():
- if (
- not application_input.mute # application input is not muted
- and not pulseaudio.source_info(application_input.source).mute # system input is not muted
- ):
- # Treat recordings as video because likely you don't
- # want to turn the screen of while recording
- screen_relevant_procs += 1
- # Save the application's process name
- application_name = application_input.proplist["application.process.binary"]
- active_applications.append(application_name)
-
- if self.music_procs > 0 or screen_relevant_procs > 0:
- if self.__auto_activated:
- logger.debug(f"Audio playback detected ({', '.join(active_applications)}). No change.")
- elif not self.get_activated():
- logger.info(f"Audio playback detected ({', '.join(active_applications)}). Inhibiting.")
-
if (
process_running
or fullscreen
- or self.music_procs > 0
- or screen_relevant_procs > 0
) and not self.__auto_activated:
self.__auto_activated = True
# TODO: Check __set_activated
@@ -195,14 +137,12 @@
not (
process_running
or fullscreen
- or self.music_procs > 0
- or screen_relevant_procs > 0
)
and self.__auto_activated
):
logger.info(
- "Was auto-inhibited, but there's no fullscreen, whitelisted "
- "process or audio playback now. De-activating."
+ "Was auto-inhibited, but there's no fullscreen or whitelisted "
+ "process now. De-activating."
)
# TODO: Check __set_activated
self.__set_activated(False)
@@ -363,7 +303,7 @@
self.__inhibition_manually_requested = True
# decide, if we allow the screen to sleep
- if self.music_procs > 0 or not self.__inhibition_manually_requested:
+ if not self.__inhibition_manually_requested:
inhibit_screen = False
else:
inhibit_screen = True
@WhyNotHugo This is also an issue on KDE when using Latte Dock. caffeine.core thinks Latte is playing audio (likely because of indicators) and it refuses to deactivate at all.
For me the problem was speech dispatcher. Strangely it was started by systemd even though I had the service disabled. After manually killing it, I am yet to discover any further issues with caffeine.
#56 adds support for disabling the pulseaudio support.
Some internals have changed, so you'll need to manually kill any previous running version first. To install this experimental version, run:
git clone -b next https://github.com/caffeine-ng/caffeine-ng.git
python setup.py build
sudo python setup.py install
sudo glib-compile-schemas /usr/share/glib-2.0/schemas
So I guess I'd just like to re-ask my original question, then: is there any possible way to make Caffeine have an option for being truly manual, and only manual? As in, a way to truly disable absolutely all autodetection or auto-inhibition whatsoever? Just a simple check-box in the preferences to simply turn off autodetection completely. Seriously, sometimes I want to turn on the screensaver while playing a video or something, and I always want software to be able to be told that it should not purport to think on my behalf.
Please, I'm begging you, is there any way to do that?
Oooh, actually, that should be doable.
A new flag should not be hard to add, and I think that separating auto-detections make sense.
Oh, that would be awesome! Thank you!
Current main has flags for --no-whitelist
and --no-fullscreen
to disable these autodetections. See the CHANGLOG for details.
I've leave this issue open for a while in order to gather feedback, since there's been large refactors and there may be issues (I really hope not :sweat: ).
I'll address a checkbox in the settings page at a later time.
I want to drop dependency on python-dbus
in favour of some other package, since the former makes testing and packaging a real pain.
Current main has flags for
--no-whitelist
and--no-fullscreen
to disable these autodetections. See the CHANGLOG for details.
Have these options changed @WhyNotHugo ? I can't seem to find them any more. I had a look through the code and thought I found some relevant options, but these don't seem to work for me.
$ caffeine --no-pulseaudio
Usage: caffeine [OPTIONS] COMMAND [ARGS]...
Try 'caffeine --help' for help.
Error: No such option: --no-pulseaudio
caffeine --help
doesn't give any details either, and the main branch seems to have slimmed these down a bit compared to the last release?
This repository has moved to codeberg.
Follow-up for this issue is at https://codeberg.org/WhyNotHugo/caffeine-ng/issues/39