Subject: Re: Hotkey support via powerd
To: Jared D. McNeill <jmcneill@invisible.ca>
From: Steven M. Bellovin <smb@cs.columbia.edu>
List: tech-kern
Date: 12/22/2007 12:47:15
On Sat, 22 Dec 2007 11:54:55 -0500 (EST)
"Jared D. McNeill" <jmcneill@invisible.ca> wrote:

> On Sat, 22 Dec 2007, Steven M. Bellovin wrote:
> > So other laptops would need their own model-specific driver?
> > Wouldn't that still necessitate something other than those
> > #defines?  (Or rather, they should be in thinkpad.h, I'd guess.)
> 
> Things like "display switch" hotkeys are not unique to Thinkpads.

That one, sure, but all of them?  Other buttons?  
> 
> >> Volume events don't need to be passed to userland -- pmf can handle
> >> them just fine in the kernel. The "Access IBM" button is the same
> >> as my "ThinkVantage" button, which is delivered to powerd as a
> >> PSWITCH_HK_VENDOR_BUTTON.
> >
> > The question is user feedback.  Many interfaces -- Windows, I think
> > Gnome/Ubuntu, my mobile phone, my television, etc., display
> > something to show the relative volume level when I change it.  If
> > the events aren't passed to userlevel, displaying that is hard.  Of
> > course, I'm not saying that powerd is the best way to pass that
> > info to userlevel -- see below -- but I think we need some way.
> 
> So what I would like to do for those devices, is deliver the events
> to powerd. The script handling volume presses can inject keycodes
> back to wsmux1 if it doesn't want to handle it directly.

Hmm, ok, though I'll have to figure out how to trigger a user-level
process independent of what window has the focus.
> 
> >> powerd runs scripts as root. We do, however, need to find out who
> >> is running X -- right now my scripts are pretty stupid and assume
> >> the owner of /dev/console is the X user.
> >>
> > I know it runs things as root now -- that's the problem...  I want
> > some mechanism for user control on certain events.  For example,
> > the MUA I use (pkgsrc/mail/claws-mail) gets unhappy if its local IP
> > address changes while it has connections open, but that happens
> > frequently after a suspend/resume.  I'd like to run a command to
> > tell it to go offline when I suspend.  Similarly, I sometimes like
> > to run a command to lock my screen when I suspend.
> 
> What exactly is the problem? This can all be scripted.

I'm looking for a clean solution.  Right now, my scripts assume that
'smb' is the only person of interest.  In about two weeks, that won't
be a valid assumption for my T42.
> 
> > Figuring out who's running X is certainly a necessary step.  The
> > next problem, though, is figuring out what scripts that particular
> > user wants to run.  I'm looking for the analog of user crontabs.
> 
> I feel that you're overcomplicating the issue.
> 
> So let me ask you -- do you actually have a technical issue against
> delivering hotkey events via powerd?
> 
I never said I did.  In fact, my original note said "Excellent idea (I
look forward to using it)".  I do, however, have user-level
requirements, and I want to understand how to meet them with your
kernel-level solution.

We obviously have different styles of work.  (We've been over that in a
previous discussion...)  What meets your needs may not meet mine.  In
this case, I see a strong need to pass keyboard events to a user
process; powerd is a root process.  I'm simply inquiring what the
interface is.

		--Steve Bellovin, http://www.cs.columbia.edu/~smb