You are not logged in.

#1 2022-07-23 12:47:21

donaastor
Member
Registered: 2022-03-14
Posts: 68

Changing X settings doesn't work from .xinitrc

So I have these settings for mouse and keyboard that I want to set on every startup of my X environment, so I wrote bash commands in xset. Then I noticed how often it won't work, so I guessed X server isn't up yet and I wrote it to run every 3 seconds for several minutes so that it surely run at least once after X launches. But it still doesn't work. I forgot now how, but I managed to get it to print to me the successfulness of these periodic commands and I saw how it consistently fails to execute. Even after X is clearly up it still can't set the settings. So I had two terminals, one running the script and printing and another waiting for my input, regularly. The script was failing while I succesfully set the settings on the other terminal. Here is my .xinitrc:

xset s noblank
xset s noexpose
xset s 0 0
xset +dpms
xset dpms 0 180 0
bash -c 'xset_ctr=0; xset r rate 250 30; while [ "$(xset q | grep -- repeat\ rate | awk \{print\ \$4,\$7\})" != "250 30" ]; do echo WHAT; bash --norc -c xset\ r\ rate\ 250\ 30; xset_ctr=$(( $xset_ctr + 1 )); if [ $xset_ctr = 105 ]; then break; fi; sleep 2; done' &
numlockx &
xbindkeys &
/opt/kbswtb &
if ! pgrep -f xidlehook; then
  xidlehook --timer 600 'systemctl suspend -i' '' &
fi
picom --experimental-backends &
export QT_SCREEN_SCALE_FACTORS=1.5
corectrl &
nitrogen --restore &
exec i3

How can I wait for X to properly get up and then set its settings? Is there maybe a script or a file that X reads as soon as it gets up?

Last edited by donaastor (2022-08-10 18:47:36)

Offline

#2 2022-07-23 12:49:42

Irets
Member
Registered: 2019-02-01
Posts: 143

Re: Changing X settings doesn't work from .xinitrc

Some of these settings can also be set in i3's configuration file, if .xinitrc doesn't properly execute them.
That way you can be sure that xorg server is running when the commands get executed.

You can see the syntax from here: https://i3wm.org/docs/userguide.html

Last edited by Irets (2022-07-23 12:52:35)

Offline

#3 2022-07-23 13:21:17

donaastor
Member
Registered: 2022-03-14
Posts: 68

Re: Changing X settings doesn't work from .xinitrc

Irets wrote:

Some of these settings can also be set in i3's configuration file, if .xinitrc doesn't properly execute them.
That way you can be sure that xorg server is running when the commands get executed.

You can see the syntax from here: https://i3wm.org/docs/userguide.html

Thank you for suggesting. I did check that page when I was writing my script, but I didn't find these specific settings. I also didn't bother much honestly. Anyway, I would still prefer a generic way of doing this, so could a

exec bash myscript.sh

in i3's config work? Would that guarantee that X is up?

Offline

#4 2022-07-23 13:22:40

seth
Member
Registered: 2012-09-03
Posts: 50,929

Re: Changing X settings doesn't work from .xinitrc

