Ruby Hack to toggle touchpad on your notebook

Well, my Dell 1520 didn’t have a button to toggle touchpad and when you are coding your way to glory, the touchpad comes in your way and slows you down. Here is a hack, that toggles the touchpad. Save it in your ~/bin/ directory and enjoy:

#!/usr/bin/env ruby

touchpadout = `synclient -l`
touchpadout.split("\n").each do |b_output|
  next unless b_output =~ /TouchPadOff/i
  key,t_value = b_output.split('=')
  value = t_value.strip.to_i
  if value == 0
    system("synclient TouchPadOff=1")
    system("synclient TouchPadOff=0")

Leave a Reply

You must be logged in to post a comment.