Ubuntu 19.04 Alternate Keyboard Shortcut for Home/End Buttons
772
I am using Ubuntu 19.04 and what to create key combinations for Home and End buttons. I am unable to understand what should I enter in the command dialog?
In the "Command" section of the "Set Custom Shortcut" dialog, you need to provide a command that needs to be executed when the key combination is pressed. That could be the name of an executable, e.g. gnome-terminal would cause the keyboard combination to lauch a terminal window, or firefox would cause firefox to launch. That command may also be an executable script containing a range of commands. For example, I have a hotkey that (only) blanks my screen (without locking or anything else). The script is called blankscreen and resides in my bin folder in my home folder. The script is nothing else than a small text file, containing:
#!/bin/bash
sleep 0.3 && xset dpms force off
The script file is set to be executable (right-click the script file, "Permissions" tab). In the "Command" section, I would then fill out the full pathname of the script:
/home/$USER/bin/blankscreen
(where "$USER" is to be replaced by your real login.)
Specific answer on creating extra home key
Easy approach using Settings - Keyboard
For what you want to do, i.e, have an extra key combination for Home or End you may need to resort to a utility xdotool. It can simulate key presses. Install xdotool first: it is not installed by default. To create an extra Home, fill out following code directly in the "command" field:
sh -c "sleep 0.4 ; xdotool key Home
Deeper system approach
You can redefine keys and key combinations with tools such as sxhkd or xbindkeys. This will provide a much more integrated, seamless solution but requires some more technical skills to set up.
To use 'Home' and 'End' as commands for keyboard shortcuts, it is neccesary to install xdotool and then enter as the command in the Set Custom Shortcuts window as:
xdotool key --clearmodifiers Home
or
xdotool key --clearmodifiers End
Without including the --clearmodifiers part I found that it would jump to the start of the page rather than the start of the sentence. Another reply here suggested that it was neccesary to preface with sh -c "sleep 0.4 ; but I found this stopped it from working.
General answer on the "command" item
In the "Command" section of the "Set Custom Shortcut" dialog, you need to provide a command that needs to be executed when the key combination is pressed. That could be the name of an executable, e.g.
gnome-terminal
would cause the keyboard combination to lauch a terminal window, orfirefox
would cause firefox to launch. That command may also be an executable script containing a range of commands. For example, I have a hotkey that (only) blanks my screen (without locking or anything else). The script is calledblankscreen
and resides in my bin folder in my home folder. The script is nothing else than a small text file, containing:The script file is set to be executable (right-click the script file, "Permissions" tab). In the "Command" section, I would then fill out the full pathname of the script:
(where "$USER" is to be replaced by your real login.)
Specific answer on creating extra home key
Easy approach using Settings - Keyboard
For what you want to do, i.e, have an extra key combination for Home or End you may need to resort to a utility
xdotool
. It can simulate key presses. Install xdotool first: it is not installed by default. To create an extra Home, fill out following code directly in the "command" field:Deeper system approach
You can redefine keys and key combinations with tools such as
sxhkd
orxbindkeys
. This will provide a much more integrated, seamless solution but requires some more technical skills to set up.To use 'Home' and 'End' as commands for keyboard shortcuts, it is neccesary to install
xdotool
and then enter as the command in theSet Custom Shortcuts
window as:xdotool key --clearmodifiers Home
orxdotool key --clearmodifiers End
Without including the
--clearmodifiers
part I found that it would jump to the start of the page rather than the start of the sentence. Another reply here suggested that it was neccesary to preface withsh -c "sleep 0.4 ;
but I found this stopped it from working.