Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mapping backslash to a modifier loses bar character #120

Open
sidequestboy opened this issue Feb 17, 2020 · 3 comments
Open

mapping backslash to a modifier loses bar character #120

sidequestboy opened this issue Feb 17, 2020 · 3 comments

Comments

@sidequestboy
Copy link

sidequestboy commented Feb 17, 2020

I've mapped my backslash character to a spare modifier using the following:

xmodmap -e "keycode 51 = Hyper_L"
xmodmap -e "remove mod4 = Hyper_L"
xmodmap -e "add mod3 = Hyper_L"
xmodmap -e "keycode any = backslash"
xcape -e "Hyper_L=backslash"

but now when I want to type a vertical "bar" character, it inserts a backslash.

How can I preserve my shifted bar character?

@supremesnickers
Copy link

supremesnickers commented Jun 4, 2020

I had similar issues using xcape in combination with Xmodmap while trying to replicate Ethan Schoonover's modifier setup. Xmodmap:

clear mod4
keycode 23 = Hyper_L
keycode 51 = Hyper_R
keycode 133 = Super_L
keycode any = Tab
keycode any = backslash

When I now run xcape -e "Hyper_L=Tab;Hyper_R=backslash", pressing tab by itself gives both Hyper_L and tab, pressing the backslash key by itself also gives both Hyper_R and backslash. Pressing Shift together with those keys doesn't make any difference.

I analyzed the pressed keys with this command: xev | grep -A2 --line-buffered '^KeyRelease' | sed -n '/keycode /s/^.*keycode \([0-9]*\).* (.*, \(.*\)).*$/\1 \2/p'.

@dadaurs
Copy link

dadaurs commented Mar 19, 2021

I also had the same issue

The easiest way I found to circumvent this was to use xmodmap to essentially reconfigure the backslash character.
The way you do this is by simply running

xmodmap -e "keysym  backslash = backslash bar"

After you've run this, everything should be back to normal

@jaavedd9
Copy link

jaavedd9 commented May 28, 2022

After spending too much time, the following ~/.xession worked for me, @supremesnickers I was facing the same issue and it was causing my machine to hang when hitting backslash + tab it was getting into never ending loop. Some how this script works, I don't understand all of it though, figured out by hit and trial. My OS is Debian 11.

#!/bin/bash
# hyper keys configs that worked
# from https://github.com/Zetagon/dotfiles/blob/master/xsession
# xbindkeys --defaults > $HOME/.xbindkeysrc


# kill xcape process, without this everytime this script is run it is multiplying backslash and tab keys 
# multiple xcape process causing this issue
pkill xcape
xbindkeys
# Log stderror to a file 
#exec awesome 
#    # No error logging
#    #dwm >/dev/null 2>&1
setxkbmap -option "caps:ctrl_modifier"
setxkbmap -layout us,se -option grp:shifts_toggle

# Make tab a superkey when held down, tab when pressed alone
xmodmap -e "keysym Tab = Hyper_L"
xmodmap -e "remove mod4 = Hyper_L"
xmodmap -e "keycode any = Tab"
xcape -e "Hyper_L=Tab"

# Make backslash a superkey when held down, backslash when pressed alone
xmodmap -e "keysym backslash = Hyper_R"
xmodmap -e "remove mod4 = Hyper_R"
xmodmap -e "keycode any = backslash"
xcape -e "Hyper_R=backslash"

# to restore pipe when clicking blackslash with shift
# from here https://github.com/alols/xcape/issues/120
xmodmap -e "keysym  backslash = backslash bar"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants