Other Configure i3/sway & key-combinations assignments

Alain De Vos

Son of Beastie

Reaction score: 763
Messages: 2,512

I want to assign certain key-combinations in the window manager to do some things.
Problem is different applications capture different keys already and they should not conflict with the window manager assigned keys.
An example for workspace stuff sway uses by default e.g. windows_key-1.
But windows_key-1 is used by firefox when you play youtube to scroll to the beginning of the video so this key does not work when firefox is open.
Many other possible conflicts exist based on the applications you use.
What is your advice , tips for key assignment in the window manager.
Or what is your configuration ?
 

memreflect

Well-Known Member

Reaction score: 221
Messages: 257

It's odd that any application or website would use the Windows key for anything by default (other than a WM). I tried it in Firefox on YouTube while running i3, and it didn't work. If you're using libinput, what does libinput debug-events --show-keycodes print when you press that key combination and the effect occurs? Here's my output:

Code:
ROOT# libinput debug-events --show-keycodes
…
…
-event1   KEYBOARD_KEY     +2.833s      KEY_LEFTMETA (125) pressed
 event1   KEYBOARD_KEY     +3.855s      KEY_1 (2) pressed
 event1   KEYBOARD_KEY     +3.977s      KEY_1 (2) released
 event1   KEYBOARD_KEY     +5.203s      KEY_4 (5) pressed
 event1   KEYBOARD_KEY     +5.310s      KEY_4 (5) released
 event1   KEYBOARD_KEY     +5.719s      KEY_LEFTMETA (125) released
 event1   KEYBOARD_KEY     +9.238s      KEY_RIGHTCTRL (97) pressed
 event1   KEYBOARD_KEY     +9.638s      KEY_C (46) pressed
^C

You can also try capturing events using x11/wev (like xev, but for Wayland).

What happened for me:
  1. Press Windows key
  2. Win-1 ⇒ switch to workspace 1
  3. Win-4 ⇒ switch back to workspace 4
  4. Release Windows key
  5. Ctrl-C to kill the program
 
OP
Alain De Vos

Alain De Vos

Son of Beastie

Reaction score: 763
Messages: 2,512

I have,
export XKB_DEFAULT_LAYOUT="be"
I tried variant,
export XKB_DEFAULT_LAYOUT="be(nodeadkeys)"
But windowkey-1 still got captured by firefox
windowskey-1 produces :
Code:
 event4   KEYBOARD_KEY     +16.776s KEY_LEFTMETA (125) pressed
 event4   KEYBOARD_KEY     +20.719s KEY_1 (2) pressed
^X@s& event4   KEYBOARD_KEY     +20.912s    KEY_1 (2) released
 event4   KEYBOARD_KEY     +25.947s KEY_LEFTMETA (125) released
 

memreflect

Well-Known Member

Reaction score: 221
Messages: 257

I just tried without pressing any key except '1', and that triggered the behavior you described (it actually jumps to another time in the video when you press any of the number keys), so it's as if your modifier key is being ignored entirely.

I did notice that Sway had trouble with one of my i3 config lines when I had a (long) comment at the end of a bindsym line:
Code:
bindsym $mod+Shift+e exit #exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"
My $mod+Shift+e was not allowing me to exit. I'm not sure why that happened, but (re)moving the comment and reloading my config allowed my keybinding to finally behave as expected.

You mentioned that you set some environment variables, which gave me an idea: are you running Firefox under Wayland or Xwayland? By default, it launches under Xwayland on my system (x11/xeyes follows my mouse movement inside a Firefox window), so you might try closing Firefox and executing env -u DISPLAY firefox to see if the problem persists.
 
OP
Alain De Vos

Alain De Vos

Son of Beastie

Reaction score: 763
Messages: 2,512

This is how i start sway, nothing special,
Code:
export XDG_RUNTIME_DIR=/home/x/TMP 
export XKB_DEFAULT_LAYOUT="be(nodeadkeys)" 
export GDK_BACKEND=wayland 
export QT_QPA_PLATFORM=wayland 
export QT_QPA_PLATFORMTHEME="qt5ct" 
export QT_WAYLAND_DISABLE_WINDOWDECORATION=1 
export SDL_VIDEODRIVER=wayland 
export MOZ_ENABLE_WAYLAND=1 
sway
 

memreflect

Well-Known Member

Reaction score: 221
Messages: 257

x11/wev was more helpful here since libinput-debug-events(1) only shows keycodes rather than keysym names. I apologize for not considering the fact that your keyboard layout was a possible factor.

Your keyboard layout has & (ampersand) as the primary symbol and 1 as the shifted symbol. When I switched to your layout, I encountered the same issue in Firefox/YouTube as you. But when I held the Shift key, there was no problem because I use $mod+1 to switch workspaces. You need to use $mod+ampersand if you want to avoid the Shift key.
 
OP
Alain De Vos

Alain De Vos

Son of Beastie

Reaction score: 763
Messages: 2,512

Using "wshowkeys" or "wev" on the bottom row I have from left to right :
Code:
Control_L
Super_L
Alt_L
space
Iso_Level3_Shift
Menu(+)
Control_R

With xmodmap:
Code:
xmodmap:  up to 4 keys per modifier, (keycodes in parentheses):
shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  Meta_L (0xcd)
mod2        Num_Lock (0x4d)
mod3      
mod4        Super_L (0x85),  Super_R (0x86),  Super_L (0xce),  Hyper_L (0xcf)
mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)
 

scottro

Daemon

Reaction score: 909
Messages: 2,061

