Archive for the ‘ruby’ Category

Ruby Hack to toggle touchpad on your notebook

Tuesday, August 14th, 2007

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″)
  else
    system(“synclient TouchPadOff=0″)
  end
end