samcday / archlinux-msm8916

2 stars 0 forks source link

Buttons in initramfs #16

Closed samcday closed 6 months ago

samcday commented 6 months ago

Can I make them toggle dracut?

samcday commented 6 months ago

So at least on the samsung-a5 + samsung-gt510, the power button is code 116.

So if I want to make the power button toggle Dracut, I just need to insert a keymap that maps code 116 -> code 1. Inserting that keymap looks to be quite simple in both dracut and mkinitcpio.

samcday commented 6 months ago

I don't know why I keep saying "dracut" instead of "plymouth". I did it in the original comment and the follow-up. Cringe...

samcday commented 6 months ago

Sigh. This could/should have been simple. Plymouth 22.x inadvertently already worked when I tested it on pmOS a few weeks ago. It turns out that was somewhat accidental as a result of the "legacy" way that input was handled in the past.

Now, some bozo on a crusade to kill Linux VT support (yes, really) who thinks it's better to put another 12mb in the early initfs and run an entire FUCKING Wayland session + cage for emergency console, has managed to get changes into Plymouth that switch it to use god damn fucking XKB files instead of the much simpler KEYMAP stuff. It gets more insane: they parse XKBLAYOUT + friends from /etc/vconsole.conf, but if you go searching on the internet there's effectively ZERO references to this. It's not documented anywhere except some Github pull requests in systemd.

I spent a little while trying to figure out how I might create an xkb layout thingie that maps phone buttons but ... I really don't want to learn xkb crap. It doesn't seem like it's used anywhere in Wayland and X11 is on the way out ...

samcday commented 6 months ago

Okay never mind, most of the rant was unnecessary (except the part about replacing VT with cage ... as if early user-space in most distros isn't brittle enough already wtf). Looks like keymap still works. It's just that the power button in particular isn't working. When I tried remapping the home button to escape that seems to work okay.

samcday commented 6 months ago

Well anyway what works is to add a custom keymap:

$ cat /usr/share/kbd/keymaps/samsung.map 
keycode 172 = Escape

And then use it in vconsole.conf:

cat /etc/vconsole.conf
KEYMAP=samsung

mkinitcpio (and dracut, probs) will ensure the keymap gets included in initramfs.

The 172 keycode is the home button on the samsung-a5 and samsung-gt510 at least.

I'm not really sure how to package this for redistribution, though. Problems:

1) Messing with /etc/vconsole.conf isn't really portable and someone might want to use vconsole keymap config for legitimate purposes. 2) The home button keycode is very likely to be different on other devices. I don't want to add device-specific packaging (at least not yet. not unless I really have to).

So I'll leave this issue open for now. Maybe it'll just be a wiki entry somewhere or something...

samcday commented 6 months ago

While I remember...

The other way this can be achieved is to add rd.vconsole.keymap=samsung to cmdline. But in that case the keymap has to be explicitly included in initramfs (mkinitcpio: FILES+=(/usr/share/kbd/keymaps/samsung.map)`