0

I install Ubuntu on my notebook bought in USA but I'm from Brazil, the problem is, because of the keyboard model, I have to run this command every time I turn on my system:

"setxkbmap -model abnt2 -layout br -variant abnt2"

How can I turn this process automatic, or maybe install a keyboard model. Sorry for bad enlgish.

2 Answers2

1

One way to do this would be to set it up as a systemd service:

  1. Create a .service file, which, once enabled, will be run by systemd upon booting. In a text editor, create a file called mykeyboard.service and include the following (change the path/to/ part with the actual path to your script):

    [Unit]
    Description=MyKeyboard service
    
    [Service]
    ExecStart=setxkbmap -model abnt2 -layout br -variant abnt2
    
    [Install]
    WantedBy=multi-user.target
    
  2. Place your new .service file in the directory /etc/systemd/system/

  3. To run and have it run on boot, you would use sudo systemctl enable --now mykeyboard

That should do it!

1

Instead of running a command at each startup, you'd better save those settings persistently. Open /etc/default/keyboard for editing and give it this contents:

XKBLAYOUT="br"
BACKSPACE="guess"
XKBVARIANT="abnt2"
XKBMODEL="abnt2"
Gunnar Hjalmarsson
  • 33,540
  • 3
  • 64
  • 94