LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-14-2020, 11:21 PM   #1
onesapien
LQ Newbie
 
Registered: Jul 2020
Posts: 2

Rep: Reputation: 0
How to write a shell script for disabling keyboard.


Hi everyone,

New Linux user here.

Keyboard of my laptop is malfunctioning and wreaks havoc until its disabled.

I use "xinput float" command for it.

I want to disable it as soon as I log in. How can I write a script for disabling it or make it sort of a desktop icon which will execute this.
 
Old 08-14-2020, 11:51 PM   #2
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by onesapien View Post
Hi everyone,

New Linux user here.

Keyboard of my laptop is malfunctioning and wreaks havoc until its disabled.

I use "xinput float" command for it.

I want to disable it as soon as I log in. How can I write a script for disabling it or make it sort of a desktop icon which will execute this.
There are several ways to do this.

If you have the command you want to execute (looks like you do) just create the simple script, say, "disable_kbd":
Code:
#!/bin/bash

xinput float
Put this in ${HOME}/bin (assuming you have such a directory and it's in your PATH. Make it executable -- "chmod u+x ~/bin/disable_kbd". (If you haven't seen it before, "${HOME}" and "~" both refer to your home directory.)

Now go into your desktop manager and look for a panel widget that allows you to create a simple launcher. Create a new launcher for your panel and specify that script (with full path) as the command to execute. The drawback to this is: If you like to switch desktop managers from time to time, this method will only make your keyboard disabler available in the desktop environment in which you created the launcher.

Alternate: copy the script to ${HOME}/Desktop/. Refresh your desktop. You can launch it by double clicking on it. This isn't a great solution, though. If you were to edit the copy of the script in ~/Desktop, depending on the editor you use, you might wind up with the editor backup file (say, "disable_kbd~") cluttering the desktop.

Better: cd to your Desktop directory and create a symbolic link to the script:
Code:
$ cd ~/Desktop
$ ln -s ~/bin/disable_kbd .
Again, refresh your desktop. This method keeps you a.) from having two copies of the script laying around (one in ~/bin and another in ~/Desktop) and b.) eliminates the head scratching you'll do when you modify the one in your bin directory and the one on your desktop doesn't do what you expect.

As before, you launch it by double clicking on it.

HTH...
 
1 members found this post helpful.
  


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
write a shell script to enter ur name through keyboard and print it yusufsiddiqui Linux - Newbie 2 10-11-2009 06:46 AM
How to ssh from a shell script ? For ppl who can write shell scripts. thefountainhead100 Programming 14 10-22-2008 06:24 AM
[SHELL SCRIPT] Write at the right of the shell window Creak Linux - General 2 04-02-2004 03:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:38 AM.

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