[haiku] Blueprint: User idle time component/interface for Haiku OS

  • From: helix84 <helix84@xxxxxxxxxx>
  • To: haiku@xxxxxxxxxxxxx
  • Date: Mon, 14 Dec 2009 16:56:11 +0100

Hello,
I'm sending and idea about a feature which could be added to Haiku.

Although my idea is generally applicable, I'm sending it to Haiku
because it's a _desktop_ system and it's in development.
Let me first say that I'm not very familiar with Haiku design and
terminology (I only tried Haiku once) so I'm posting this idea to the
general mailing list. Feel free to point me to a more appropriate
place to discuss this.


The problem
* many applications need to know how long user has been idle
* currently apps need to monitor user input themselves
* monitored events: last keystroke, mouse movement (possibly input
from other devices)

Why it should be a part of the OS
* these events are _systemwide_, outside the application
* the application shouldn't need to monitor user input outside the
application itself
* many applications do this simultaneously
* enables asynchronous processing (e.g registering a callback)


Use cases:
* Screen saver - launches according to idle time
* Power saving mode - launches according to idle time
* Instant messenger application - switches user status according to idle time
* Notification system - when user is away, send notifications to his cellphone
* Movie player, presentation tool - blocks away status by providing a
device which has zero idle time when playing a movie or a presentation


Pseudocode (just a suggestion):

# provider (OS):
def how_long_has_user_been_idle(devices = [mouse, keyboard, presentation]):
       total_idle_time = 0
       for i in devices:
               if device.idle_time > total_idle_time:
                       total_idle_time = device.idle_time
       return total_idle_time

def register_user_idle_handler(devices, idle_time, callback_function):
       ...


# consumer (IM application):
def switch_to_away:
               IM.mode = away

register_user_idle_handler([mouse, keyboard]), idle_time, switch_to_away)

# consumer (idle time display):
               print how_long_has_user_been_idle([mouse, keyboard])


Regards
~~helix84

Other related posts: