sergei-mironov / xkb-switch

Switch your X keyboard layouts from the command line
MIT License
345 stars 37 forks source link

Bug when use xkb-switch in xbindkeys #71

Closed FrolovRuslan1 closed 9 months ago

FrolovRuslan1 commented 9 months ago

Hello everyone ! I develop analog PuntoSwitcher for Windows. It is OpenSwitcher and its github here OpenSwitcher. I faced with a problem when I use xkb-switch in xbindkeys. At first run xbindkeys key combination Ctr+Alt script run correctly but i another cases it doesnt work. Without xkb-switch xbindkeys key combination Ctr+Alt script run normaly. Code here:

$HOME/.xbindkeysrc

# Activate OpenSwitcher
# To read about how to customise read `man xbindkeys`
# To read where is keys see #include <X11/keysym.h>
"openswitcher.sh"
Control + Alt_L

/usr/local/bin/openswitcher.sh

# sleep 0.5
xkb-switch -n
sleep 0.5
xsel | sudo openswitcher

uname -a Linux MyDebian 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.38-2 (2023-07-27) x86_64 GNU/Linux

sergei-mironov commented 9 months ago

Hihi. Could you please clarify what behavior do you expect in this case? xkb-switch -n should select next kb layout. Does it work if you run it in terminal manually?

FrolovRuslan1 commented 9 months ago

Yes it works in terminal manually, after several test I think the problem may occur because of xbindkeys,. Now I search solution for xbindkeys.

FrolovRuslan1 commented 9 months ago

Hihi. Could you please clarify what behavior do you expect in this case? xkb-switch -n should select next kb layout. Does it work if you run it in terminal manually?

I dont not how an why but me help sleep 0.5 AFTER script

FrolovRuslan1 commented 9 months ago

No, my problem is still here :) Exactly after I add xkb-switch -n to the script problem occur, I tried add before and after sleep 0.5 and it doesnt solve my problem. At beginning of discussion I had two problems with xbindkeys and xkb-switch -n first I solve with sleep 0.5 and second I didnt solve

sergei-mironov commented 9 months ago

No, my problem is still here :) Exactly after I add xkb-switch -n to the script problem occur, I tried add before and after sleep 0.5 and it doesnt solve my problem. At beginning of discussion I had two problems with xbindkeys and xkb-switch -n first I solve with sleep 0.5 and second I didnt solve

Could you please clarify what your script is supposed to do exactly? I see it calls xkb-switch to change the layout and then it pipes the X11 selection into your openswitcher app. What should happen next? It is not clear to me how switching the layout correlates with this second part. Does xkb-switch fail to change the layout or there is some other problem?

FrolovRuslan1 commented 9 months ago

No, my problem is still here :) Exactly after I add xkb-switch -n to the script problem occur, I tried add before and after sleep 0.5 and it doesnt solve my problem. At beginning of discussion I had two problems with xbindkeys and xkb-switch -n first I solve with sleep 0.5 and second I didnt solve

Could you please clarify what your script is supposed to do exactly? I see it calls xkb-switch to change the layout and then it pipes the X11 selection into your openswitcher app. What should happen next? It is not clear to me how switching the layout correlates with this second part. Does xkb-switch fail to change the layout or there is some other problem?

Sure ! My program take a text from input and transform to the Keycodes after that it print via /dev/input/event0 (keybord driver, function write())

sergei-mironov commented 9 months ago

No, my problem is still here :) Exactly after I add xkb-switch -n to the script problem occur, I tried add before and after sleep 0.5 and it doesnt solve my problem. At beginning of discussion I had two problems with xbindkeys and xkb-switch -n first I solve with sleep 0.5 and second I didnt solve

Could you please clarify what your script is supposed to do exactly? I see it calls xkb-switch to change the layout and then it pipes the X11 selection into your openswitcher app. What should happen next? It is not clear to me how switching the layout correlates with this second part. Does xkb-switch fail to change the layout or there is some other problem?

Sure ! My program take a text from input and transform to the Keycodes after that it print via /dev/input/event0 (keybord driver, function write())

Hmm, I see. I have installed your app, had to change event0 -> event2 and I think I am able to see it works. Pretty cool! But that means I can not reproduce the problem.. I think I saw a couple of buffer overflows, had to build the app wiht -O0 -g. image

sergei-mironov commented 9 months ago

Are you able to run your app without xkb-switch normally?

sergei-mironov commented 9 months ago

Also, even if it doesn't work properly, do you see the keyboard layout is changed after your script exits?

FrolovRuslan1 commented 9 months ago

Are you able to run your app without xkb-switch normally?

That is interesting. After several tests I think that bug appear more likely because of xbindkeys, but I dont know why when I usexkb-switch -n it is getting worse. BUT when I use openswitcher.sh via terminal it works absolutely good.

FrolovRuslan1 commented 9 months ago

Also, even if it doesn't work properly, do you see the keyboard layout is changed after your script exits?

Yes, layouts changed )