Re: Show modeline when super key is pressed

Robert Taylor <[email protected]> Mon, 31 Mar 2025 02:19:12 -0700
Newsgroups gmane.comp.window-managers.stumpwm.devel
Message-ID <CAL1n=PEjje29dd2XDsw=p3yWxMBvTv8hNRKHJe1+4GMi6dz0WA@mail.gmail.com>
Whoa. This is nice, thanks!  Thanks to everyone for keeping an eye on
StumpWM, absolutely love seeing stuff like this pop up.

On Tue, Dec 31, 2024 at 2:25=E2=80=AFPM <[email protected]> wrote:
>
>
> I put together a small asdf system to implement the functionality of
> running code on key press/release of a modifier key. Its attached to
> this email as a tarball with a readme. Its cleaner and more extensible
> than the solution I gave earlier, and allows for arbitrary actions
> instead of only mode line toggling.
>
>
>
> <[email protected]> writes:
>
> >>
> >> Some additional code to allow holding super to display the mode line:
> >>
> >> ``` lisp
> >> (defun custom-press-handler (code state)
> >>   (declare (ignore state))
> >>   (let ((super-keycodes (nth-value 6 (xlib:modifier-mapping *display*)=
)))
> >>     (when (member code super-keycodes :test #'=3D)
> >>       (toggle-mode-line (current-screen) (current-head))
> >>       t)))
> >>
> >> (define-stump-event-handler :key-release (code state)
> >>   (declare (ignore state))
> >>   (let ((super-keycodes (nth-value 6 (xlib:modifier-mapping *display*)=
)))
> >>     (when (member code super-keycodes :test #'=3D)
> >>       (toggle-mode-line (current-screen) (current-head))
> >>       t)))
> >>
> >> (setf *custom-key-event-handler* 'custom-press-handler)
> >> ```
> >
> > NB: the above code requires you to grab the super keycode, which for me
> > is 133, though you can find it by calling xlib:modifier-mapping.
> >
> > You can grab it like so in your init file:
> >
> > ``` lisp
> > (xlib:ungrab-key (screen-root (current-screen)) your-super-key-code)
> > ```
>