1

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 "[email protected]"

and

cat "[email protected]"

and

sed "[email protected]"

... 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?

2 Answers 2

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("[email protected]")

and set a hotkey and you're done.

3
  • 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. Oct 20, 2018 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, 2018 at 9:20
  • I like the sound of this, but the command keyboard.send_keys("[email protected]") doesn't include any mention of autokey. To clarify: Would the command keyboard.send_keys("[email protected]") go into the > System Settings... > Keyboard > Shortcuts > Custom Shortcuts > Command: field? Nov 23, 2018 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 '[email protected]'"

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
1
  • This no longer works in Linux Mint 21.1. When you click the shortkey it just randomly opens and closes a bunch of windows and menus. Bizarre.
    – Kane
    Jul 31, 2023 at 18:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .