var1="r on"
var2="r off"
if [[ $(xset r on) = true ]] then
  $xset "$var1"
  $xset "$var2"

is the script which I tried to run to toggle the key repeat.

When running the script, the key repeat is kept on/off.

Apologies in advance if I sound like a newbie. I'm really new to this scripting stuff.

Edit: I tried running the script in a terminal, but the output was:

Toggle key repeat.sh: 5: Toggle key repeat.sh: [[: not found
Toggle key repeat.sh: 9: Toggle key repeat.sh: r off: not found

You want to do something like this:


if [[ $(xset q) =~ 'auto repeat:  on' ]]
    xset r off
    xset r on
| improve this answer | |
  • This works, but when running it from the terminal it doesn't work. Still, it suffices. – Psionikal May 2 at 20:03
  • how do you run it – bac0n May 2 at 20:04
  • To correct myself, it does work when run from terminal, doing ./script.sh – Psionikal May 2 at 20:09
  • dont think anything is tracking the repeat setting in the console (believe xset is tracked by x) you can set repeat with setterm --repeat on|off or echo -e "\033[?8h" and "\033[?8l" – bac0n May 3 at 11:09

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.