You are not logged in.
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
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
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
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?
Offline
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.
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...
What is "/opt/kbswtb"?
That is my program I honestly forgot what exactly it does.
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
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
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
xkb-switch is GPL 3, so you're not "stealing" anything as long as you adhere those licenses requirements.
Offline
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
commands like setxkbmap and xmodmap break reset my keyboard settings
Offline
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
Do you suggest it does?
If any it's gonna be xkbopendisplay, which isn't required - you're not udsing the xkb version anyway.
Offline
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