I assume you're positive that you're running xinitrc (because you're using xinit or startx and not a DM like lightdm)?
The X11 server is available when xinitrc is interpreted, how do you asses that "often it won't work"? Does "xset q" report different values?
What is "/opt/kbswtb"?
Do you at any point (eg. via i3) run setxkbmap or xmodmap?

Is there maybe a script or a file that X reads as soon as it gets up?

https://wiki.archlinux.org/title/Xorg/K … ion_option

Offline

#5 2022-07-23 13:39:12

donaastor
Member
Registered: 2022-03-14
Posts: 68

Re: Changing X settings doesn't work from .xinitrc

seth wrote:

I assume you're positive that you're running xinitrc (because you're using xinit or startx and not a DM like lightdm)?

Yes, I had kinda tiredly written my post so it's messy, but yes. I am running startx and I don't have a DM.

seth wrote:

The X11 server is available when xinitrc is interpreted, how do you asses that "often it won't work"? Does "xset q" report different values?

It just sometimes works, sometimes it doesn't. Varies from boot to boot. For example this time it didn't set my keyboard rate, but yesterday it did...

seth wrote:

What is "/opt/kbswtb"?

That is my program smile I honestly forgot what exactly it does.

seth wrote:

Do you at any point (eg. via i3) run setxkbmap or xmodmap?

No, not in i3. My program has a method that does the same thing as setxkbmap, but I never call it so I think the compiler even removed it from the binary.
Thank you for the link.

Offline

#6 2022-07-23 13:59:56

seth
Member
Registered: 2012-09-03
Posts: 50,929

Re: Changing X settings doesn't work from .xinitrc

I honestly forgot what exactly it does.

My program has a method that does the same thing as setxkbmap.

I'd heavily and intensely look there (don't run/ comment /opt/kbswtb and see whether that has any impact)

Offline

#7 2022-07-23 17:08:26

donaastor
Member
Registered: 2022-03-14
Posts: 68

Re: Changing X settings doesn't work from .xinitrc

seth wrote:

I'd heavily and intensely look there (don't run/ comment /opt/kbswtb and see whether that has any impact)

Ok, I'll do it and see if that changes the likelihoods. I can tell about it only tomorrow or the day after. I can even share my code (so anyone can see), it's already publicly available (on github) and very short in fact, but I am afraid to share it because I kinda stole it from another open-source project. I don't have a clue about legal stuff so idk... I use it for myself only anyway. This is the original project: https://github.com/grwlf/xkb-switch.
Ok damn it, here it is: https://github.com/donaastor/i3-config/ … kbswtb.cpp

Last edited by donaastor (2022-07-23 17:10:15)

Offline

#8 2022-07-23 18:53:56

seth
Member
Registered: 2012-09-03
Posts: 50,929

Re: Changing X settings doesn't work from .xinitrc

xkb-switch is GPL 3, so you're not "stealing" anything as long as you adhere those licenses requirements.

Offline

#9 2022-07-25 13:14:31

donaastor
Member
Registered: 2022-03-14
Posts: 68

Re: Changing X settings doesn't work from .xinitrc

seth wrote:

I'd heavily and intensely look there (don't run/ comment /opt/kbswtb and see whether that has any impact)

It seems like it worked... Although I tried not so many times, the correlation did show up.
Why would commands like setxkbmap and xmodmap break my keyboard settings?

Offline

#10 2022-07-25 13:26:32

seth
Member
Registered: 2012-09-03
Posts: 50,929

Re: Changing X settings doesn't work from .xinitrc

commands like setxkbmap and xmodmap break reset my keyboard settings

Offline

#11 2022-08-07 17:16:30

donaastor
Member
Registered: 2022-03-14
Posts: 68

Re: Changing X settings doesn't work from .xinitrc

seth wrote:

commands like setxkbmap and xmodmap break reset my keyboard settings

I have shortened and cleaned my code: https://github.com/donaastor/i3-config/ … kbswtb.cpp . Do you know do functions XkbOpenDisplay and XkbSelectEventDetails have any way to reset my keyboard settings?

Offline

#12 2022-08-07 18:03:54

seth
Member
Registered: 2012-09-03
Posts: 50,929

Re: Changing X settings doesn't work from .xinitrc

Do you suggest it does?
If any it's gonna be xkbopendisplay, which isn't required - you're not udsing the xkb version anyway.

https://bbs.archlinux.org/viewtopic.php … 8#p2045738

Offline

#13 2022-08-09 00:01:21

donaastor
Member
Registered: 2022-03-14
Posts: 68

Re: Changing X settings doesn't work from .xinitrc

seth wrote:

If any it's gonna be xkbopendisplay, which isn't required - you're not udsing the xkb version anyway.

I reduced the code as much as I could but the problem is still there. It's gotta be something else other than my program, right?

Last edited by donaastor (2022-08-10 18:47:25)

Offline

Board footer

Powered by FluxBB