Skip to content

Instantly share code, notes, and snippets.

@cristianovitorino
Last active February 28, 2020 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cristianovitorino/206ed2d326f63bad7e9a03b81e62c476 to your computer and use it in GitHub Desktop.
Save cristianovitorino/206ed2d326f63bad7e9a03b81e62c476 to your computer and use it in GitHub Desktop.
[i3-gaps] Space as Modifier for i3-gaps

Make Spacebar the default modifier in i3-gaps

Author

This was done by the user u/b_wright on Reddit: Using Space Bar as $mod is Life Changing

Small edit

Added useful hyperlinks.

Cristiano Vitorino: https://github.com/cristianovitorino


In an effort to both keep from getting repetitive stress injuries and too avoid buying the $350 dollar keyboard I've had my eye on, I've been doing a lot of remapping of keys. Caps Lock to serve as both Escape/Ctrl is an obvious first. hjkl movement everywhere I can is a nice second. Getting rid of the nagbar to exit i3---because it just makes so much sense to have to use the mouse to exit i3---might be a third.

I'd been using mod4 (super) as my mod key for a long time, and that was good, but it still makes for a lot of thumb curling and awkward left handed gymnastics, which is not what I'm aiming to do. I was seriously considering the feasibility of firing up the dremel and soldering iron and trying to replace the left portion of the space bar with a new modifier key. We all know that would have gone so well....

But recently---and I don't know why it took me so long since I'd already remapped things---I added Hyper_L to mod3 and remapped the space bar to it. Of course, that leaves you without spaces...butwhoneeds'em,right? I then used xcape to add 'space' back to the space bar on release. So now, when space is pressed by itself, it's space; when it's pressed in combination with another key, it's a modifier. I say this is life changing, because it not only gets rid of the thumb curling to reach super or alt because your thumb is already resting on the space bar, but it greatly reduces all the left handed contortions, because you can now press mod with either hand.

If you want to give it a go, here's what I did:

  1. Install xcape from github or your distro's repo.

  2. Edit or create ~/.Xmodmap including:

clear mod3 
clear mod4 
add mod3 = Hyper_L 
add mod4 = Super_L Super_R
  1. Edit or create ~/.profile including:
# This file depends on settings in .Xmodmap
 xmodmap /home/<yourusername>/.Xmodmap

 # Use Spacebar as a Modifier
 spare_modifier="Hyper_L" 
 xmodmap -e "keycode 65 = $spare_modifier"   
 xmodmap -e "add Hyper_L = $spare_modifier"
 xmodmap -e "keycode any = space"  
 xcape -e "$spare_modifier=space"
  1. Edit your i3 config: set $mod mod3 (You will also want to change your floating window controls as they are set to $mod+space and $mod+Shift+space. I moved them to $mod+p for "pop-up". You can do what makes sense to you.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment