3

I would like to remap or to create a shortcut for F3, F4 and F6 to copy cut and paste.

Using Ubuntu 22.04

Vitor Abella
  • 7,537

2 Answers2

2
  1. Install autokey

     sudo apt-get install autokey-gtk
    
  2. Open Autokey

  3. File -> New -> Folder

  4. Select Folder and create New Script from File -> New -> Script

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

  1. Click on the second "set" on the Hotkey and set your hotkey

  2. Test them out.

It should work now.

Extra

Enable automatically start Autokey at login (Edit -> preferences -> general) , clear the special hotkeys (Edit -> preferences -> Special Hotkeys) and we are done.

Credits: https://ubuntuforums.org/showthread.php?t=1764318

Artur Meinild
  • 26,018
Vitor Abella
  • 7,537
0

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.

vanadium
  • 88,010