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

[Tip in progress] Poor man's vim digraphs emulation with sxhkd and xdotool in the terminal and elsewhere #165

Closed
grepsuzette opened this issue Dec 14, 2019 · 0 comments

Comments

@grepsuzette
Copy link

grepsuzette commented Dec 14, 2019

Using this tip, you will be able to simulate some vim digraphs using sxhkd and xdotool, meaning it would work in any terminal application (including the shell) and not just in vim.

Here is an example. When you need to add digraphs you will find symbols in this file: /usr/include/rfb/keysym.h, potentially with the help of :UnicodeTable (a vim plugin) and or :he digraphs in vim.

# poor man's vim digraphs w/ sxhkd:

shift + ctrl + k ; {a,e,i,o,u} ; {apostrophe,exclam,greater,colon}
    xdotool key --clearmodifiers {a,e,i,o,u}{acute,grave,circumflex,diaeresis}

# for uppercase, there might be better ways. A difference here 
# with vim is that you will have to keep shift pressed throughout 
# the end of the sequence (notice apostrophe becoming 
# quotedbl, other characters are already using the shift key)

shift + ctrl + k ; shift + {a,e,i,o,u} ; {quotedbl,exclam,greater,colon}
    xdotool key {A,E,I,O,U}{acute,grave,circumflex,diaeresis}

shift + ctrl + k ; c ; comma
    xdotool key ccedilla

shift + ctrl + k ; shift + c ; less
    xdotool key Ccedilla

shift + ctrl + k ; d ; g
    xdotool key degree

shift + ctrl + k ; s ; s
    xdotool key ssharp

shift + ctrl + k ; a ; e
    xdotool key ae

shift + ctrl + k ; o ; e
    xdotool key oe

shift + ctrl + k ; shift + o ; {_, shift + } e
    xdotool key --clearmodifiers OE

Remarks:

  1. you can not use native Ctrl+k as in vim, or you will lose the digraphs ability in vim. The above example therefore used shift + ctrl + k.
  2. you will have to manually enter all digraphs you need in your sxhkdrc file. I only include a few a them here.
  3. using a shell to run xdotool each time one of those digraph character is output may seem costly. I recommend it for occasional use only.
  4. For uppercase version of Eacute, Agrave, ... you will need to maintain the shift key pressed through the end of the sequence (see comment in above snippet). There might be other ways.
  5. The timing seems important, sometimes it won't work if you are to fast or too slow, I am not sure how to improve this.

Maybe due to the way of sxhkd's way of working with ; it seems that this randomly works or doesn't work. It may also be my mappings. Might also be related to xdotool ( #86 ) (fixed with xdotool --clearmodifiers, seemingly the shift in Shift + Ctrl + k ; a ; exclam (i.e. **Shift** + 1 ) was intercepted by xdotool when typing e.g. egrave, resulting in something like EGRAVE (-> i.e. not working most of the time) or Egrave (-> i.e. working only sometimes) based on your timing).

I will leave this idea open and maybe someone with a better understanding of sxhkd can help us improve this. For my occasional use of this, it works quite well enough.

@grepsuzette grepsuzette changed the title [Tip] Poor man's vim digraphs simulation with sxhkd [Tip] Poor man's vim digraphs emulation with sxhkd Dec 14, 2019
@grepsuzette grepsuzette changed the title [Tip] Poor man's vim digraphs emulation with sxhkd [Tip] Poor man's vim digraphs emulation with sxhkd and xdotool Dec 14, 2019
@grepsuzette grepsuzette changed the title [Tip] Poor man's vim digraphs emulation with sxhkd and xdotool [Tip in progress] Poor man's vim digraphs emulation with sxhkd and xdotool Dec 15, 2019
@grepsuzette grepsuzette changed the title [Tip in progress] Poor man's vim digraphs emulation with sxhkd and xdotool [Tip in progress] Poor man's vim digraphs emulation with sxhkd and xdotool in the terminal and elsewhere Dec 15, 2019
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

1 participant