On Tue 23 Jan 2024 at 18:09:00 (-0600), Mike McClain wrote:
> David Wright wrote:
> > You could try running:
> >
> >   $ xmodmap -e 'keycode 124=' # to override XF86PowerOff
> >
> >   $ xmodmap -e 'keycode 150=' # to override XF86Sleep
> >
> >   $ xmodmap -e 'keycode 151=' # to override XF86WakeUp perhaps.
> 
> Given your input I read the xmodmap man page.
> I ran 'xmodmap -pk' and saw the keycode to function mapping as you
> stated.
> 
> I ran the commands you suggested then ran 'xmodmap -pk' again and saw
> that the assignments were cleared. Just to be safe I checked the two
> files I normally keep open were saved then hit the XF86PowerOff button
> and watched my computer shutdown.

Two things: I don't know whether it's necessary to restart the
X server (which might not require rebooting) to make sure that
every part of X is aware of the new mapping.

Also, just check that it really did shutdown and not merely suspend.
I find my ancient noname MS-019O mouse useful in this respect, as
the LEDs inside it stay lit with suspend, but not with poweroff.
If the machine suspended, pressing the key again may wake it up.¹

> I've heard more that once not to believe all you read. With all the
> disinformation on the net by enemies of democracy, both foreign and
> domestic, I take most of the news I read with a grain of salt. I guess
> I need to apply that to Linux man pages too.

Disinformation is malevolent. Misinformation is usually not.

What you might have read about xmodmap will only apply, AIUI,
in an X session. If that's where you spend almost all your time,
then that may be good enough. (I've never used wayland.)

If what I wrote doesn't work, then it may be that we're not
inserting the change into the pathway that the keystroke follows.
So the next place I would try is /etc/systemd/logind.conf where
this line occurs:

  #HandlePowerKey=poweroff

You could try changing it to, say:

  HandlePowerKey=ignore

in the first instance, and seeing whether that made any difference.
(You might have to reboot for the new setting to take effect.)
If so, then you might want the key to suspend instead.

Also be aware that if HandlePowerKey=ignore succeeds, you may
lose the ability to power off with the real, physical switch on
the computer itself, though hard-reset is unaffected. Hence my
suggesting a less invasive manner.

Somewhere between xmodmap and HandlePowerKey there may be a kbd
driver method, but I've never got into that stuff deeply.

I'm aware that none of this will help with your Devuan machine.
I don't know what keyboard you use, but other approaches are
keeping your fingers away, constructing a guard with cut-down
plastic from an old bubble-pack, or using a different keyboard.

¹ That's how my K520 works because, even though the key engraving
  is ⏻ (IEC Power) with PC underneath, it behaves as ⏾, sending
  Suspend.

Cheers,
David.

Reply via email to