You are not logged in.

#1 2022-01-11 17:23:10

romm
Member
Registered: 2022-01-05
Posts: 15

[SOLVED] Systemd startup script error while trying to layout keyboard.

So. Since my installation of arch ive been with troubles about keyboard layout, none loadkeys or setxkbmap had effect on my system, only before start the interface.
Here are the outputs of both setxkbmap -layout br-abnt2:

Error loading new keyboard description

and loadkeys br-abnt2 (on interface)

Couldn't get a file descriptor referring to the console.

At first i didnt even thought about that cuz i installed Gnome, but now im using suckless, that dont have a settings app to set the layout to me.

Basically, searching on the internet i have read that it can be a error on systemd, and that i could create a script to set the layout on the system start. I dont know if this has really any sense, but im actually trying what i find.

So, going to the problem, i have this script i created as a service:

[Unit]
Description=ChangekeyboardLayout
[Service]

Type=oneshot
ExecStart=/usr/local/bin/idioma.sh

[Install]
WantedBy=multi-user.target

The "idioma.sh" is just a "setxkbmap -layout br-abnt2".

Thanks.

Last edited by romm (2022-01-13 23:29:34)

Offline

#2 2022-01-11 17:46:08

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 2,611
Website

Re: [SOLVED] Systemd startup script error while trying to layout keyboard.

romm wrote:

The "idioma.sh" is just a "setxkbmap -layout br-abnt2".
Thanks.

Why don't you put that command into ExecStart directly then?
And are you sure that the service in question really has no dependencies?


Inofficial first vice president of the Rust Evangelism Strike Force

Online

#3 2022-01-11 18:03:37

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,999
Website

Re: [SOLVED] Systemd startup script error while trying to layout keyboard.

romm wrote:

im using suckless, that dont have a settings app to set the layout to me.

Add the command to your X startup script. For example use ~/.xinitrc if you're running 'startx' from a console login or ~/.xprofile if you're running a display manager.

To run it from a unit file see https://wiki.archlinux.org/title/Systemd/User and be sure to set DISPLAY & XAUTHORITY correctly.

But I think you should be using localectl(1) instead.


Jin, Jîyan, Azadî

Offline

#4 2022-01-11 18:06:43

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,104

Re: [SOLVED] Systemd startup script error while trying to layout keyboard.

You don't want/can't  do that in a system service. You'd do it in a user service but there are a few gotchas if you start your X session with startx, at which point you could just put that command directly into your .xinitrc instead.

Offline

#5 2022-01-12 17:00:26

romm
Member
Registered: 2022-01-05
Posts: 15

Re: [SOLVED] Systemd startup script error while trying to layout keyboard.

V1del wrote:

You don't want/can't  do that in a system service. You'd do it in a user service but there are a few gotchas if you start your X session with startx, at which point you could just put that command directly into your .xinitrc instead.

I already did this before, but doesnt work.

Offline

#6 2022-01-12 17:06:21

romm
Member
Registered: 2022-01-05
Posts: 15

Re: [SOLVED] Systemd startup script error while trying to layout keyboard.

schard wrote:
romm wrote:

The "idioma.sh" is just a "setxkbmap -layout br-abnt2".
Thanks.

And are you sure that the service in question really has no dependencies?

If you mean setxkbmap, it looks like the main command to change the layout permanently, based on what i searched. Maybe i didnt understand what you are saying.

Offline

#7 2022-01-12 20:28:50

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,307

Re: [SOLVED] Systemd startup script error while trying to layout keyboard.

"Doesn't work" isn't an error description.
How do you determine that is doesn't work and what did the attempted xinitrc look like and do you use startx to begin with (because most DMs won't use that for your session at all)

Also see https://dwm.suckless.org/patches/autostart/ and last but not least if you're the only user on that system and always want that layout: https://wiki.archlinux.org/title/Xorg/K … tion_files

Edit: also just in case, your findings with gnome will not apply to DWM. Gnome steamrolls over every previous config while DWM won't.

Last edited by seth (2022-01-12 20:29:38)

Offline

#8 2022-01-12 20:44:32

romm
Member
Registered: 2022-01-05
Posts: 15

Re: [SOLVED] Systemd startup script error while trying to layout keyboard.

seth wrote:

"Doesn't work" isn't an error description.
How do you determine that is doesn't work and what did the attempted xinitrc look like and do you use startx to begin with (because most DMs won't use that for your session at all)

Also see https://dwm.suckless.org/patches/autostart/ and last but not least if you're the only user on that system and always want that layout: https://wiki.archlinux.org/title/Xorg/K … tion_files

Edit: also just in case, your findings with gnome will not apply to DWM. Gnome steamrolls over every previous config while DWM won't.

Oh, sorry. I forgot to mention that both loadkeys and setxkbmap output the errors i showed even without interface, when without sudo. setxkbmap with sudo too, loadkeys simply doesn't have output despite this is my output of localectl status:

[romrom@archrom ~]$ localectl status
   System Locale: LANG=en_US.UTF-8
       VC Keymap: br-abnt2
      X11 Layout: n/a

Even my layout in practice being en-us.

Last edited by romm (2022-01-12 20:45:35)

Offline

#9 2022-01-12 20:50:09

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,307

Re: [SOLVED] Systemd startup script error while trying to layout keyboard.

loadkeys operates the linux console, setxkbmap the X11 session. Don't use sudo for the latter.
Don't just use sudo when things don't work your way in general, you're just causing more trouble.

As for setxkbmap, you'll have to apply that for a running X11 server, you cannot use that on the console.
Also see the wiki link I posted.

Edit: and that somehow didn't touch on V1del's xinitrc suggestion at all.

Last edited by seth (2022-01-12 20:50:46)

Offline

#10 2022-01-13 23:25:34

romm
Member
Registered: 2022-01-05
Posts: 15

Re: [SOLVED] Systemd startup script error while trying to layout keyboard.

seth wrote:

loadkeys operates the linux console, setxkbmap the X11 session. Don't use sudo for the latter.
Don't just use sudo when things don't work your way in general, you're just causing more trouble.

As for setxkbmap, you'll have to apply that for a running X11 server, you cannot use that on the console.
Also see the wiki link I posted.

Edit: and that somehow didn't touch on V1del's xinitrc suggestion at all.

So. I may haven't read the error that showed on the start of x before when i tested putting setxkbmap on .xinitrc, but today i did it and noticed that X was not finding my layout. Apparently, the problem was me using the name of the layout i used on console (br-abnt2) to put on X session (just "br"). After i saw the layout list of X, i got it. Systemd had nothing to do with it.
Thank you, guys.

Last edited by romm (2022-01-13 23:31:00)

Offline

Board footer

Powered by FluxBB