> Now that we have request_sleep() we can add a new internal KS_Cmd_Sleep > keycode, map it into the macbook keyboard, catch in wskbd and go to sleep. > > ok?
> --- sys/dev/usb/ukbdmap.c > +++ sys/dev/usb/ukbdmap.c > @@ -176,6 +176,7 @@ static const keysym_t ukbd_keydesc_us[] = { > KC(127), KS_AudioMute, > KC(128), KS_AudioRaise, > KC(129), KS_AudioLower, > + KC(130), KS_Cmd_Sleep, > KC(224), KS_Cmd1, KS_Control_L, > KC(225), KS_Shift_L, > KC(226), KS_Cmd2, KS_Alt_L, This file is generated, so the changes would be lost eventually. You should add this in makemap.awk in the block starting at line 330. Also, that block mentions the use of keysym 102 for suspend, rather than 130 (which you probably picked randomly), so I would prefer if you would use 102, this would allow this feature to also work on more systems. > --- sys/dev/wscons/wskbd.c > +++ sys/dev/wscons/wskbd.c > @@ -1513,6 +1513,11 @@ internal_command(struct wskbd_softc *sc, u_int *type, > if (*type != WSCONS_EVENT_KEY_DOWN) > return (0); > > +#ifdef SUSPEND > + if (ksym == KS_Cmd_Sleep) > + return request_sleep(SLEEP_SUSPEND); > +#endif I think you should return 1 regardless of the result of request_sleep().