0

I want to use keyboard combination Alt-E to write my email address, rather than have to type it out all the time.

I know how to create a custom key in

unity-control-center
  • Keyboard
  • Shortcuts
  • Custom Shortcuts

...but I can't figure out what to write in the Command: field. I've tried:

echo "my@emailaddress.com"

and

cat "my@emailaddress.com"

and

sed "my@emailaddress.com"

... but as you can tell, I don't know what I'm doing. I've just been trying things from a websearch "linux custom key output specified text".

It doesn't seem as if a macro would be necessary, nor the installation of another application. I've found a couple of other solutions here that both involve installing another application (autokey, xdotool). It seems to me that there would be a command on Linux that I would be able to use in the Command: field. Could that be true?

1

I'm not sure if you can run a command almost essentially in a terminal and have it auto-type to any application window that happens to be open & selected.

Autokey does, and works great and is very simple to just type some keys, essentially just use

keyboard.send_keys("my@emailaddress.com")

and set a hotkey and you're done.

  • Thanks. In the Keyboard settings, I wonder what the Command: field actually means and admits. As I mentioned, I'm trying to avoid installing the application if I can avoid it. – el_gallo_azul Oct 20 '18 at 9:10
  • 1
    In XFCE the keyboard shortcuts seem to just run a command, just like running it in a terminal, good for starting a program but not so good for desktop integrated typing. I suspect unity's similar – Xen2050 Oct 20 '18 at 9:20
  • I like the sound of this, but the command keyboard.send_keys("my@emailaddress.com") doesn't include any mention of autokey. To clarify: Would the command keyboard.send_keys("my@emailaddress.com") go into the > System Settings... > Keyboard > Shortcuts > Custom Shortcuts > Command: field? – el_gallo_azul Nov 23 '18 at 23:22
1

Simplest solution

"It seems to me that there would be a command on Linux that I would be able to use in the Command: field. Could that be true?" No, not without installing anything additionally, but

..Make xdotool type it for you.
You have several options and tools, but the easiest / simplest solution is to add the following command to a shortcut:

/bin/bash -c "sleep 0.2 && xdotool type 'monkey@zoo.com'"

The sleep 0.2 is to prevent your actual keypress (shortcut) to interfere with the virtual keypress by xdotool.

Note

Depending on what else you have installed, you might need to install xdotool:

sudo apt install xdotool

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.