3

My problem is about if command.

I have tried to type this in console:

if gsettings get org.gnome.settings-daemon.peripherals.touchpad touchpad-enabled; then gsettings set org.gnome.settings-daemon.peripherals.touchpad touchpad-enabled false; else gsettings set org.gnome.settings-daemon.peripherals.touchpad touchpad-enabled true; fi

But this seems to disable the touchpad although it is yet disabled.

Typing help if I have learned that the commands after the word then are executed when the output of the command after the word if is 0 (instead of true, as usual in other programming lenguages).

How can I write a command that toggles the touchpad then?

1
  • This no longer works in Ubuntu 16.04 "No such schema 'org.gnome.settings-daemon.peripherals.touchpad'" Mar 29, 2016 at 9:07

1 Answer 1

3

You just have to evaluate the output (not the exit code) of gsettings:

if $(gsettings get org.gnome.settings-daemon.peripherals.touchpad touchpad-enabled); then gsettings set org.gnome.settings-daemon.peripherals.touchpad touchpad-enabled false; else gsettings set org.gnome.settings-daemon.peripherals.touchpad touchpad-enabled true; fi

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .