13

I would like to disable the Ctrl-Alt-Backspace combination using a command line tool, without root priviliges.

I know I can use setxkbmap to enable “zapping” with the option terminate:ctrl_alt_bksp. Further, setxkbmap -option [naming no option] removes all options. Is there a way to unset only one option?

4
  • Maybe this will help. Sep 14, 2015 at 10:47
  • 1
    setxkbmap -option -option $(setxkbmap -query | sed -n '/options:\s*\|terminate:[^,]*/s///gp')
    – Costas
    Sep 14, 2015 at 11:15
  • 1
    @don_crissti I hope that there is more correct decision than my crutch…
    – Costas
    Sep 14, 2015 at 13:59
  • 2
    @Costas - alas, there is no straightforward way, setxkbmap -option -option new:options is the easiest way. Sep 14, 2015 at 14:04

4 Answers 4

9

A little bit crutched: remove all options using -option with an empty argument first, then set same options with terminate excluded from the list:

setxkbmap -option -option $(setxkbmap -query |
    sed -n 's/options:\s*\(terminate:[^:]*,\)\?\|,terminate:[^,]*//gp')
1
  • To be clear, I was looking for something more straightforward — like you said yourself. It really seems there should be an option to do that, but if there isn't, this is The Answer.
    – xebtl
    Sep 15, 2015 at 7:03
7

From my experience (limited) what worked best was using:

setxkbmap -query

And that prints out your current settings ( setxkbmap -print is another alternative to show your current keyboard settings) Then delete all the options by using the -option without any arguments:

setxkbmap -option

Then reintroduce the new options one at time:

setxkbmap -option key:key_replacement
0

Easy way:

setxkbmap -option
setxkbmap -option 'terminate:ctrl_alt_bksp'
0

Here's a more general script, based on the accepted answer; you can pass patterns, as in unsetxkbmap-option 'terminate:.* or, to undo -option ctrl:swapcaps but preview results: unsetxkbmap-option -n '.*swap.*'

!/bin/sh -eu
DRY=
while test $# -gt 0; do case "$1" in
--dry-run|-n) shift; DRY=y ;;
--) shift; break ;;
-*) echo "Unknown: $1"; exit 1 ;;
*) break ;;
esac; done
opts=$(setxkbmap -query |
 perl -wlnE 'if (/^options:\s*/gc) { ($& =~ /'^"$1"'$/ or print "-option $& ") while /[^,]+/g }'
)
printf '%s\n' "$opts"
test -z "$DRY" && setxkbmap -option $opts

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.