FDH2 / UxPlay

AirPlay Unix mirroring server
GNU General Public License v3.0
1.35k stars 72 forks source link

Need to disable power saving #71

Closed amardhruva closed 2 years ago

amardhruva commented 2 years ago

The app needs to suppress the power saving mechanisms of the desktop environment as prolonged idleness causes the screen to dim and get locked.

amardhruva commented 2 years ago

This would be a amazing feature as currently we need to disable dimming of screen ourselves.

fduncanh commented 2 years ago

can you explain what you are asking about, and describe your issue better.

What is the UxPlay issue?

math-gout commented 2 years ago

I think this is more of a feature request. Most desktop tend to lock the screen after a certain amount of time of inactivity, and the idea would be to add an option to UxPlay to prevent that.

fduncanh commented 2 years ago

how would such a thing be done??

Does this locking happen even if there is an active connection from a client to uxplay?

If activity on the uxplay terminal screen during an active connection would help, try the option -FPSdata

This displays some video connection data (mainly framerate) , sent from the iOS client once per second

math-gout commented 2 years ago

That I have no idea, I don't even know if it is possible

fduncanh commented 2 years ago

I still dont understand what the aim is.

The app needs to suppress the power saving mechanisms of the desktop environment as prolonged idleness causes the screen to dim and get locked.

Does something bad happen if UxPlay is running, but idle, and the screen-saver dims the screen? I need a better explanation of what the issue is.

Or is Uxplay streaming something, and the screen saver comes on while it is streaming?

fduncanh commented 2 years ago

Please reopen with more details if this really is a UxPlay problem.

amardhruva commented 2 years ago

Sorry, Have been busy with a few other things. This is not a issue but a feature request. What I want is for uxplay to suppress the power management of de(GNOME) while the application is running. This is what media players do when some video is playing back. https://wiki.gnome.org/Attic/GnomePowerManager/FAQ#How_do_I_make_my_application_stop_the_computer_auto-suspending.3F. Here is some documentation which i found for gnome.

amardhruva commented 2 years ago

@fduncanh I dont have permissions to reopen closed issues. Can you please reopen this?

fduncanh commented 2 years ago

This is outside my expertise range. The gnome doc is very old. Uxplay is not gnome-specific.

Do I understand that the issue is

(1) that you have started uxplay, but it is not connected to a client and waiting for a connection, and the computer goes to sleep, blocking any future connection,

or is it

(2) e.g., A long video is streaming from the client to UxPlay, and the computer goes to sleep while uxplay is receiving the stream,as nothing is happening on its keyboard?

From your post, I guess its (2)?

fduncanh commented 2 years ago

This probably useless advice from the web is the issue , I guess

Originally Answered: how do I make my computer not go to sleep while I'm watching videos?

When you're watching video, your OS considers your computer idle. The way to avoid it going to
 sleep is to nudge the mouse or touchpad intermittently.

Your computer is not idle while you are using the mouse or keyboard.

Otherwise, you will need to set your sleep time to at least the length of the video.
fduncanh commented 2 years ago

There are three types of regular events at intervals of 1, 2, and 3 secs respectively while the client is connected to the server which are detected by UxPlay. I suppose one of them could be used to optionally send some kind of "ping" to something on the server host. Do you have any suggestions? On linux we have gnome kde and a number of other desktop environments. Uxplay also supports macOS and OpenBSD. Is there any common standard? It would have to be an option, hopefully as generic as possible. Please research this, and let me know.

All I can do is add an option for uxplay to "do something" once per second or once per 3 secs. You would need to suggest what it should do.

fduncanh commented 2 years ago

In the AirPlay protocol:

Once every second, the client sends a summary of transmission quality statistics to the uxplay server. uxplay ignores it, but detects its reception and can display it in the terminal with the -FPSdata option.

Once every 2 secs the client sends a "heartbeat" request to the server asking if the server is still there and listening. The server has to reply "OK" otherwise the client gives up after a few failures, and assumes the server is dead, so it disconnects.

Once every three 3 secs the server (uxplay) asks the client for a timestamp to measure the latency of the connection. If no reply is received after 5 consecutive attempts, the server concludes the client is gone, and resets (drops) the connection, becoming available for a new client. (the limit 5 can be changed with the -reset n option)

these events are independent of each other.

fduncanh commented 2 years ago

various links from googling:

https://archived.forum.manjaro.org/t/prevent-system-from-going-to-sleep-suspend-during-playing-video-on-youtube-firefox-de-xfce/74879

https://forums.linuxmint.com/viewtopic.php?t=289583

https://superuser.com/questions/99391/prevent-display-from-turning-off-due-to-inactivity-when-watching-full-screen-vid

fduncanh commented 2 years ago

if @flashrocket or @math-gout want to investigate this and find out what the modern solution is, something could probably be done. Apparently (at least, according to one of the above links) VLC has such a feature, and it works in lots of environments.

amardhruva commented 2 years ago

@fduncanh This has nothing to do with video playback. What i meant is the following workflow. Hopefully this clears some confusion.

  1. start uxplay on linux pc(GNOME)
  2. use airplay feature to cast second screen from mac
  3. after about 5 minutes the linux display dims and sleeps as no input has been recieved. :(
fduncanh commented 2 years ago

OK its the same issue as the video, or perhaps simpler.
https://arnaudr.io/2020/09/25/inhibit-suspending-the-computer-with-gtkapplication/

fduncanh commented 2 years ago

How about this?

http://manpages.ubuntu.com/manpages/bionic/man1/systemd-inhibit.1.html

https://www.freedesktop.org/wiki/Software/systemd/inhibit/

Does this do what you want,? please test it.

fduncanh commented 2 years ago

or this? https://fostips.com/prevent-screen-dimming-blank-ubuntu-linux/

fduncanh commented 2 years ago

It's clear that stopping screen dimming is a complex issue, and uxplay has no gtk in it.

I'm closing again, but please post test results with Caffeine or systemd-inhibit, which may solve the issue as workarounds.