Script Question: How to Send an Insert Mode?

With a PinePhone and its physical keyboard and Manjaro/xfce, I’m trying to build a simple script that will send a command to go into Insert Mode, type a character, and then return to Overwrite Mode, and exit.

Using xdotool, one rub is the kb’s Insert Mode is Fn + ; and my searches show a lot of issues with xdotool and a hard-coded Fn key.

With:

xmodmap -e "keycode 108 = Insert Insert"

I can circumvent possible Fn issues by successfully turning the unused AltGr key into an Insert/Overwrite key.

But I still don’t know how to call either the AltGr or Fn + ; in a script to toggle to Insert Mode and then back again to Overwrite.

Any ideas how to do this?

xev for X11 or showkey for console, ssh, etc, should work to get the keycode.
ex:

showkey -a

Thank you for your quick reply.

In xev, Fn + ; produces:

keycode 118 (keysym 0xff63, Insert)

AltGr produces:

keycode 108 (keysym 0xff63, Insert)

Could you suggest how to call either one in a script to generate an Insert Mode?

Thanks again.

Does this work as a command?

xdotool key 'Insert'; xdotool key 'x'; xdotool key 'Insert'

(that is of course assuming the desired character is ‘x’, and I got your intentions right)

Thanks again. While typing ‘x’ works, xdotool key 'Insert'; does not change to Insert Mode (or back) when calling said command in either LibreOffice or Abiword.

Very strange.

Hm… well, lets try the code:

xdotool key 0xff63; xdotool key 'x'; xdotool key 0xff63

Still the same result. ‘x’ is typed; Insert Mode remains uncalled.

Appreciate you staying with this.

And one (or two) more:

xdotool key 118; xdotool key 'x'; xdotool key 118
xdotool key 108; xdotool key 'x'; xdotool key 108

You did it. Both commands produce the desired results.

The reason behind this arcane script is because the PinePhone’s cpu can’t keep up with LibreOffice (laggy typing, etc), which forces a move to Abiword. And with these small screens, the easiest display on the eyes is white text on black background. But black background hides Abiword’s black cursor (Abiword cursor color can’t be changed). Abiword does use a red cursor when in Overwrite Mode, but Insert Mode is needed when adding special characters (called from script) so as not to overwrite other text.

More information than you wanted, I’m sure, but your knowledge/patience provided the solution and I’ve marked it as such.

Thank you again.

Sometimes I guess you just need to keep trying slightly different invocations :sweat_smile:
Glad its worked out … and hopefully there will be a more generally good solution in the future.

People have been complaining about the Abiword cursor color since 2003; I’m not holding my breath :slight_smile:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.