You can use
easystroke to create right-clicks with a modifier plus tap, such as Ctrl + Alt + tap. With additional configuration, this can be accessed single-handedly with just a touchscreen, see below.
This is quite nice, as "modifier plus tap" as a right-click cannot be configured with any of
touchegg (does not recognize modifiers),
mouseemu (does not recognize taps as they lack scancodes) or
xsetwacom "…" set Button 1 … (does not recognize taps as finger input is not a button event in the driver).
easystroke program is only minimally maintained right now, but in the release notes they link to a recent Ubuntu package, built on Ubuntu 18.04. It worked well for me (Ubuntu 18.10 here). You can install it as follows:
sudo apt install ./easystroke_0.6.0-0ubuntu8_amd64.deb
Start the program with
Under the second tab "Preferences", click "Gesture Button" and Ctrl + Alt + tap into the gray field. Ctrl + Alt seems to be the best choice of modifier, at least under LXQt, because:
- Both Shift + click and Ctrl + click are used for multi-selection already and would become unavailable for that if assigned to
- Alt, Super and any combination involving Super will not be seen by
easystroke. This is probably a LXQt or Openbox coniguration issue, but I could not resolve it so far.
Under the first tab "Actions", click "Add Action".
Configure your action with "Type: Command" and "Details:
xdotool keyup ctrl alt; xdotool click 3". Adapt according to your chosen modifiers.
Depending on the modifiers, clearing the modifiers first is important to prevent side effects. For example Shift + right-click in Chrome would lead to text selection. Also, clearing the modifiers explicitly is needed to prevent stuck modifiers when triggering these key presses with software (see section 3 below). Not clearing the modifiers on its own before executing the command could be considered a bug in
Click "Record Stroke" and record a single tap.
You can disable the (here rather useless) popups under "Preferences → Appearance → Show Popups".
You can limit this gesture recognition to only your touchscreen and perhaps pen input device under "Advanced → Devices".
Now, Ctrl + Alt + tap will create a right-click.
easystroke has great gesture recognition for single-touch gestures ("drawing shapes on the screen") which you can use to automate many tasks while using the touchscreen. That's its main purpose, while right-click emulation is just a side effect.
3. Improvement: touch-only right-clicks
Now let's improve this configuration so that you can trigger right-clicks with just one hand and a touchscreen by (1) tapping on a special on-screen button that will mean "next tap is a right-click" and (2) then tapping on the screen just normally.
Here is a recipe for Lubuntu (LXQt) and using the Ctrl + Alt modifier chosen above, but the principle is the same in all desktop environments and with all modifiers: a custom quicklaunch entry in the panel.
Create a custom icon for your quicklaunch entry and save it as
Create a custom
.desktop file and save it as
.local/share/applications/rightclick.desktop, with the following content. Note that you have to supply
username for the absolute path.
Comment=Next tap is a rightclick via Ctrl + Alt + easystroke gesture.
Exec=xdotool keydown ctrl alt
Add another quicklaunch widget to your LXQt panel. While in principle you can also modify your existing one, I found that one placed in the bottom right corner of the screen is the most natural for right-handed operation and also accidental misclicks will only show the date (if that's what is next to the left, as in my case) instead of starting some large application.
~/.config/lxqt/panel.conf and adjust the new
[quicklaunch2] section to refer to your custom
.desktop file. Again, you have to supply
username. Example how it may look:
Restart the LXQt panel to make the changes effective. For that:
- Go to "LXQt menu → Preferences → LXQt Settings → Session settings".
- Select "Basic Settings → LXQt Modules → Panel".
- Click "Stop".
- Click "Start".
(You could also execute
killall lxqt-panel && lxqt-panel in the Alt + F2 launch dialog, but that will interfere with the panel status recognized in the above mentioned dialog, and if you mix both techniques you'd have two panels running on top of each other, with one missing some panel icons. So better don't. This is still buggy.)
Also, if you have special hardware buttons at the side of the touchscreen, you could assign the
xdotool keydown ctrl alt command to one of them instead.
4. Other improvements and troubleshooting
As a nice side effect, the above technique for touch-only right-clicks also enables single-handed access to all the other gestures you may have configured in
easystroke. That's a pretty powerful feature for touchscreen usage automation.
When you configure other gestures in
easystroke, be aware of the following bug:
easystroke does not clear our chosen modifiers before doing the configured action. The action types "Key" and "Text" all result in key combinations together with Ctrl + Alt in the case above, which makes them unusable. As a workaround, choose action type "Command" instead and clear the modifiers yourself the same way as above. So to trigger Ctrl + V, the command would be:
xdotool keyup ctrl alt; xdotool key "ctrl+v"
--clearmodifiers does not help here as it only disables the modifiers during the key combination to execute and re-applies them afterwards. Which in this case would make the next tap a right-click as per the technique above, but we would not want that in this case.)
If you ever have stuck modifiers during testing, pressing and releasing the modifier keys on the physical keyboard will fix the condition.
Sometimes during testing these things, my LXQt my keyboard and mouse events would become very messed up. In such a case, only logging out from the graphical environment and logging in again helped.
The cleanest way to implement single-handed touch-only operation in
easystroke, including for the case of right-clicks as required here, would be that a tap on the
easystroke panel icon brings it into the same internal state as our custom panel icon configured above, but without actually changing the keyboard modifier state because that can lead to stuck modifiers etc.. To show the
easystroke window, one would then have to use the context menu of its panel icon. Obviously, that requires some changes in the