2

I'm running xfce4 on debian. I'd like to assign keyboard shortcuts for the home and end keys (specifically, to move the cursor to the beginning and end of a line).

In the settings manager there is a gui interface for assigning keyboard shortcuts to commands. However, how could I set a keyboard shortcut (e.g. ctrl+a or ctrl+e) for another key (home or end)?

Thanks!

0

This could be an answer, but the intention was to provide useful hints.

If I read correctly, you are trying to bind a single key to several keys presses. The given example is to remap End to Ctrl+E (this may be easier to understand).

xmodmap and xbindkeys

The classic approach is to check your keycode using xev and use X tool like xmodmap to remap the keys, as explained in this answer on askubuntu.com. But this doesn't allow you to remap several keys, mentioned in the answer for this question.

The other approach is to use xbindkeys to grab the keys and xvkbd to send keys, whose answer was given to this post. However, this approach also has its own caveat which cause focus to lose, as mentioned by someone in the comment.

Actually, there is similar question being asked, to remap several key presses to another several key presses (which is one level harder than your request). Unfortunately, the answer has clearly mentioned that you can't achieve that with xmodmap and suggesting to use xbindkeys instead.

Alternative: xdotool

Some time ago, I was still using a two-button mouse (I know, quite old piece of hardware) and trying to emulate the mouse middle-click. Then, I discovered xdotool which was able to emulate mouse clicks, as well as keyboard key presses.

My suggestion is, use xdotool to emulate keyboard key press for End (this will give you a string of command). Then use this command to assign a custom shorcut Ctrl+E in Xfce4, which is found under Settings Manager > Keyboard > Application Shortcuts.

To build the command using xdotool, you can refer to several examples of which one of them is quoted as follows.

Example: focus the firefox url bar

WID=`xdotool search "Mozilla Firefox" | head -1`
xdotool windowactivate --sync $WID
xdotool key --clearmodifiers ctrl+l

# As of version 2.20100623, you can do this simpler version of above:
xdotool search "Mozilla Firefox" windowactivate --sync key --clearmodifiers ctrl+l

I haven't used this tool for some time, so I can't give exact answer to your question. In my opinion, using xdotool with Xfce4 Application Shortcuts is the best solution you can try on Debian Xfce.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.