LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-11-2013, 08:49 AM   #1
drink76cup
LQ Newbie
 
Registered: May 2013
Posts: 10

Rep: Reputation: Disabled
Help with a bash script


Hello,

I have a notebook, and when I try to write text documents, sometimes the cursor moves to a completely different part of the screen.

I found the solution, and thats to modprobe -r the module which drives the touchpad. However, once I've finished writing a text document, I'd like to be able to turn the trackpad back on, by loading the same kernel module as I used to turn it off.

I want both on and off functionality tied to a single key on my keyboard, so I guess I need a bash script, but I dont know how I'd do that. I was hoping someone might be able to help with a script.
 
Old 06-11-2013, 10:15 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,623

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
Quote:
Originally Posted by drink76cup View Post
Hello,

I have a notebook, and when I try to write text documents, sometimes the cursor moves to a completely different part of the screen.

I found the solution, and thats to modprobe -r the module which drives the touchpad. However, once I've finished writing a text document, I'd like to be able to turn the trackpad back on, by loading the same kernel module as I used to turn it off.

I want both on and off functionality tied to a single key on my keyboard, so I guess I need a bash script, but I dont know how I'd do that. I was hoping someone might be able to help with a script.
We'll be glad to help...so post what you've written/tried so far, and where you're stuck. Depending on your window manager, you can probably tie a script to a particular hotkey, so that part is fairly easy. To get something to 'toggle' as you'd like, try looking for the module first with an lsmod command...if it's there, run the modprobe -r. If it's NOT there, just modprobe.
 
Old 06-11-2013, 12:28 PM   #3
drink76cup
LQ Newbie
 
Registered: May 2013
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
We'll be glad to help...so post what you've written/tried so far, and where you're stuck. Depending on your window manager, you can probably tie a script to a particular hotkey, so that part is fairly easy. To get something to 'toggle' as you'd like, try looking for the module first with an lsmod command...if it's there, run the modprobe -r. If it's NOT there, just modprobe.
Im not too good with bash scripting, although I do know which driver module to remove/load ('psmouse'). I can tie the script to a key with fluxbox, its just getting the script to toggle from on to off, off to on, etc.
 
Old 06-11-2013, 12:42 PM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,623

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
Quote:
Originally Posted by drink76cup View Post
Im not too good with bash scripting, although I do know which driver module to remove/load ('psmouse'). I can tie the script to a key with fluxbox, its just getting the script to toggle from on to off, off to on, etc.
There are excellent tutorials you can read, the links are in my posting signature. The hints I provided before should be what you need to get going. What you need to do is to run lsmod and pipe it into grep looking for your psmouse module. Again, if it's present, run the modprobe -r to remove it. If it's NOT found, run the modprobe to insert it.

A good way to get better at scripting is to actually DO it. Again we will be glad to HELP, but we aren't going to write your scripts for you.
 
Old 06-11-2013, 01:29 PM   #5
drink76cup
LQ Newbie
 
Registered: May 2013
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
A good way to get better at scripting is to actually DO it. Again we will be glad to HELP, but we aren't going to write your scripts for you.
ok, no problem, Im just a bit pushed to learn at the moment. Thanks for the advice.
 
Old 06-11-2013, 01:48 PM   #6
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
If it is by any chance a Synaptics touchpad, this works for me:
Code:
#!/bin/bash

synclient TouchpadOff=$(synclient -l|grep -c 'TouchpadOff.*=.*0')
It uses the synclient program to toggle the touchpad on or off. I have bound it to a key-combination and it works without a hitch.
 
1 members found this post helpful.
Old 06-11-2013, 05:40 PM   #7
litzel
Member
 
Registered: May 2013
Location: Athens, Greece
Distribution: Xubuntu 12.04, Linux Mint 13
Posts: 80

Rep: Reputation: 5
I too had that problem, I fixed it with syndaemon, as such:

Code:
syndaemon -d -p 7000
where 7000 is a random process number given by me.
It of course only applies in synaptic touchpad...
 
1 members found this post helpful.
Old 06-12-2013, 04:05 AM   #8
drink76cup
LQ Newbie
 
Registered: May 2013
Posts: 10

Original Poster
Rep: Reputation: Disabled
I wanted to turn off the touchpad completely so I'll use Tobi's solution, thank you Tobi.

Thanks everyone, that should make it easier to type documents.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Converting Script from Linux (GNU) Bash 4 to Solaris Bash 2.05 - Any cheat sheet? oly_r Solaris / OpenSolaris 6 05-03-2013 08:25 AM
How to get some bash scripts into a simple bash script with some echo and if statement. y0_gesh Programming 3 03-01-2012 09:46 AM
Variables and Mkvextract in a bash script and a good resource for bash help? gohmifune Linux - General 9 04-13-2011 08:37 AM
SSH connection from BASH script stops further BASH script commands tardis1 Linux - Newbie 3 12-06-2010 08:56 AM
[SOLVED] Using a long Bash command including single quotes and pipes in a Bash script antcore Linux - General 9 07-22-2009 11:10 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration