add possibility to do `keyd do` without any additional modifiers
Would it be possible to add a feature that is analogous do keyd do but ignores any active modifiers?
What I mean is to add a function, say "nomoddo" so that if I'm (physically) holding alt and then the command keyd nomoddo C-v is run keyd will lift alt, press ctrl, tap v, lift ctrl and then press alt again, same as when I have a binding like
[alt]
<something> = C-v
Use case
Many use cases for key remapping involve entering large amounts of text into programs (e.g. predetermined phrases, things like the current date+time, or scripts that copy the current mouse selection, modify it in some way and insert it back). The only easy way to do this seems to be to use the clipboard. The only (somewhat) reliable way to paste from the clipboard is to send ctrl+v or shift+insert to the program, which can be easily done with keyd do C-v.
Now the problem is that if I bind this action to something like alt+a then alt will still be pressed when the action triggers and nothing gets pasted.
Can you do it with the following?
[alt]
a = macro(esc 100ms C-v)
@tkna91 I'm confused. The example you provide will paste the clipboard (in most applications), same as
[alt]
a = C-v
(this will generate a alt up event before sending the control down event and re-press alt at the end of the macro).
What I'm looking for is a way to use keyd to produce control+v from a script, regardless of what other modifiers are pressed.
Sorry if my guess is off. Are you saying that you want a mode that combines the current 1 and 2 operations below, which would be 3?
- when the Alt key is pressed
keyd virtual keyboard 0fac:0ade leftalt down
keyd virtual keyboard 0fac:0ade leftcontrol down
keyd virtual keyboard 0fac:0ade leftalt up
keyd virtual keyboard 0fac:0ade leftcontrol up
keyd virtual keyboard 0fac:0ade leftalt down
keyd virtual keyboard 0fac:0ade leftalt up
- executed
keyd do "C-v".
keyd virtual keyboard 0fac:0ade leftcontrol down
keyd virtual keyboard 0fac:0ade v down
keyd virtual keyboard 0fac:0ade v up
keyd virtual keyboard 0fac:0ade leftcontrol up
- want a mode like this when
keyd do "C-v"is executed (merge 1 and 2)
keyd virtual keyboard 0fac:0ade leftalt down
keyd virtual keyboard 0fac:0ade leftcontrol down
keyd virtual keyboard 0fac:0ade leftalt up
keyd virtual keyboard 0fac:0ade leftcontrol up
keyd virtual keyboard 0fac:0ade leftcontrol down
keyd virtual keyboard 0fac:0ade v down
keyd virtual keyboard 0fac:0ade v up
keyd virtual keyboard 0fac:0ade leftcontrol up
I think the way that keyd do currently works is good and shouldn't be changed. I proposing a variant, say keyd nomoddo, that would behave as follows: If keyd nomoddo C-v is called when no modifiers are currently active then you would get
keyd virtual keyboard 0fac:0ade leftcontrol down
keyd virtual keyboard 0fac:0ade v down
keyd virtual keyboard 0fac:0ade v up
keyd virtual keyboard 0fac:0ade leftcontrol up
same as keyd do C-v. However if you do keyd nomoddo C-v while the alt layer is active (most likely because the alt key is physically being pressed) you would get
keyd virtual keyboard 0fac:0ade leftalt up
keyd virtual keyboard 0fac:0ade leftcontrol down
keyd virtual keyboard 0fac:0ade v down
keyd virtual keyboard 0fac:0ade v up
keyd virtual keyboard 0fac:0ade leftcontrol up
keyd virtual keyboard 0fac:0ade leftalt down
The problem with this proposal is that the behaviour would depend on whether or not the keyboard is currently managed by keyd. keyd can't release keys on keyboards that it hasn't grabbed, so the script would not be portable.
For this particular application you should be able to use something like xclip -o, since most applications will automatically set the selection when you highlight text.
@ces42 Something like this might be an alternative for now.
[alt]
a = macro(500ms C-v)
#!/bin/bash
FILE=/tmp/file
date > $FILE
#X11
xclip < $FILE
#Wayland
#wl-copy < $FILE
sleep 0.5
keyd do C-v