For Ubuntu 18.04.
I struggled with this problem for two days. I tried all the methods listed here earlier. And it looks like I came up with a solution. But it is very unstable and has bugs.
The basic idea is this: in the system settings you can specify the command that is started by the Ctrl+Shift+U key combination.
Note: if you specify
false as the command, the combination will not work at all.
However, we can specify the path to the script as the command, in which we will simulate pressing the same key combination.
To simulate keystrokes, I tried the
apt install xdotool) and the
apt install xautomation).
Both options were unstable. However,
xte turned out to be more flexible for me.
- Create a file
- Add permission to execute:
chmod u+x /home/username/shortcut.sh
- Specify the path to the script as a command for the Ctrl+Shift+U key combination in the keyboard settings
Here is an example script:
# Make a small delay in order to have time to release the keys.
# Simulate the release of just pressed keys, if they are still pressed.
xte 'keyup u' 'keyup Shift_L' 'keyup Control_L'
# Hack: Caps_Lock is used so that the system does not intercept this combination.
# You can try to remove it if it hinders you.
xte 'key Caps_Lock'
# Simulate pressing a key combination
xte 'keydown Shift_L' 'keydown Control_L' 'key u'
# Simulate releasing a key combination
xte 'keyup Shift_L' 'keyup Control_L'
# Restore Caps_Lock to the previous state.
xte 'key Caps_Lock'
I tested this in PhpStorm 2018.2 EAP Build #PS-182.3458.35 and I can say that it works, but with some caveats:
- this works slowly (on my rather old PC)
- during the execution of the script, it is better not to press any keys
- sometimes it may not work
- sometimes it can enter an infinite loop. Therefore, it's better to add a check to the script that the script is already running.
In general, if you do not often use this combination, then this solution may suit you.
But, probably, someone will come up with a better and more stable solution.
I hope this idea will help someone.