I often plugin a USB keyboard to my laptop (in addition to external monitor and mouse, which all virtually convert my laptop to a desktop computer) and I prefer using a different keyboard layout then.
I have to manually change the current keyboard layout each time I plugin this USB keyboard.
And I'd like to use an automated way for this, if possible.
Radu's answer to the question here gives some clues, but it seems I'll need a startup script for this task as the device ID for my USB keyboard changes every time the computer starts.
This startup script will probably first include the command xinput -list | grep "USB Keyboard"
, and another command to grab the first USB Keyboard ID number displayed and then use it in the final command to set my chosen layout for that USB keyboard as below:
setxkbmap -device <NUMBER> -layout <LAYOUT>