I would like to remap or to create a shortcut for F3, F4 and F6 to copy cut and paste.
Using Ubuntu 22.04
I would like to remap or to create a shortcut for F3, F4 and F6 to copy cut and paste.
Using Ubuntu 22.04
Install autokey
sudo apt-get install autokey-gtk
Open Autokey
File -> New -> Folder
Select Folder and create New Script from File -> New -> Script
in the "# Enter script code" enter
keyboard.send_keys(shortcut you desire to imitate)
Examples
Copy:
keyboard.send_keys("<ctrl>+c")
Paste:
keyboard.send_keys("<ctrl>+v")
Cut:
keyboard.send_keys("<ctrl>+x")
NOTE: repeat Step 4-5 for each hotkey you want to add
Click on the second "set" on the Hotkey and set your hotkey
Test them out.
It should work now.
Enable automatically start Autokey at login (Edit -> preferences -> general) , clear the special hotkeys (Edit -> preferences -> Special Hotkeys) and we are done.
Fast forward 2024, Wayland is becoming the default desktop. The accepted answer, which uses a tools, Autokey, that requires Xorg, will not anymore work.
ydotool
is a small command line tool to simulate keystrokes and mouse clicks. It works on both Xorg and Wayland.
You can have F3 send out shortcut keys for copy with the following command:
ydotool key 29:1 46:1 46:0 29:0
Assign that command to F3 using the standard tool of your desktop environment for defining custom shortcut keys. For the standard Ubuntu desktop: "Settings", "Keyboard", then under "Keyboard Shortcuts" "Custom Shortcuts".
Keycodes can be seen with the sudo showkey
command. Ctrl is 29
, C is 46
. These keys are subsequently pressed (:1
) then released (:0
).
ydotool
is available in the Ubuntu software repositories and can be installed with sudo apt install ydotool
. Users of Ubuntu 22.04, however, should compile ydotool
themselves because the version in the software center is very outdated and does not work properly.
Even in later Ubuntu versions, when installed using APT, some configuration may be needed to make ydotool
work for a normal user. Check the section 4. Configuration in this answer.