Re: [i3] default kbd layout per window

2015-09-01 Thread Nokan Emiro
Yes, the "terminal" role is a-okay.  For example

for_window [window_role="terminal"]  border pixel 22

works fine.  And the dbus-send command also works if it's run from the
terminal.  But
if I start a new terminal with $mod+Enter, it comes up with the wrong
layout.

For testing, I did this (the same dbus-send command bound to $mod+o):

bindsym $mod+o exec --no-startup-id dbus-send --dest=ru.gentoo.KbddService
/ru/gentoo/KbddService ru.gentoo.kbdd.set_layout uint32:1

and pressing $mod+o in the new terminal changes the layout to US, as I
expected.

My guess is that the switching to the US layout happens too early.  Maybe
kbdd kicks in on the
new window just a bit after the US layout was set and kbdd overwrites it
with the default.


This didn't work either:

xte 'keydown Shift_L' 'keydown Caps_Lock' 'keyup Caps_Lock' 'keyup Shift_L'

but this one (that sleeps 0.5 sec before simulating the keypresses) did:

xte 'usleep 50' 'keydown Shift_L' 'keydown Caps_Lock' 'keyup Caps_Lock'
'keyup Shift_L'

So, this seems to be some stupied timing issue.  I'm sorry about
bothering...

Uz.


On Tue, Sep 1, 2015 at 5:23 PM, Ingo Bürk  wrote:

> Then I think it should work, assuming your terminal actually has the
> window role "terminal".
>
> Can you be more specific on how it doesn't work? Can you figure out if the
> command is run on the wrong window? Also, a log file would be helpful to
> see how the command is being executed.
>
> You probably also want to add --no-startup-id to the exec call. I doubt
> dbus-send does anything with startup notifications.
>
> Regards
> Ingo
>
> Sent from TypeMail 
>
> On Sep 1, 2015, at 17:19, Nokan Emiro  wrote:
>>
>> That's not a problem.  If the layout is once set for that particular
>> window,  kbdd will
>> take care of the focus changes and activate the proper layout if the
>> focus moves.  All
>> I want is to set the initial layout to US on the terminal windows and
>> leave the other
>> layout as the default for all the rest.
>>
>>
>> On Tue, Sep 1, 2015 at 5:13 PM, Ingo Bürk  wrote:
>>
>>> For_window will only be run when the window is opened, not everytime it
>>> is focused.
>>>
>>


Re: [i3] default kbd layout per window

2015-09-01 Thread Mateusz Poszwa
Je 2015-09-01 21:27:20
Nokan Emiro  skribis:

(…)
> but this one (that sleeps 0.5 sec before simulating the keypresses) did:
> 
> xte 'usleep 50' 'keydown Shift_L' 'keydown Caps_Lock' 'keyup Caps_Lock'
> 'keyup Shift_L'
> 
> So, this seems to be some stupied timing issue.  I'm sorry about
> bothering...

If it’s just a timing issue, you may want to add a delay, like this:

for_window [window_role="terminal"] exec --no-startup-id sleep 1 && dbus-send 
--dest=ru.gentoo.KbddService /ru/gentoo/KbddService ru.gentoo.kbdd.set_layout 
uint32:1

-- 
Mateusz Poszwa


Re: [i3] default kbd layout per window

2015-09-01 Thread Ingo Bürk
For_window will only be run when the window is opened, not everytime it is 
focused. 

What you need to do is hook into the focus event on the IPC, match the window 
there and execute the command. 

Regards
Ingo 

Sent from TypeMail



On Sep 1, 2015, 17:07, at 17:07, Nokan Emiro  wrote:
>Hi i3wm gurus,
>
>I use i3 with kbdd in order to have different keyboard layouts in
>different
>windows:
>
>exec_always --no-startup-id kbdd
>exec_always setxkbmap -layout de,us -option grp:shift_caps_toggle
>
>
>I figured out that the following command changes the current layout
>into
>the US version:
>
>$  dbus-send --dest=ru.gentoo.KbddService /ru/gentoo/KbddService
>ru.gentoo.kbdd.set_layout uint32:1
>
>...and replacing the uint32:1 with uint32:0 switches to the DE layout.
>
>
>Now, what I couldn't figure out is that how can I set up a default
>layout
>for certain types
>of windows.  New windows start with the DE version (I guess because
>that
>one comes
>first in the list with the 'setxkbmap -layout de,us' command).  So far,
>so
>go.  But on
>terminals I want to use the US layout.  I tried something like this in
>the
>i3wm config:
>
>for_window [window_role="terminal"] exec dbus-send
>--dest=ru.gentoo.KbddService /ru/gentoo/KbddService
>ru.gentoo.kbdd.set_layout uint32:1
>
>Unfortunately this doesn't work.  Can you please tell me how can I do
>this
>kind of
>setup from the i3 config?  (Maybe I could run the dbus-send command
>from the
>bash_profile or something like that, but I hope this can be done with
>for_window
>in the i3 config somehow.)
>
>Thanks,
>Uz.


Re: [i3] default kbd layout per window

2015-09-01 Thread Nokan Emiro
That's not a problem.  If the layout is once set for that particular
window,  kbdd will
take care of the focus changes and activate the proper layout if the focus
moves.  All
I want is to set the initial layout to US on the terminal windows and leave
the other
layout as the default for all the rest.


On Tue, Sep 1, 2015 at 5:13 PM, Ingo Bürk  wrote:

> For_window will only be run when the window is opened, not everytime it is
> focused.
>


Re: [i3] default kbd layout per window

2015-09-01 Thread Ingo Bürk
Then I think it should work, assuming your terminal actually has the window 
role "terminal".

Can you be more specific on how it doesn't work? Can you figure out if the 
command is run on the wrong window? Also, a log file would be helpful to see 
how the command is being executed. 

You probably also want to add --no-startup-id to the exec call. I doubt 
dbus-send does anything with startup notifications. 

Regards
Ingo 

Sent from TypeMail



On Sep 1, 2015, 17:19, at 17:19, Nokan Emiro  wrote:
>That's not a problem.  If the layout is once set for that particular
>window,  kbdd will
>take care of the focus changes and activate the proper layout if the
>focus
>moves.  All
>I want is to set the initial layout to US on the terminal windows and
>leave
>the other
>layout as the default for all the rest.
>
>
>On Tue, Sep 1, 2015 at 5:13 PM, Ingo Bürk  wrote:
>
>> For_window will only be run when the window is opened, not everytime
>it is
>> focused.
>>