You can remap the key using ~/.Xmodmap
. Use xev
(in a terminal) to find the offending keycode, then assign a different keysym, e.g. XF86WakeUp. Append this line to ~/.Xmodmap
(create that file if it does not yet exist):
keycode 150 = XF86WakeUp
After logging out and logging in again your key should be mapped. If you don't want to log out, you can also use xmodmap ~/.Xmodmap
to reload the key mappings.
Using xev
to actually find the keycode of the key that you want to remap might be not so easy: if the key is already bound to an action (e.g. in the Gnome keyboard properties), xev
does not show the keycode. As an example, this is the kind of xev
output that you want to see:
KeyPress event, serial 41, synthetic NO, window 0x5800001,
root 0xb3, subw 0x0, time 312883, (737,182), root:(946,647),
state 0x0, keycode 180 (keysym 0x1008ff18, XF86HomePage), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
You can see the keycode (180) in the third line after the word "keycode". If you don't get such a block that starts with "KeyPress event", your key probably is already bound. You can try to use a non-Gnome desktop like LXDE or KDE and use xev
there.
Unfortunately, the lock-screen utility gnome-screensaver-command
, which the Ctrl+Alt+L shortcut uses, will also activate the blank-screen "screensaver" whenever it is told to lock the screen.
The trick then is to "fake" a keystroke immediately after the screen is locked to get rid of the blank-screen and leave the lock-screen on. We'll do this with xdotool
, a small command-line utility which allows automation of keyboard and mouse clicks/movements.
Install xdotool
with
sudo apt-get install xdotool
Paste the following to a file in your home directory, such as locknoblank.sh
:
#!/bin/bash
gnome-screensaver-command -l
xdotool sleep 1 key Ctrl
Go to System Settings...Keyboard...Shortcuts and remove Ctrl+Alt+L as the lock-screen shortcut so we can re-use it for our custom command. Click on "System" on the left sidebar, then click on the right of "Lock Screen" where it says "Ctrl+Alt+L"; it will now say "New Accelerator...". Press Backspace to remove the shortcut.
Now go to Custom Shortcuts on the left, and add a shortcut, naming it whatever you want to with the command as /home/username/locknoblank.sh
. Click Apply, then click on its right where it says "Disabled" to get "New Accelerator", and press Ctrl+Alt+L.
Close System Settings, and you're done!
To prevent reactivation of the screensaver (idle timeout)
Open a terminal, and type/paste:
gsettings set org.gnome.desktop.session idle-delay 7200
This sets the screensaver idle activation time to 2 hours (or 7200 seconds). You can set it to anything you want; the default is 600.
Note: For Ubuntu 18.04, use
xdg-screensaver lock
instead of gnome-screensaver-command -l
.
Best Answer
the issue is the description is a bit misleading (for me as well) ..
ctrl_L .. doesnt mean ctrl+l but the left! ctrl button
so you just have to press ctrl + alt (without any other char) on the left side of the keybord