0

I have been wondering if it is possible to create an application whose sole purpose is to perform a specific keyboard shortcut assigned to it when its icon is clicked.

I believe that this can be done using the file that the keyboard shortcut is saved in. However, unfortunately I could not find a folder that might contain such files. Kindly respond as soon as possible if you have any idea how to do such thing because I am kind of in a hurry.

Thank you in advance

1 Answers1

0

You can achieve such an effect using a small and very useful command line tool, xdotool. For example, the command

sleep 0.3s; xdotool key ctrl+x

will trigger a Ctrl+x keypress when executed.

Include these command in a custom launcher file to obtain a clickable item.

The sleep command introduces a small 300 ms delay before executing the command. This will decrease the chance that the keypress is discarded by the keyboard buffer. To have this work directly in a .desktop file, write your Exec= line as:

Exec=sh -c "sleep 0.3s; xdotool key ctrl+x"

In the .desktop file, you also can specify your icon.

vanadium
  • 88,010