The problem is that if an external keyboard is plugged in after i3 starts it will default to US layout.
I'd prefer having it run automatically, if no issues comes to mind with doing so, because that will let it have the expected layout when unlocking the screen saver when I set it up on my desk with the external keyboard after having brought it somewhere.
The internal keyboard retains the expected layout.
I've decided to switch to using the US layout by default, it has much better placement of special characters for programming than the Danish one (where most of them are on Shift+number or Right_Alt+number and mostly the high end of the numbers so uncomfortable for touch typing), so unless you have an interest in fixing this just disregard it.
This is a problem for everyone as a newly plugged keyboard won't have things like the caps/esc switch. The thing is, I'm not immediately sure how to solve this by modifying home dotfiles. It might actually require adjusting system settings, which is out of the purview of this repo. I'll double check eventually but others are welcome to provide an easy way to rerun a script when a new usb device is plugged in.
may be use system Udev when a device plugged in run scripts
Well I see that as feature actually.
In gaming or other situations, it's required to feel free without having the fear to press caps lock.
but I guess there is no solution for built-in keyboards to undo this remaps in LARBS systems. (I mean we need another script here to undo binds)
Just came to say if this issue wants to be solved without making new problems, there should be an "undoremaps" script too. OR there should be a way to disable this "automatic rerun remaps" if anybody plans to solve this issue.
I'll try to fix it if felt like it xD' but not really... Sorry for bad English btw.
In ~/.xprofile, I would suggest to add
setxkbmap -device <device ID> -option caps:super <your layout> && killall xcape 2>/dev/null ; xcape -e 'Super_L=Escape' &
right after the line that sets the US intl-deadkeys layout.
you can find <device ID> with xinput -list | grep key (from the xorg-xinput package).
This way, you can have the best of both worlds. Either you make the US layout a default, or you assign it to a specific device (in which case you would use -device for the previous line and not the next)
may be use system Udev when a device plugged in run scripts
Did anybody find a way to implement an udev rule for this? I got a big headache after reading the whole udev arch wiki article...
EDIT for posterity: if anybody wants to try figuring it out for their particular keyboards, these links might be useful:
https://superuser.com/questions/249064/udev-rule-to-auto-load-keyboard-layout-when-usb-keyboard-plugged-in
https://stackoverflow.com/questions/20619376/triggering-udev-rule-for-particular-keyboard
https://facility9.com/2019/07/remapping-keys-in-linux/
https://wiki.archlinux.org/index.php/Udev#udev_rule_example
Ive been looking into this. Ill push my fix if no one has one yet
@vladdoster Could you please share your fix?
@BachoSeven find fix in my Linux dotfiles
@vladdoster So if I understand correctly (from here), you call this script with a keybinding whenever an external keyboard is plugged in(?)
I'm doing this as well, but it would be better if we could find a way to automatize the process..
Most helpful comment
I've decided to switch to using the US layout by default, it has much better placement of special characters for programming than the Danish one (where most of them are on Shift+number or Right_Alt+number and mostly the high end of the numbers so uncomfortable for touch typing), so unless you have an interest in fixing this just disregard it.