Not that this solves your issue, but I noticed that hitting the home key on a TKL keyboard will also restart a youtube video. I use dwm, with Mod4 as the mod key, and it does have some builtins that conflict with my preferred use. In such cases, I usually add shift or alt to the key combo to avoid conflict.
 

memreflect

Well-Known Member

Reaction score: 221
Messages: 257

Have you changed your config to use $mod+ampersand? Or are you still using $mod+1, which requires you to hold the Shift key if you're using the be(nodeadkeys) layout?
 
OP
Alain De Vos

Alain De Vos

Son of Beastie

Reaction score: 763
Messages: 2,512

I ended up rebinding alot of keys in /home/myuser/.config/sway/config and simply avoiding 0...9 and using a few ALT combinations.
Code:
# Logo key. Use Mod1 for Alt.
set $mod Mod4

# Your preferred terminal emulator
set $term qterminal 

# Your preferred application launcher
set $menu dmenu_path | dmenu | xargs swaymsg exec --

# Exec

    # Exit sway (logs you out of your Wayland session)
    bindsym $mod+Shift+w exec swaynag -t warning -m 'Do you really want to exit sway' -b 'Yes, exit sway' 'swaymsg exit'

    # Start a terminal
    bindsym $mod+Return exec $term

    # ALT##############################################
    bindsym Mod1+w exec /home/x/Sway/my_wofi
    bindsym Mod1+x exec /home/x/Sway/my_rofi
    bindsym Mod1+c exec /home/x/Sway/my_lavalauncher
    bindsym Mod1+v exec /home/x/Sway/my_nwgbar
    bindsym Mod1+b exec $menu
    bindsym Mod1+m exec conky -c /home/x/Conf/CONKY1.CONF
    bindsym Mod1+l exec conky -c /home/x/Conf/CONKY2.CONF
    bindsym Mod1+k exec gkrellm

    bindsym $mod+a exec nemo /home/x/Desktop
    bindsym $mod+z exec thunar /home/x/Desktop
    bindsym $mod+e exec xfce4-terminal
    bindsym $mod+r exec qterminal
    bindsym $mod+t exec sakura
    bindsym $mod+y exec firefox
    bindsym $mod+u exec midori
    bindsym $mod+i exec strawberry
    bindsym $mod+o exec gtk-mixer
    bindsym $mod+p exec leafpad

# Switch to workspace
    bindsym $mod+Shift+a workspace number 1
    bindsym $mod+Shift+z workspace number 2
    bindsym $mod+Shift+e workspace number 3
    bindsym $mod+Shift+r workspace number 4
    bindsym $mod+Shift+t workspace number 5
    bindsym $mod+Shift+y workspace number 6
    bindsym $mod+Shift+u workspace number 7
    bindsym $mod+Shift+i workspace number 8

# Move focused container to workspace
    bindsym $mod+Shift+q move container to workspace number 1
    bindsym $mod+Shift+s move container to workspace number 2
    bindsym $mod+Shift+d move container to workspace number 3
    bindsym $mod+Shift+f move container to workspace number 4
    bindsym $mod+Shift+g move container to workspace number 5
    bindsym $mod+Shift+h move container to workspace number 6
    bindsym $mod+Shift+j move container to workspace number 7
    bindsym $mod+Shift+k move container to workspace number 8

# Moving around:
    bindsym $mod+Left focus left
    bindsym $mod+Down focus down
    bindsym $mod+Up focus up
    bindsym $mod+Right focus right
    bindsym $mod+Shift+Left move left
    bindsym $mod+Shift+Down move down
    bindsym $mod+Shift+Up move up
    bindsym $mod+Shift+Right move right

# Resizing containers:
mode "resize" {
    bindsym Left resize shrink width 10px
    bindsym Down resize grow height 10px
    bindsym Up resize shrink height 10px
    bindsym Right resize grow width 10px

    # Return to default mode
    bindsym Return mode "default"
    bindsym Escape mode "default"
}
bindsym $mod+s mode "resize"

# Layout stuff:
    # You can "split" the current object of your focus with
    # $mod+b or $mod+v, for horizontal and vertical splits
    # respectively.
    bindsym $mod+b splith
    bindsym $mod+v splitv

    # Switch the current container between different layout styles
    bindsym $mod+w layout stacking
    bindsym $mod+x layout tabbed
    bindsym $mod+c layout toggle split

    # Make the current focus fullscreen
    bindsym $mod+n fullscreen

    # Move focus to the parent container
    bindsym $mod+m focus parent

    # Swap focus between the tiling area and the floating area
    bindsym $mod+space focus mode_toggle

    # Toggle the current focus between tiling and floating mode
    bindsym $mod+Shift+space floating toggle

# Scratchpad bag of holding for windows.
    # Move the currently focused window to the scratchpad
    bindsym $mod+Shift+minus move scratchpad

    # Show the next scratchpad window or hide the focused scratchpad window.
    bindsym $mod+minus scratchpad show

# Other

    # Kill focused window
    bindsym $mod+Shift+x kill

    # Reload the configuration file
    bindsym $mod+Shift+c reload

    # Drag floating windows by holding down $mod and left mouse button.
    floating_modifier $mod normal
 
OP
Alain De Vos

Alain De Vos

Son of Beastie

Reaction score: 763
Messages: 2,512

I found out the hard way "geany" application captures also a lot of keys.
So i must first release focus of geany before i use those keys on the sway windows manager.
 
OP
Alain De Vos

Alain De Vos

Son of Beastie

Reaction score: 763
Messages: 2,512

Tip. To run river within sway i assigned the "river" keys to mod5 i.e. ISO_Level3_Shift or ALT-GR.
 
Top