Is there a way to disable a laptop's internal keyboard?
A week ago, I spilt the contents of my cup onto my laptop keyboard. Half of the keys no longer work, except one! The letter Q which is very active regularly.
This is very disturbing as I work.
Is there a way to disable the internal keyboard of a laptop?
Is it possible with xmodmap
?
keyboard
migrated from stackoverflow.com Jul 7 '12 at 22:05
This question came from our site for professional and enthusiast programmers.
add a comment |
A week ago, I spilt the contents of my cup onto my laptop keyboard. Half of the keys no longer work, except one! The letter Q which is very active regularly.
This is very disturbing as I work.
Is there a way to disable the internal keyboard of a laptop?
Is it possible with xmodmap
?
keyboard
migrated from stackoverflow.com Jul 7 '12 at 22:05
This question came from our site for professional and enthusiast programmers.
What brand and model laptop is it?
– Mitch♦
Aug 21 '12 at 21:18
it'sHP pavilion dv9000
– atmon3r
Aug 21 '12 at 21:31
4
The most straightforward way would be to lift the keyboard and disconnect it from the motherboard. You can then place it right back down where it was, sans the connection. This way the keyboard will be disabled after reinstalls and you wont need to bother with software. See this link, about halfway down the page where it gets to the keyboard: insidemylaptop.com/…
– Mark Paskal
Aug 21 '12 at 22:00
Might also be worth taking it out, taking it apart, an cleaning between the layers..
– JonasCz
Mar 1 '15 at 14:25
add a comment |
A week ago, I spilt the contents of my cup onto my laptop keyboard. Half of the keys no longer work, except one! The letter Q which is very active regularly.
This is very disturbing as I work.
Is there a way to disable the internal keyboard of a laptop?
Is it possible with xmodmap
?
keyboard
A week ago, I spilt the contents of my cup onto my laptop keyboard. Half of the keys no longer work, except one! The letter Q which is very active regularly.
This is very disturbing as I work.
Is there a way to disable the internal keyboard of a laptop?
Is it possible with xmodmap
?
keyboard
keyboard
edited Feb 24 '14 at 22:37
Braiam
51.6k20136220
51.6k20136220
asked Jul 7 '12 at 13:00
atmon3ratmon3r
4631614
4631614
migrated from stackoverflow.com Jul 7 '12 at 22:05
This question came from our site for professional and enthusiast programmers.
migrated from stackoverflow.com Jul 7 '12 at 22:05
This question came from our site for professional and enthusiast programmers.
What brand and model laptop is it?
– Mitch♦
Aug 21 '12 at 21:18
it'sHP pavilion dv9000
– atmon3r
Aug 21 '12 at 21:31
4
The most straightforward way would be to lift the keyboard and disconnect it from the motherboard. You can then place it right back down where it was, sans the connection. This way the keyboard will be disabled after reinstalls and you wont need to bother with software. See this link, about halfway down the page where it gets to the keyboard: insidemylaptop.com/…
– Mark Paskal
Aug 21 '12 at 22:00
Might also be worth taking it out, taking it apart, an cleaning between the layers..
– JonasCz
Mar 1 '15 at 14:25
add a comment |
What brand and model laptop is it?
– Mitch♦
Aug 21 '12 at 21:18
it'sHP pavilion dv9000
– atmon3r
Aug 21 '12 at 21:31
4
The most straightforward way would be to lift the keyboard and disconnect it from the motherboard. You can then place it right back down where it was, sans the connection. This way the keyboard will be disabled after reinstalls and you wont need to bother with software. See this link, about halfway down the page where it gets to the keyboard: insidemylaptop.com/…
– Mark Paskal
Aug 21 '12 at 22:00
Might also be worth taking it out, taking it apart, an cleaning between the layers..
– JonasCz
Mar 1 '15 at 14:25
What brand and model laptop is it?
– Mitch♦
Aug 21 '12 at 21:18
What brand and model laptop is it?
– Mitch♦
Aug 21 '12 at 21:18
it's
HP pavilion dv9000
– atmon3r
Aug 21 '12 at 21:31
it's
HP pavilion dv9000
– atmon3r
Aug 21 '12 at 21:31
4
4
The most straightforward way would be to lift the keyboard and disconnect it from the motherboard. You can then place it right back down where it was, sans the connection. This way the keyboard will be disabled after reinstalls and you wont need to bother with software. See this link, about halfway down the page where it gets to the keyboard: insidemylaptop.com/…
– Mark Paskal
Aug 21 '12 at 22:00
The most straightforward way would be to lift the keyboard and disconnect it from the motherboard. You can then place it right back down where it was, sans the connection. This way the keyboard will be disabled after reinstalls and you wont need to bother with software. See this link, about halfway down the page where it gets to the keyboard: insidemylaptop.com/…
– Mark Paskal
Aug 21 '12 at 22:00
Might also be worth taking it out, taking it apart, an cleaning between the layers..
– JonasCz
Mar 1 '15 at 14:25
Might also be worth taking it out, taking it apart, an cleaning between the layers..
– JonasCz
Mar 1 '15 at 14:25
add a comment |
11 Answers
11
active
oldest
votes
You can use xinput
to float the input device under X.
- Execute the command
xinput list
to list your input devices. - Locate
AT Translated Set 2 keyboard
and take note of itsid
number; this will be used to disable the keyboard. Also, take note of the number at the end,[slave keyboard (#)]
; this is the id number of themaster
, which will be used to re-enable your keyboard. - To disable the keyboard, execute the command
xinput float <id#>
, where<id#>
is your keyboard's id number. For example, if theid
was10
, then the command would bexinput float 10
. - To re-enable the keyboard, execute the command
xinput reattach <id#> <master#>
, wheremaster
is that second number we noted down. So if the number was3
, you would doxinput reattach 10 3
.
Here's a demonstration:
$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=11 [slave pointer (2)]
⎜ ↳ Logitech USB-PS/2 Optical Mouse id=12 [slave pointer (2)]
⎜ ↳ Logitech Unifying Device. Wireless PID:4004 id=13 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Sleep Button id=8 [slave keyboard (3)]
↳ Acer CrystalEye webcam id=9 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=10 [slave keyboard (3)]
$ xinput float 10
$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=11 [slave pointer (2)]
⎜ ↳ Logitech USB-PS/2 Optical Mouse id=12 [slave pointer (2)]
⎜ ↳ Logitech Unifying Device. Wireless PID:4004 id=13 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Sleep Button id=8 [slave keyboard (3)]
↳ Acer CrystalEye webcam id=9 [slave keyboard (3)]
∼ AT Translated Set 2 keyboard id=10 [floating slave]
$ xinput reattach 10 3
$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=11 [slave pointer (2)]
⎜ ↳ Logitech USB-PS/2 Optical Mouse id=12 [slave pointer (2)]
⎜ ↳ Logitech Unifying Device. Wireless PID:4004 id=13 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Sleep Button id=8 [slave keyboard (3)]
↳ Acer CrystalEye webcam id=9 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=10 [slave keyboard (3)]
I am interested by this solution! my xinput pastebin.com/puDxQaZ8 so I guess that would be it:xinput float 14
This query is reversible? how to enable keyboard after this?
– atmon3r
Aug 21 '12 at 22:23
2
You would use thereattach
argument to reattach it.xinput reattach 14 3
– Ignacio Vazquez-Abrams
Aug 21 '12 at 22:25
Perfect! this is exactly what I needed, you get my bounty =)
– atmon3r
Aug 22 '12 at 20:31
1
Perfect answer - was looking for this too. any of the keys on my laptop stopped working so now keep an external keyboard over it and it kept pressing the control key and what not. This fixed it up, thanks!
– asymptotically
Dec 15 '12 at 22:08
2
Wouldn't xinput disable/enable do the same thing?
– SomeNickName
Apr 20 '16 at 23:49
|
show 3 more comments
Here is a little switch button to enable and disable a specific keyboard.
First, you have to find your keyboard id with xinput
or xinput-list
.
Bash script to enable/disable keyboard
#!/bin/bash
Icon="/PATH/TO/ICON_ON"
Icoff="/PATH_TO_ICON_OFF"
fconfig=".keyboard"
id=12
if [ ! -f $fconfig ];
then
echo "Creating config file"
echo "enabled" > $fconfig
var="enabled"
else
read -r var< $fconfig
echo "keyboard is : $var"
fi
if [ $var = "disabled" ];
then
notify-send -i $Icon "Enabling keyboard..." "ON - Keyboard connected !";
echo "enable keyboard..."
xinput enable $id
echo "enabled" > $fconfig
elif [ $var = "enabled" ]; then
notify-send -i $Icoff "Disabling Keyboard" "OFF - Keyboard disconnected";
echo "disable keyboard"
xinput disable $id
echo 'disabled' > $fconfig
fi
Configuration
Icon
as the path of icon to display when enabling (for instance,/home/user/path/icon.png
)
Icoff
as the path of the icon to display when disablingI used the following icons :
id
as the keyboard id (found it withxinput
)
fconfig
path to config file. Change if you want to create configuration file in another directory
Don't try to run the script if you can't run it again without the use of your keyboard (unless you got another keyboard of course). Create the following launcher (in home/user/.local/share/applications
) and add it to unity :
Desktop entry (Unity launcher)
[Desktop Entry]
Version=1.0
Type=Application
Name=Clavier ON-OFF
Icon=PATH/TO/YOUR/ICON
Exec=bash NAME_OF_YOUR_SCRIPT.sh
Path=PATH/TO/YOUR/SCRIPT
NoDisplay=false
Categories=Utility;
StartupNotify=false
Terminal=false
RESULT :
Launcher:
Notifications:
This works well, thank you for explaining it clearly. There is one thing that I don't understand: how to make the icon change according to the shell script logic. I think this determined in part by "Icon=PATH/TO/YOUR/ICON" in the Desktop entry, I have used an absolute path, "/home/.../icon_on.png" as I don't know how else to use a ".desktop" file though I can see that this may prevent it switching icons. Could anyone provide a clue please?
– Puffin
Dec 12 '16 at 20:03
1
Hi, you're right about the absolute path in the .desktop file. Sorry but I don't know how to make dynamic changes for a launcher icon. According to that answer, is not possible at all : askubuntu.com/a/244951/458410. The icon in my script changes in notifications only.
– mxdsp
Dec 20 '16 at 10:00
Ah ha, ok that makes sense, mine does the same, thank you.
– Puffin
Dec 20 '16 at 18:47
A possible improvement: instead of storing state in a file you can check directly if the keyboard is disabled with this command:function is-disabled() { xinput --list --long | grep -A 1 "id=$1" | grep -q disabled }
. That way everything works even if the keyboard is enabled/disabled by another program.
– dshepherd
Feb 26 '17 at 11:21
fconfig=".keyboard" if [ ! -f $fconfig ];
Here, what is.keyboard
? And the both thefconfig
and$fconfig
are same? And also what does! -f $fconfig
means? I'm new in bash scripting. Thanks :)
– sphoenix
Sep 16 '17 at 18:01
|
show 2 more comments
I thought of 2 ways you can do this:
By setting up a wrong model for your laptop keyboard in xorg.conf ?
By installing Lock-keyboard-for-Baby
`Lock-keyboard-for-Baby or lk4b in short, is a small program which locks your keyboard but leaves your mouse free. I wrote it because my niece likes to bash away at my keyboard whenever she sees me sit down at it. Keys typed on a keyboard can have disastrous consequences and I didn't want to lock my screen all the time with a screensaver.
When started, lock-keyboard-for-baby opens a small window which grabs the keyboard and echos keys which are typed. By default, it tells you what to type to quit ("Quit Now").
Unlike a screensaver, your screen is not blocked and the mouse still partially works, so you can still see what is on your screen - keep watching tv / video and/or read a document using the mouse to scroll.`
Requirements:
· GTK >= 2.x
· perl GTK2 bindings (perl-gtk2 or gtk2-perl depending on your system)
1
this is not exactly what I need, I need to use my usb keyboard, but your code is very useful! ;)
– atmon3r
Aug 21 '12 at 22:28
Lock-keyboard-for-Baby will let you disable your internal keyboard while mainting the use of the external
– LnxSlck
Aug 22 '12 at 0:49
Brilliant. Lock-Keyboard-For-Baby works in Ubuntu 16.04 as well. I prefer to code using pen and paperbook keeping it on keyboard. This tiny utility solved my problem. For others, you might have to run sudo apt-get install libgtk2-perl before running the perl script
– mac
Feb 1 '17 at 8:05
"Quit Now", Quit Now or quit now no worky under 18.04 with desktop tower USB keyboard.
– fleamour
Aug 9 '18 at 19:10
add a comment |
One sure way to disable it is to unplug the signal cable. You need to pop up the keyboard for that. For information on how to do that, check out the Maintenance and Service Guide for the HP Pavilion dv9000 and dv9200 Notebook PC .
Now there is a way to disable the keyboard using xinput
. T do that, just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the commands below.
To list the devices your X
xinput --list
To disable the keyboard:
xinput set-int-prop 2 "Device Enabled" 8 0
To enable the keyboard again:
xinput set-int-prop 2 "Device Enabled" 8 1
If you get a error about permissions, use the commands above with sudo
.
add a comment |
For Disabling Laptop's internal keyboard permanently On Ubuntu, Need pass this i8042.nokbd
Kernel parameters for not to check/create keyboard port
i8042.nokbd [HW] Don't check/create keyboard port
Open terminal and run the following command
$sudo gedit /etc/default/grub
Try to find the following line
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
Add parameter i8042.nokbd
, the above line should be looks like this
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash i8042.nokbd"
Update grub as following command
$sudo update-grub
Then reboot
your laptop computer.
add a comment |
Device id
's received from xinput list
as suggested in accepted answer are sometimes somehow changed on reboot (at least on my PC) which resulted in disabling wrong device.
That's why I've ended using device name
instead of id
, e.g.:
xinput disable "AT Translated Set 2 keyboard"
add a comment |
For example to temporarly disable de keyboard for clean up:
$ xinput float id#;sleep t;xinput reattach id# master#
t -time to sleep in seconds
id# and master# as mentioned above (top of all),for example on my notebook:
$ xinput float 11;sleep 5 ;xinput reattach 11 3
I just added this because I like to clean the keyboard all the time. I have to reboot, so I discover this!
add a comment |
Try running xmodmap -e 'keycode 24='
to disable just the Q key. If that works, you could add it it to your ~/.bashrc
or global /etc/bash.bashrc
file. I got this idea from here, which shows all the key-mappings.
4
Wouldn't this disableq
in the external keyboard as well?
– Sparhawk
Aug 30 '13 at 5:07
add a comment |
For what it's worth, based on previous answers and my own playing around, I created the following script, which I call toggle_keyboard.sh
and place in my ~/bin
path. I have a keyboard shortcut that runs it set to CtrlWinK.
Some problems with the previous answers and benefit of my script:
- Relying on an id number with xinput fails when you reboot and the id number is changed. This happened to me when running
xinput float 13
. I ended up disabling the wrong hardware. - Relying on a file to hold the enabled/disabled state will fail if you reboot as well. The file will tell you the keyboard is disabled (if you disabled it with the script), but after a reboot it will be enabled again. My solution gets the enabled/disabled information from a parsed xinput command.
- My script will work with any xinput device that shows up when you type
xinput list --name-only
. Just get the name and edit the top four variables. I use it for my laptop keyboard, webcam, touchscreen monitor and a few other things I use only once in a while.
#!/bin/bash
# Toggle the laptop keyboard either on or off and notify the user about it
# Device name can be found by typing this command: xinput list --name-only
DEVICE_NAME="AT Translated Set 2 keyboard"
# The display name of the device in the notify-send popup
DEVICE_DISPLAY_NAME="Laptop Keyboard"
# Set these to the icons you want to use.
# If they are not found, the notification will still work.
ICON_ENABLE="$HOME/.icons/keyboard.png"
ICON_DISABLE="$HOME/.icons/keyboard_disabled.png"
function xinput_set_prop() {
xinput set-prop "$DEVICE_NAME" "Device Enabled" $1
}
function notify_change() {
if [ -f "$1" ]; then
notify-send --urgency=low --icon="$1" "$2"
else
notify-send --urgency=low "$2"
fi
}
# Returns 1 if device is enabled, 0 if disabled
is_enabled=$(xinput list-props "$DEVICE_NAME" | grep "Device Enabled" | awk '{ print $4 }' | sed 's/[^0-9]*//g')
if [ $is_enabled -eq 1 ]; then
# device is enabled, so disable it
xinput_set_prop 0
notify_change "$ICON_DISABLE" "$DEVICE_DISPLAY_NAME Disabled"
else
# device is disabled, so enable it
xinput_set_prop 1
notify_change "$ICON_ENABLE" "$DEVICE_DISPLAY_NAME Enabled"
fi
add a comment |
xinput float "AT Translated Set 2 keyboard"
After spending hours over years with different methods with different distros and releases. The above terminal command is what I rely on after problems..... I use this now with neon plasma and was using it a month ago in straight ubuntu 18.04.
(needs applying after restart - can be placed in startup)
New contributor
add a comment |
I had a problem with a stuck key, there is a command somewhere that you can put into terminal and it will automatically disable it every time on startup, I am no programmer and I can't remember i (I just copy and paste into terminal, I have no clue how you guys know this stuff, or how you all can come up with different versions lol), had it on mint 17, but I also know there is one you can even put in so it disables it even before you login, although I never did that as it is more involved
But what I have done, is go into settings, keyboard ( on mint 18 xfce you click back where the start menu used to be and go to system then keyboard) and you can disable repeat keys, it's just a box you uncheck you'll see it, you'll still have to use your usb keyboard as if you use the other it will retype the offending letter every other key, but it does the job perfectly
By the way thank you all for helping me with computers over the years whoever you guys are, you rock, had win 8 and my computer like ev eryone elses who had a notebook touchscreen just couldn't handle it, and through your discussions on here I have kept going, you are heroes :)
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f160945%2fis-there-a-way-to-disable-a-laptops-internal-keyboard%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
11 Answers
11
active
oldest
votes
11 Answers
11
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use xinput
to float the input device under X.
- Execute the command
xinput list
to list your input devices. - Locate
AT Translated Set 2 keyboard
and take note of itsid
number; this will be used to disable the keyboard. Also, take note of the number at the end,[slave keyboard (#)]
; this is the id number of themaster
, which will be used to re-enable your keyboard. - To disable the keyboard, execute the command
xinput float <id#>
, where<id#>
is your keyboard's id number. For example, if theid
was10
, then the command would bexinput float 10
. - To re-enable the keyboard, execute the command
xinput reattach <id#> <master#>
, wheremaster
is that second number we noted down. So if the number was3
, you would doxinput reattach 10 3
.
Here's a demonstration:
$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=11 [slave pointer (2)]
⎜ ↳ Logitech USB-PS/2 Optical Mouse id=12 [slave pointer (2)]
⎜ ↳ Logitech Unifying Device. Wireless PID:4004 id=13 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Sleep Button id=8 [slave keyboard (3)]
↳ Acer CrystalEye webcam id=9 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=10 [slave keyboard (3)]
$ xinput float 10
$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=11 [slave pointer (2)]
⎜ ↳ Logitech USB-PS/2 Optical Mouse id=12 [slave pointer (2)]
⎜ ↳ Logitech Unifying Device. Wireless PID:4004 id=13 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Sleep Button id=8 [slave keyboard (3)]
↳ Acer CrystalEye webcam id=9 [slave keyboard (3)]
∼ AT Translated Set 2 keyboard id=10 [floating slave]
$ xinput reattach 10 3
$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=11 [slave pointer (2)]
⎜ ↳ Logitech USB-PS/2 Optical Mouse id=12 [slave pointer (2)]
⎜ ↳ Logitech Unifying Device. Wireless PID:4004 id=13 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Sleep Button id=8 [slave keyboard (3)]
↳ Acer CrystalEye webcam id=9 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=10 [slave keyboard (3)]
I am interested by this solution! my xinput pastebin.com/puDxQaZ8 so I guess that would be it:xinput float 14
This query is reversible? how to enable keyboard after this?
– atmon3r
Aug 21 '12 at 22:23
2
You would use thereattach
argument to reattach it.xinput reattach 14 3
– Ignacio Vazquez-Abrams
Aug 21 '12 at 22:25
Perfect! this is exactly what I needed, you get my bounty =)
– atmon3r
Aug 22 '12 at 20:31
1
Perfect answer - was looking for this too. any of the keys on my laptop stopped working so now keep an external keyboard over it and it kept pressing the control key and what not. This fixed it up, thanks!
– asymptotically
Dec 15 '12 at 22:08
2
Wouldn't xinput disable/enable do the same thing?
– SomeNickName
Apr 20 '16 at 23:49
|
show 3 more comments
You can use xinput
to float the input device under X.
- Execute the command
xinput list
to list your input devices. - Locate
AT Translated Set 2 keyboard
and take note of itsid
number; this will be used to disable the keyboard. Also, take note of the number at the end,[slave keyboard (#)]
; this is the id number of themaster
, which will be used to re-enable your keyboard. - To disable the keyboard, execute the command
xinput float <id#>
, where<id#>
is your keyboard's id number. For example, if theid
was10
, then the command would bexinput float 10
. - To re-enable the keyboard, execute the command
xinput reattach <id#> <master#>
, wheremaster
is that second number we noted down. So if the number was3
, you would doxinput reattach 10 3
.
Here's a demonstration:
$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=11 [slave pointer (2)]
⎜ ↳ Logitech USB-PS/2 Optical Mouse id=12 [slave pointer (2)]
⎜ ↳ Logitech Unifying Device. Wireless PID:4004 id=13 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Sleep Button id=8 [slave keyboard (3)]
↳ Acer CrystalEye webcam id=9 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=10 [slave keyboard (3)]
$ xinput float 10
$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=11 [slave pointer (2)]
⎜ ↳ Logitech USB-PS/2 Optical Mouse id=12 [slave pointer (2)]
⎜ ↳ Logitech Unifying Device. Wireless PID:4004 id=13 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Sleep Button id=8 [slave keyboard (3)]
↳ Acer CrystalEye webcam id=9 [slave keyboard (3)]
∼ AT Translated Set 2 keyboard id=10 [floating slave]
$ xinput reattach 10 3
$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=11 [slave pointer (2)]
⎜ ↳ Logitech USB-PS/2 Optical Mouse id=12 [slave pointer (2)]
⎜ ↳ Logitech Unifying Device. Wireless PID:4004 id=13 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Sleep Button id=8 [slave keyboard (3)]
↳ Acer CrystalEye webcam id=9 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=10 [slave keyboard (3)]
I am interested by this solution! my xinput pastebin.com/puDxQaZ8 so I guess that would be it:xinput float 14
This query is reversible? how to enable keyboard after this?
– atmon3r
Aug 21 '12 at 22:23
2
You would use thereattach
argument to reattach it.xinput reattach 14 3
– Ignacio Vazquez-Abrams
Aug 21 '12 at 22:25
Perfect! this is exactly what I needed, you get my bounty =)
– atmon3r
Aug 22 '12 at 20:31
1
Perfect answer - was looking for this too. any of the keys on my laptop stopped working so now keep an external keyboard over it and it kept pressing the control key and what not. This fixed it up, thanks!
– asymptotically
Dec 15 '12 at 22:08
2
Wouldn't xinput disable/enable do the same thing?
– SomeNickName
Apr 20 '16 at 23:49
|
show 3 more comments
You can use xinput
to float the input device under X.
- Execute the command
xinput list
to list your input devices. - Locate
AT Translated Set 2 keyboard
and take note of itsid
number; this will be used to disable the keyboard. Also, take note of the number at the end,[slave keyboard (#)]
; this is the id number of themaster
, which will be used to re-enable your keyboard. - To disable the keyboard, execute the command
xinput float <id#>
, where<id#>
is your keyboard's id number. For example, if theid
was10
, then the command would bexinput float 10
. - To re-enable the keyboard, execute the command
xinput reattach <id#> <master#>
, wheremaster
is that second number we noted down. So if the number was3
, you would doxinput reattach 10 3
.
Here's a demonstration:
$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=11 [slave pointer (2)]
⎜ ↳ Logitech USB-PS/2 Optical Mouse id=12 [slave pointer (2)]
⎜ ↳ Logitech Unifying Device. Wireless PID:4004 id=13 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Sleep Button id=8 [slave keyboard (3)]
↳ Acer CrystalEye webcam id=9 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=10 [slave keyboard (3)]
$ xinput float 10
$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=11 [slave pointer (2)]
⎜ ↳ Logitech USB-PS/2 Optical Mouse id=12 [slave pointer (2)]
⎜ ↳ Logitech Unifying Device. Wireless PID:4004 id=13 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Sleep Button id=8 [slave keyboard (3)]
↳ Acer CrystalEye webcam id=9 [slave keyboard (3)]
∼ AT Translated Set 2 keyboard id=10 [floating slave]
$ xinput reattach 10 3
$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=11 [slave pointer (2)]
⎜ ↳ Logitech USB-PS/2 Optical Mouse id=12 [slave pointer (2)]
⎜ ↳ Logitech Unifying Device. Wireless PID:4004 id=13 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Sleep Button id=8 [slave keyboard (3)]
↳ Acer CrystalEye webcam id=9 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=10 [slave keyboard (3)]
You can use xinput
to float the input device under X.
- Execute the command
xinput list
to list your input devices. - Locate
AT Translated Set 2 keyboard
and take note of itsid
number; this will be used to disable the keyboard. Also, take note of the number at the end,[slave keyboard (#)]
; this is the id number of themaster
, which will be used to re-enable your keyboard. - To disable the keyboard, execute the command
xinput float <id#>
, where<id#>
is your keyboard's id number. For example, if theid
was10
, then the command would bexinput float 10
. - To re-enable the keyboard, execute the command
xinput reattach <id#> <master#>
, wheremaster
is that second number we noted down. So if the number was3
, you would doxinput reattach 10 3
.
Here's a demonstration:
$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=11 [slave pointer (2)]
⎜ ↳ Logitech USB-PS/2 Optical Mouse id=12 [slave pointer (2)]
⎜ ↳ Logitech Unifying Device. Wireless PID:4004 id=13 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Sleep Button id=8 [slave keyboard (3)]
↳ Acer CrystalEye webcam id=9 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=10 [slave keyboard (3)]
$ xinput float 10
$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=11 [slave pointer (2)]
⎜ ↳ Logitech USB-PS/2 Optical Mouse id=12 [slave pointer (2)]
⎜ ↳ Logitech Unifying Device. Wireless PID:4004 id=13 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Sleep Button id=8 [slave keyboard (3)]
↳ Acer CrystalEye webcam id=9 [slave keyboard (3)]
∼ AT Translated Set 2 keyboard id=10 [floating slave]
$ xinput reattach 10 3
$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=11 [slave pointer (2)]
⎜ ↳ Logitech USB-PS/2 Optical Mouse id=12 [slave pointer (2)]
⎜ ↳ Logitech Unifying Device. Wireless PID:4004 id=13 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Sleep Button id=8 [slave keyboard (3)]
↳ Acer CrystalEye webcam id=9 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=10 [slave keyboard (3)]
edited Aug 30 '13 at 5:32
Alaa Ali
22.1k96894
22.1k96894
answered Aug 21 '12 at 21:53
Ignacio Vazquez-AbramsIgnacio Vazquez-Abrams
2,90611115
2,90611115
I am interested by this solution! my xinput pastebin.com/puDxQaZ8 so I guess that would be it:xinput float 14
This query is reversible? how to enable keyboard after this?
– atmon3r
Aug 21 '12 at 22:23
2
You would use thereattach
argument to reattach it.xinput reattach 14 3
– Ignacio Vazquez-Abrams
Aug 21 '12 at 22:25
Perfect! this is exactly what I needed, you get my bounty =)
– atmon3r
Aug 22 '12 at 20:31
1
Perfect answer - was looking for this too. any of the keys on my laptop stopped working so now keep an external keyboard over it and it kept pressing the control key and what not. This fixed it up, thanks!
– asymptotically
Dec 15 '12 at 22:08
2
Wouldn't xinput disable/enable do the same thing?
– SomeNickName
Apr 20 '16 at 23:49
|
show 3 more comments
I am interested by this solution! my xinput pastebin.com/puDxQaZ8 so I guess that would be it:xinput float 14
This query is reversible? how to enable keyboard after this?
– atmon3r
Aug 21 '12 at 22:23
2
You would use thereattach
argument to reattach it.xinput reattach 14 3
– Ignacio Vazquez-Abrams
Aug 21 '12 at 22:25
Perfect! this is exactly what I needed, you get my bounty =)
– atmon3r
Aug 22 '12 at 20:31
1
Perfect answer - was looking for this too. any of the keys on my laptop stopped working so now keep an external keyboard over it and it kept pressing the control key and what not. This fixed it up, thanks!
– asymptotically
Dec 15 '12 at 22:08
2
Wouldn't xinput disable/enable do the same thing?
– SomeNickName
Apr 20 '16 at 23:49
I am interested by this solution! my xinput pastebin.com/puDxQaZ8 so I guess that would be it:
xinput float 14
This query is reversible? how to enable keyboard after this?– atmon3r
Aug 21 '12 at 22:23
I am interested by this solution! my xinput pastebin.com/puDxQaZ8 so I guess that would be it:
xinput float 14
This query is reversible? how to enable keyboard after this?– atmon3r
Aug 21 '12 at 22:23
2
2
You would use the
reattach
argument to reattach it. xinput reattach 14 3
– Ignacio Vazquez-Abrams
Aug 21 '12 at 22:25
You would use the
reattach
argument to reattach it. xinput reattach 14 3
– Ignacio Vazquez-Abrams
Aug 21 '12 at 22:25
Perfect! this is exactly what I needed, you get my bounty =)
– atmon3r
Aug 22 '12 at 20:31
Perfect! this is exactly what I needed, you get my bounty =)
– atmon3r
Aug 22 '12 at 20:31
1
1
Perfect answer - was looking for this too. any of the keys on my laptop stopped working so now keep an external keyboard over it and it kept pressing the control key and what not. This fixed it up, thanks!
– asymptotically
Dec 15 '12 at 22:08
Perfect answer - was looking for this too. any of the keys on my laptop stopped working so now keep an external keyboard over it and it kept pressing the control key and what not. This fixed it up, thanks!
– asymptotically
Dec 15 '12 at 22:08
2
2
Wouldn't xinput disable/enable do the same thing?
– SomeNickName
Apr 20 '16 at 23:49
Wouldn't xinput disable/enable do the same thing?
– SomeNickName
Apr 20 '16 at 23:49
|
show 3 more comments
Here is a little switch button to enable and disable a specific keyboard.
First, you have to find your keyboard id with xinput
or xinput-list
.
Bash script to enable/disable keyboard
#!/bin/bash
Icon="/PATH/TO/ICON_ON"
Icoff="/PATH_TO_ICON_OFF"
fconfig=".keyboard"
id=12
if [ ! -f $fconfig ];
then
echo "Creating config file"
echo "enabled" > $fconfig
var="enabled"
else
read -r var< $fconfig
echo "keyboard is : $var"
fi
if [ $var = "disabled" ];
then
notify-send -i $Icon "Enabling keyboard..." "ON - Keyboard connected !";
echo "enable keyboard..."
xinput enable $id
echo "enabled" > $fconfig
elif [ $var = "enabled" ]; then
notify-send -i $Icoff "Disabling Keyboard" "OFF - Keyboard disconnected";
echo "disable keyboard"
xinput disable $id
echo 'disabled' > $fconfig
fi
Configuration
Icon
as the path of icon to display when enabling (for instance,/home/user/path/icon.png
)
Icoff
as the path of the icon to display when disablingI used the following icons :
id
as the keyboard id (found it withxinput
)
fconfig
path to config file. Change if you want to create configuration file in another directory
Don't try to run the script if you can't run it again without the use of your keyboard (unless you got another keyboard of course). Create the following launcher (in home/user/.local/share/applications
) and add it to unity :
Desktop entry (Unity launcher)
[Desktop Entry]
Version=1.0
Type=Application
Name=Clavier ON-OFF
Icon=PATH/TO/YOUR/ICON
Exec=bash NAME_OF_YOUR_SCRIPT.sh
Path=PATH/TO/YOUR/SCRIPT
NoDisplay=false
Categories=Utility;
StartupNotify=false
Terminal=false
RESULT :
Launcher:
Notifications:
This works well, thank you for explaining it clearly. There is one thing that I don't understand: how to make the icon change according to the shell script logic. I think this determined in part by "Icon=PATH/TO/YOUR/ICON" in the Desktop entry, I have used an absolute path, "/home/.../icon_on.png" as I don't know how else to use a ".desktop" file though I can see that this may prevent it switching icons. Could anyone provide a clue please?
– Puffin
Dec 12 '16 at 20:03
1
Hi, you're right about the absolute path in the .desktop file. Sorry but I don't know how to make dynamic changes for a launcher icon. According to that answer, is not possible at all : askubuntu.com/a/244951/458410. The icon in my script changes in notifications only.
– mxdsp
Dec 20 '16 at 10:00
Ah ha, ok that makes sense, mine does the same, thank you.
– Puffin
Dec 20 '16 at 18:47
A possible improvement: instead of storing state in a file you can check directly if the keyboard is disabled with this command:function is-disabled() { xinput --list --long | grep -A 1 "id=$1" | grep -q disabled }
. That way everything works even if the keyboard is enabled/disabled by another program.
– dshepherd
Feb 26 '17 at 11:21
fconfig=".keyboard" if [ ! -f $fconfig ];
Here, what is.keyboard
? And the both thefconfig
and$fconfig
are same? And also what does! -f $fconfig
means? I'm new in bash scripting. Thanks :)
– sphoenix
Sep 16 '17 at 18:01
|
show 2 more comments
Here is a little switch button to enable and disable a specific keyboard.
First, you have to find your keyboard id with xinput
or xinput-list
.
Bash script to enable/disable keyboard
#!/bin/bash
Icon="/PATH/TO/ICON_ON"
Icoff="/PATH_TO_ICON_OFF"
fconfig=".keyboard"
id=12
if [ ! -f $fconfig ];
then
echo "Creating config file"
echo "enabled" > $fconfig
var="enabled"
else
read -r var< $fconfig
echo "keyboard is : $var"
fi
if [ $var = "disabled" ];
then
notify-send -i $Icon "Enabling keyboard..." "ON - Keyboard connected !";
echo "enable keyboard..."
xinput enable $id
echo "enabled" > $fconfig
elif [ $var = "enabled" ]; then
notify-send -i $Icoff "Disabling Keyboard" "OFF - Keyboard disconnected";
echo "disable keyboard"
xinput disable $id
echo 'disabled' > $fconfig
fi
Configuration
Icon
as the path of icon to display when enabling (for instance,/home/user/path/icon.png
)
Icoff
as the path of the icon to display when disablingI used the following icons :
id
as the keyboard id (found it withxinput
)
fconfig
path to config file. Change if you want to create configuration file in another directory
Don't try to run the script if you can't run it again without the use of your keyboard (unless you got another keyboard of course). Create the following launcher (in home/user/.local/share/applications
) and add it to unity :
Desktop entry (Unity launcher)
[Desktop Entry]
Version=1.0
Type=Application
Name=Clavier ON-OFF
Icon=PATH/TO/YOUR/ICON
Exec=bash NAME_OF_YOUR_SCRIPT.sh
Path=PATH/TO/YOUR/SCRIPT
NoDisplay=false
Categories=Utility;
StartupNotify=false
Terminal=false
RESULT :
Launcher:
Notifications:
This works well, thank you for explaining it clearly. There is one thing that I don't understand: how to make the icon change according to the shell script logic. I think this determined in part by "Icon=PATH/TO/YOUR/ICON" in the Desktop entry, I have used an absolute path, "/home/.../icon_on.png" as I don't know how else to use a ".desktop" file though I can see that this may prevent it switching icons. Could anyone provide a clue please?
– Puffin
Dec 12 '16 at 20:03
1
Hi, you're right about the absolute path in the .desktop file. Sorry but I don't know how to make dynamic changes for a launcher icon. According to that answer, is not possible at all : askubuntu.com/a/244951/458410. The icon in my script changes in notifications only.
– mxdsp
Dec 20 '16 at 10:00
Ah ha, ok that makes sense, mine does the same, thank you.
– Puffin
Dec 20 '16 at 18:47
A possible improvement: instead of storing state in a file you can check directly if the keyboard is disabled with this command:function is-disabled() { xinput --list --long | grep -A 1 "id=$1" | grep -q disabled }
. That way everything works even if the keyboard is enabled/disabled by another program.
– dshepherd
Feb 26 '17 at 11:21
fconfig=".keyboard" if [ ! -f $fconfig ];
Here, what is.keyboard
? And the both thefconfig
and$fconfig
are same? And also what does! -f $fconfig
means? I'm new in bash scripting. Thanks :)
– sphoenix
Sep 16 '17 at 18:01
|
show 2 more comments
Here is a little switch button to enable and disable a specific keyboard.
First, you have to find your keyboard id with xinput
or xinput-list
.
Bash script to enable/disable keyboard
#!/bin/bash
Icon="/PATH/TO/ICON_ON"
Icoff="/PATH_TO_ICON_OFF"
fconfig=".keyboard"
id=12
if [ ! -f $fconfig ];
then
echo "Creating config file"
echo "enabled" > $fconfig
var="enabled"
else
read -r var< $fconfig
echo "keyboard is : $var"
fi
if [ $var = "disabled" ];
then
notify-send -i $Icon "Enabling keyboard..." "ON - Keyboard connected !";
echo "enable keyboard..."
xinput enable $id
echo "enabled" > $fconfig
elif [ $var = "enabled" ]; then
notify-send -i $Icoff "Disabling Keyboard" "OFF - Keyboard disconnected";
echo "disable keyboard"
xinput disable $id
echo 'disabled' > $fconfig
fi
Configuration
Icon
as the path of icon to display when enabling (for instance,/home/user/path/icon.png
)
Icoff
as the path of the icon to display when disablingI used the following icons :
id
as the keyboard id (found it withxinput
)
fconfig
path to config file. Change if you want to create configuration file in another directory
Don't try to run the script if you can't run it again without the use of your keyboard (unless you got another keyboard of course). Create the following launcher (in home/user/.local/share/applications
) and add it to unity :
Desktop entry (Unity launcher)
[Desktop Entry]
Version=1.0
Type=Application
Name=Clavier ON-OFF
Icon=PATH/TO/YOUR/ICON
Exec=bash NAME_OF_YOUR_SCRIPT.sh
Path=PATH/TO/YOUR/SCRIPT
NoDisplay=false
Categories=Utility;
StartupNotify=false
Terminal=false
RESULT :
Launcher:
Notifications:
Here is a little switch button to enable and disable a specific keyboard.
First, you have to find your keyboard id with xinput
or xinput-list
.
Bash script to enable/disable keyboard
#!/bin/bash
Icon="/PATH/TO/ICON_ON"
Icoff="/PATH_TO_ICON_OFF"
fconfig=".keyboard"
id=12
if [ ! -f $fconfig ];
then
echo "Creating config file"
echo "enabled" > $fconfig
var="enabled"
else
read -r var< $fconfig
echo "keyboard is : $var"
fi
if [ $var = "disabled" ];
then
notify-send -i $Icon "Enabling keyboard..." "ON - Keyboard connected !";
echo "enable keyboard..."
xinput enable $id
echo "enabled" > $fconfig
elif [ $var = "enabled" ]; then
notify-send -i $Icoff "Disabling Keyboard" "OFF - Keyboard disconnected";
echo "disable keyboard"
xinput disable $id
echo 'disabled' > $fconfig
fi
Configuration
Icon
as the path of icon to display when enabling (for instance,/home/user/path/icon.png
)
Icoff
as the path of the icon to display when disablingI used the following icons :
id
as the keyboard id (found it withxinput
)
fconfig
path to config file. Change if you want to create configuration file in another directory
Don't try to run the script if you can't run it again without the use of your keyboard (unless you got another keyboard of course). Create the following launcher (in home/user/.local/share/applications
) and add it to unity :
Desktop entry (Unity launcher)
[Desktop Entry]
Version=1.0
Type=Application
Name=Clavier ON-OFF
Icon=PATH/TO/YOUR/ICON
Exec=bash NAME_OF_YOUR_SCRIPT.sh
Path=PATH/TO/YOUR/SCRIPT
NoDisplay=false
Categories=Utility;
StartupNotify=false
Terminal=false
RESULT :
Launcher:
Notifications:
answered Dec 26 '15 at 12:02
mxdspmxdsp
2,37111846
2,37111846
This works well, thank you for explaining it clearly. There is one thing that I don't understand: how to make the icon change according to the shell script logic. I think this determined in part by "Icon=PATH/TO/YOUR/ICON" in the Desktop entry, I have used an absolute path, "/home/.../icon_on.png" as I don't know how else to use a ".desktop" file though I can see that this may prevent it switching icons. Could anyone provide a clue please?
– Puffin
Dec 12 '16 at 20:03
1
Hi, you're right about the absolute path in the .desktop file. Sorry but I don't know how to make dynamic changes for a launcher icon. According to that answer, is not possible at all : askubuntu.com/a/244951/458410. The icon in my script changes in notifications only.
– mxdsp
Dec 20 '16 at 10:00
Ah ha, ok that makes sense, mine does the same, thank you.
– Puffin
Dec 20 '16 at 18:47
A possible improvement: instead of storing state in a file you can check directly if the keyboard is disabled with this command:function is-disabled() { xinput --list --long | grep -A 1 "id=$1" | grep -q disabled }
. That way everything works even if the keyboard is enabled/disabled by another program.
– dshepherd
Feb 26 '17 at 11:21
fconfig=".keyboard" if [ ! -f $fconfig ];
Here, what is.keyboard
? And the both thefconfig
and$fconfig
are same? And also what does! -f $fconfig
means? I'm new in bash scripting. Thanks :)
– sphoenix
Sep 16 '17 at 18:01
|
show 2 more comments
This works well, thank you for explaining it clearly. There is one thing that I don't understand: how to make the icon change according to the shell script logic. I think this determined in part by "Icon=PATH/TO/YOUR/ICON" in the Desktop entry, I have used an absolute path, "/home/.../icon_on.png" as I don't know how else to use a ".desktop" file though I can see that this may prevent it switching icons. Could anyone provide a clue please?
– Puffin
Dec 12 '16 at 20:03
1
Hi, you're right about the absolute path in the .desktop file. Sorry but I don't know how to make dynamic changes for a launcher icon. According to that answer, is not possible at all : askubuntu.com/a/244951/458410. The icon in my script changes in notifications only.
– mxdsp
Dec 20 '16 at 10:00
Ah ha, ok that makes sense, mine does the same, thank you.
– Puffin
Dec 20 '16 at 18:47
A possible improvement: instead of storing state in a file you can check directly if the keyboard is disabled with this command:function is-disabled() { xinput --list --long | grep -A 1 "id=$1" | grep -q disabled }
. That way everything works even if the keyboard is enabled/disabled by another program.
– dshepherd
Feb 26 '17 at 11:21
fconfig=".keyboard" if [ ! -f $fconfig ];
Here, what is.keyboard
? And the both thefconfig
and$fconfig
are same? And also what does! -f $fconfig
means? I'm new in bash scripting. Thanks :)
– sphoenix
Sep 16 '17 at 18:01
This works well, thank you for explaining it clearly. There is one thing that I don't understand: how to make the icon change according to the shell script logic. I think this determined in part by "Icon=PATH/TO/YOUR/ICON" in the Desktop entry, I have used an absolute path, "/home/.../icon_on.png" as I don't know how else to use a ".desktop" file though I can see that this may prevent it switching icons. Could anyone provide a clue please?
– Puffin
Dec 12 '16 at 20:03
This works well, thank you for explaining it clearly. There is one thing that I don't understand: how to make the icon change according to the shell script logic. I think this determined in part by "Icon=PATH/TO/YOUR/ICON" in the Desktop entry, I have used an absolute path, "/home/.../icon_on.png" as I don't know how else to use a ".desktop" file though I can see that this may prevent it switching icons. Could anyone provide a clue please?
– Puffin
Dec 12 '16 at 20:03
1
1
Hi, you're right about the absolute path in the .desktop file. Sorry but I don't know how to make dynamic changes for a launcher icon. According to that answer, is not possible at all : askubuntu.com/a/244951/458410. The icon in my script changes in notifications only.
– mxdsp
Dec 20 '16 at 10:00
Hi, you're right about the absolute path in the .desktop file. Sorry but I don't know how to make dynamic changes for a launcher icon. According to that answer, is not possible at all : askubuntu.com/a/244951/458410. The icon in my script changes in notifications only.
– mxdsp
Dec 20 '16 at 10:00
Ah ha, ok that makes sense, mine does the same, thank you.
– Puffin
Dec 20 '16 at 18:47
Ah ha, ok that makes sense, mine does the same, thank you.
– Puffin
Dec 20 '16 at 18:47
A possible improvement: instead of storing state in a file you can check directly if the keyboard is disabled with this command:
function is-disabled() { xinput --list --long | grep -A 1 "id=$1" | grep -q disabled }
. That way everything works even if the keyboard is enabled/disabled by another program.– dshepherd
Feb 26 '17 at 11:21
A possible improvement: instead of storing state in a file you can check directly if the keyboard is disabled with this command:
function is-disabled() { xinput --list --long | grep -A 1 "id=$1" | grep -q disabled }
. That way everything works even if the keyboard is enabled/disabled by another program.– dshepherd
Feb 26 '17 at 11:21
fconfig=".keyboard" if [ ! -f $fconfig ];
Here, what is .keyboard
? And the both the fconfig
and $fconfig
are same? And also what does ! -f $fconfig
means? I'm new in bash scripting. Thanks :)– sphoenix
Sep 16 '17 at 18:01
fconfig=".keyboard" if [ ! -f $fconfig ];
Here, what is .keyboard
? And the both the fconfig
and $fconfig
are same? And also what does ! -f $fconfig
means? I'm new in bash scripting. Thanks :)– sphoenix
Sep 16 '17 at 18:01
|
show 2 more comments
I thought of 2 ways you can do this:
By setting up a wrong model for your laptop keyboard in xorg.conf ?
By installing Lock-keyboard-for-Baby
`Lock-keyboard-for-Baby or lk4b in short, is a small program which locks your keyboard but leaves your mouse free. I wrote it because my niece likes to bash away at my keyboard whenever she sees me sit down at it. Keys typed on a keyboard can have disastrous consequences and I didn't want to lock my screen all the time with a screensaver.
When started, lock-keyboard-for-baby opens a small window which grabs the keyboard and echos keys which are typed. By default, it tells you what to type to quit ("Quit Now").
Unlike a screensaver, your screen is not blocked and the mouse still partially works, so you can still see what is on your screen - keep watching tv / video and/or read a document using the mouse to scroll.`
Requirements:
· GTK >= 2.x
· perl GTK2 bindings (perl-gtk2 or gtk2-perl depending on your system)
1
this is not exactly what I need, I need to use my usb keyboard, but your code is very useful! ;)
– atmon3r
Aug 21 '12 at 22:28
Lock-keyboard-for-Baby will let you disable your internal keyboard while mainting the use of the external
– LnxSlck
Aug 22 '12 at 0:49
Brilliant. Lock-Keyboard-For-Baby works in Ubuntu 16.04 as well. I prefer to code using pen and paperbook keeping it on keyboard. This tiny utility solved my problem. For others, you might have to run sudo apt-get install libgtk2-perl before running the perl script
– mac
Feb 1 '17 at 8:05
"Quit Now", Quit Now or quit now no worky under 18.04 with desktop tower USB keyboard.
– fleamour
Aug 9 '18 at 19:10
add a comment |
I thought of 2 ways you can do this:
By setting up a wrong model for your laptop keyboard in xorg.conf ?
By installing Lock-keyboard-for-Baby
`Lock-keyboard-for-Baby or lk4b in short, is a small program which locks your keyboard but leaves your mouse free. I wrote it because my niece likes to bash away at my keyboard whenever she sees me sit down at it. Keys typed on a keyboard can have disastrous consequences and I didn't want to lock my screen all the time with a screensaver.
When started, lock-keyboard-for-baby opens a small window which grabs the keyboard and echos keys which are typed. By default, it tells you what to type to quit ("Quit Now").
Unlike a screensaver, your screen is not blocked and the mouse still partially works, so you can still see what is on your screen - keep watching tv / video and/or read a document using the mouse to scroll.`
Requirements:
· GTK >= 2.x
· perl GTK2 bindings (perl-gtk2 or gtk2-perl depending on your system)
1
this is not exactly what I need, I need to use my usb keyboard, but your code is very useful! ;)
– atmon3r
Aug 21 '12 at 22:28
Lock-keyboard-for-Baby will let you disable your internal keyboard while mainting the use of the external
– LnxSlck
Aug 22 '12 at 0:49
Brilliant. Lock-Keyboard-For-Baby works in Ubuntu 16.04 as well. I prefer to code using pen and paperbook keeping it on keyboard. This tiny utility solved my problem. For others, you might have to run sudo apt-get install libgtk2-perl before running the perl script
– mac
Feb 1 '17 at 8:05
"Quit Now", Quit Now or quit now no worky under 18.04 with desktop tower USB keyboard.
– fleamour
Aug 9 '18 at 19:10
add a comment |
I thought of 2 ways you can do this:
By setting up a wrong model for your laptop keyboard in xorg.conf ?
By installing Lock-keyboard-for-Baby
`Lock-keyboard-for-Baby or lk4b in short, is a small program which locks your keyboard but leaves your mouse free. I wrote it because my niece likes to bash away at my keyboard whenever she sees me sit down at it. Keys typed on a keyboard can have disastrous consequences and I didn't want to lock my screen all the time with a screensaver.
When started, lock-keyboard-for-baby opens a small window which grabs the keyboard and echos keys which are typed. By default, it tells you what to type to quit ("Quit Now").
Unlike a screensaver, your screen is not blocked and the mouse still partially works, so you can still see what is on your screen - keep watching tv / video and/or read a document using the mouse to scroll.`
Requirements:
· GTK >= 2.x
· perl GTK2 bindings (perl-gtk2 or gtk2-perl depending on your system)
I thought of 2 ways you can do this:
By setting up a wrong model for your laptop keyboard in xorg.conf ?
By installing Lock-keyboard-for-Baby
`Lock-keyboard-for-Baby or lk4b in short, is a small program which locks your keyboard but leaves your mouse free. I wrote it because my niece likes to bash away at my keyboard whenever she sees me sit down at it. Keys typed on a keyboard can have disastrous consequences and I didn't want to lock my screen all the time with a screensaver.
When started, lock-keyboard-for-baby opens a small window which grabs the keyboard and echos keys which are typed. By default, it tells you what to type to quit ("Quit Now").
Unlike a screensaver, your screen is not blocked and the mouse still partially works, so you can still see what is on your screen - keep watching tv / video and/or read a document using the mouse to scroll.`
Requirements:
· GTK >= 2.x
· perl GTK2 bindings (perl-gtk2 or gtk2-perl depending on your system)
answered Aug 21 '12 at 21:46
LnxSlckLnxSlck
10.2k12949
10.2k12949
1
this is not exactly what I need, I need to use my usb keyboard, but your code is very useful! ;)
– atmon3r
Aug 21 '12 at 22:28
Lock-keyboard-for-Baby will let you disable your internal keyboard while mainting the use of the external
– LnxSlck
Aug 22 '12 at 0:49
Brilliant. Lock-Keyboard-For-Baby works in Ubuntu 16.04 as well. I prefer to code using pen and paperbook keeping it on keyboard. This tiny utility solved my problem. For others, you might have to run sudo apt-get install libgtk2-perl before running the perl script
– mac
Feb 1 '17 at 8:05
"Quit Now", Quit Now or quit now no worky under 18.04 with desktop tower USB keyboard.
– fleamour
Aug 9 '18 at 19:10
add a comment |
1
this is not exactly what I need, I need to use my usb keyboard, but your code is very useful! ;)
– atmon3r
Aug 21 '12 at 22:28
Lock-keyboard-for-Baby will let you disable your internal keyboard while mainting the use of the external
– LnxSlck
Aug 22 '12 at 0:49
Brilliant. Lock-Keyboard-For-Baby works in Ubuntu 16.04 as well. I prefer to code using pen and paperbook keeping it on keyboard. This tiny utility solved my problem. For others, you might have to run sudo apt-get install libgtk2-perl before running the perl script
– mac
Feb 1 '17 at 8:05
"Quit Now", Quit Now or quit now no worky under 18.04 with desktop tower USB keyboard.
– fleamour
Aug 9 '18 at 19:10
1
1
this is not exactly what I need, I need to use my usb keyboard, but your code is very useful! ;)
– atmon3r
Aug 21 '12 at 22:28
this is not exactly what I need, I need to use my usb keyboard, but your code is very useful! ;)
– atmon3r
Aug 21 '12 at 22:28
Lock-keyboard-for-Baby will let you disable your internal keyboard while mainting the use of the external
– LnxSlck
Aug 22 '12 at 0:49
Lock-keyboard-for-Baby will let you disable your internal keyboard while mainting the use of the external
– LnxSlck
Aug 22 '12 at 0:49
Brilliant. Lock-Keyboard-For-Baby works in Ubuntu 16.04 as well. I prefer to code using pen and paperbook keeping it on keyboard. This tiny utility solved my problem. For others, you might have to run sudo apt-get install libgtk2-perl before running the perl script
– mac
Feb 1 '17 at 8:05
Brilliant. Lock-Keyboard-For-Baby works in Ubuntu 16.04 as well. I prefer to code using pen and paperbook keeping it on keyboard. This tiny utility solved my problem. For others, you might have to run sudo apt-get install libgtk2-perl before running the perl script
– mac
Feb 1 '17 at 8:05
"Quit Now", Quit Now or quit now no worky under 18.04 with desktop tower USB keyboard.
– fleamour
Aug 9 '18 at 19:10
"Quit Now", Quit Now or quit now no worky under 18.04 with desktop tower USB keyboard.
– fleamour
Aug 9 '18 at 19:10
add a comment |
One sure way to disable it is to unplug the signal cable. You need to pop up the keyboard for that. For information on how to do that, check out the Maintenance and Service Guide for the HP Pavilion dv9000 and dv9200 Notebook PC .
Now there is a way to disable the keyboard using xinput
. T do that, just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the commands below.
To list the devices your X
xinput --list
To disable the keyboard:
xinput set-int-prop 2 "Device Enabled" 8 0
To enable the keyboard again:
xinput set-int-prop 2 "Device Enabled" 8 1
If you get a error about permissions, use the commands above with sudo
.
add a comment |
One sure way to disable it is to unplug the signal cable. You need to pop up the keyboard for that. For information on how to do that, check out the Maintenance and Service Guide for the HP Pavilion dv9000 and dv9200 Notebook PC .
Now there is a way to disable the keyboard using xinput
. T do that, just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the commands below.
To list the devices your X
xinput --list
To disable the keyboard:
xinput set-int-prop 2 "Device Enabled" 8 0
To enable the keyboard again:
xinput set-int-prop 2 "Device Enabled" 8 1
If you get a error about permissions, use the commands above with sudo
.
add a comment |
One sure way to disable it is to unplug the signal cable. You need to pop up the keyboard for that. For information on how to do that, check out the Maintenance and Service Guide for the HP Pavilion dv9000 and dv9200 Notebook PC .
Now there is a way to disable the keyboard using xinput
. T do that, just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the commands below.
To list the devices your X
xinput --list
To disable the keyboard:
xinput set-int-prop 2 "Device Enabled" 8 0
To enable the keyboard again:
xinput set-int-prop 2 "Device Enabled" 8 1
If you get a error about permissions, use the commands above with sudo
.
One sure way to disable it is to unplug the signal cable. You need to pop up the keyboard for that. For information on how to do that, check out the Maintenance and Service Guide for the HP Pavilion dv9000 and dv9200 Notebook PC .
Now there is a way to disable the keyboard using xinput
. T do that, just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the commands below.
To list the devices your X
xinput --list
To disable the keyboard:
xinput set-int-prop 2 "Device Enabled" 8 0
To enable the keyboard again:
xinput set-int-prop 2 "Device Enabled" 8 1
If you get a error about permissions, use the commands above with sudo
.
edited Mar 31 '15 at 20:17
Elder Geek
26.5k952126
26.5k952126
answered Aug 22 '12 at 11:32
Mitch♦Mitch
83.9k14173228
83.9k14173228
add a comment |
add a comment |
For Disabling Laptop's internal keyboard permanently On Ubuntu, Need pass this i8042.nokbd
Kernel parameters for not to check/create keyboard port
i8042.nokbd [HW] Don't check/create keyboard port
Open terminal and run the following command
$sudo gedit /etc/default/grub
Try to find the following line
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
Add parameter i8042.nokbd
, the above line should be looks like this
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash i8042.nokbd"
Update grub as following command
$sudo update-grub
Then reboot
your laptop computer.
add a comment |
For Disabling Laptop's internal keyboard permanently On Ubuntu, Need pass this i8042.nokbd
Kernel parameters for not to check/create keyboard port
i8042.nokbd [HW] Don't check/create keyboard port
Open terminal and run the following command
$sudo gedit /etc/default/grub
Try to find the following line
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
Add parameter i8042.nokbd
, the above line should be looks like this
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash i8042.nokbd"
Update grub as following command
$sudo update-grub
Then reboot
your laptop computer.
add a comment |
For Disabling Laptop's internal keyboard permanently On Ubuntu, Need pass this i8042.nokbd
Kernel parameters for not to check/create keyboard port
i8042.nokbd [HW] Don't check/create keyboard port
Open terminal and run the following command
$sudo gedit /etc/default/grub
Try to find the following line
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
Add parameter i8042.nokbd
, the above line should be looks like this
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash i8042.nokbd"
Update grub as following command
$sudo update-grub
Then reboot
your laptop computer.
For Disabling Laptop's internal keyboard permanently On Ubuntu, Need pass this i8042.nokbd
Kernel parameters for not to check/create keyboard port
i8042.nokbd [HW] Don't check/create keyboard port
Open terminal and run the following command
$sudo gedit /etc/default/grub
Try to find the following line
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
Add parameter i8042.nokbd
, the above line should be looks like this
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash i8042.nokbd"
Update grub as following command
$sudo update-grub
Then reboot
your laptop computer.
answered Oct 3 '15 at 21:41
Rokibul HasanRokibul Hasan
15112
15112
add a comment |
add a comment |
Device id
's received from xinput list
as suggested in accepted answer are sometimes somehow changed on reboot (at least on my PC) which resulted in disabling wrong device.
That's why I've ended using device name
instead of id
, e.g.:
xinput disable "AT Translated Set 2 keyboard"
add a comment |
Device id
's received from xinput list
as suggested in accepted answer are sometimes somehow changed on reboot (at least on my PC) which resulted in disabling wrong device.
That's why I've ended using device name
instead of id
, e.g.:
xinput disable "AT Translated Set 2 keyboard"
add a comment |
Device id
's received from xinput list
as suggested in accepted answer are sometimes somehow changed on reboot (at least on my PC) which resulted in disabling wrong device.
That's why I've ended using device name
instead of id
, e.g.:
xinput disable "AT Translated Set 2 keyboard"
Device id
's received from xinput list
as suggested in accepted answer are sometimes somehow changed on reboot (at least on my PC) which resulted in disabling wrong device.
That's why I've ended using device name
instead of id
, e.g.:
xinput disable "AT Translated Set 2 keyboard"
edited Apr 13 '17 at 12:24
Community♦
1
1
answered Mar 31 '15 at 19:43
janotjanot
75011028
75011028
add a comment |
add a comment |
For example to temporarly disable de keyboard for clean up:
$ xinput float id#;sleep t;xinput reattach id# master#
t -time to sleep in seconds
id# and master# as mentioned above (top of all),for example on my notebook:
$ xinput float 11;sleep 5 ;xinput reattach 11 3
I just added this because I like to clean the keyboard all the time. I have to reboot, so I discover this!
add a comment |
For example to temporarly disable de keyboard for clean up:
$ xinput float id#;sleep t;xinput reattach id# master#
t -time to sleep in seconds
id# and master# as mentioned above (top of all),for example on my notebook:
$ xinput float 11;sleep 5 ;xinput reattach 11 3
I just added this because I like to clean the keyboard all the time. I have to reboot, so I discover this!
add a comment |
For example to temporarly disable de keyboard for clean up:
$ xinput float id#;sleep t;xinput reattach id# master#
t -time to sleep in seconds
id# and master# as mentioned above (top of all),for example on my notebook:
$ xinput float 11;sleep 5 ;xinput reattach 11 3
I just added this because I like to clean the keyboard all the time. I have to reboot, so I discover this!
For example to temporarly disable de keyboard for clean up:
$ xinput float id#;sleep t;xinput reattach id# master#
t -time to sleep in seconds
id# and master# as mentioned above (top of all),for example on my notebook:
$ xinput float 11;sleep 5 ;xinput reattach 11 3
I just added this because I like to clean the keyboard all the time. I have to reboot, so I discover this!
edited May 12 '17 at 23:19
Community♦
1
1
answered Mar 30 '16 at 19:38
Tyþë-ØTyþë-Ø
517
517
add a comment |
add a comment |
Try running xmodmap -e 'keycode 24='
to disable just the Q key. If that works, you could add it it to your ~/.bashrc
or global /etc/bash.bashrc
file. I got this idea from here, which shows all the key-mappings.
4
Wouldn't this disableq
in the external keyboard as well?
– Sparhawk
Aug 30 '13 at 5:07
add a comment |
Try running xmodmap -e 'keycode 24='
to disable just the Q key. If that works, you could add it it to your ~/.bashrc
or global /etc/bash.bashrc
file. I got this idea from here, which shows all the key-mappings.
4
Wouldn't this disableq
in the external keyboard as well?
– Sparhawk
Aug 30 '13 at 5:07
add a comment |
Try running xmodmap -e 'keycode 24='
to disable just the Q key. If that works, you could add it it to your ~/.bashrc
or global /etc/bash.bashrc
file. I got this idea from here, which shows all the key-mappings.
Try running xmodmap -e 'keycode 24='
to disable just the Q key. If that works, you could add it it to your ~/.bashrc
or global /etc/bash.bashrc
file. I got this idea from here, which shows all the key-mappings.
answered Aug 21 '12 at 18:16
dxvxddxvxd
33718
33718
4
Wouldn't this disableq
in the external keyboard as well?
– Sparhawk
Aug 30 '13 at 5:07
add a comment |
4
Wouldn't this disableq
in the external keyboard as well?
– Sparhawk
Aug 30 '13 at 5:07
4
4
Wouldn't this disable
q
in the external keyboard as well?– Sparhawk
Aug 30 '13 at 5:07
Wouldn't this disable
q
in the external keyboard as well?– Sparhawk
Aug 30 '13 at 5:07
add a comment |
For what it's worth, based on previous answers and my own playing around, I created the following script, which I call toggle_keyboard.sh
and place in my ~/bin
path. I have a keyboard shortcut that runs it set to CtrlWinK.
Some problems with the previous answers and benefit of my script:
- Relying on an id number with xinput fails when you reboot and the id number is changed. This happened to me when running
xinput float 13
. I ended up disabling the wrong hardware. - Relying on a file to hold the enabled/disabled state will fail if you reboot as well. The file will tell you the keyboard is disabled (if you disabled it with the script), but after a reboot it will be enabled again. My solution gets the enabled/disabled information from a parsed xinput command.
- My script will work with any xinput device that shows up when you type
xinput list --name-only
. Just get the name and edit the top four variables. I use it for my laptop keyboard, webcam, touchscreen monitor and a few other things I use only once in a while.
#!/bin/bash
# Toggle the laptop keyboard either on or off and notify the user about it
# Device name can be found by typing this command: xinput list --name-only
DEVICE_NAME="AT Translated Set 2 keyboard"
# The display name of the device in the notify-send popup
DEVICE_DISPLAY_NAME="Laptop Keyboard"
# Set these to the icons you want to use.
# If they are not found, the notification will still work.
ICON_ENABLE="$HOME/.icons/keyboard.png"
ICON_DISABLE="$HOME/.icons/keyboard_disabled.png"
function xinput_set_prop() {
xinput set-prop "$DEVICE_NAME" "Device Enabled" $1
}
function notify_change() {
if [ -f "$1" ]; then
notify-send --urgency=low --icon="$1" "$2"
else
notify-send --urgency=low "$2"
fi
}
# Returns 1 if device is enabled, 0 if disabled
is_enabled=$(xinput list-props "$DEVICE_NAME" | grep "Device Enabled" | awk '{ print $4 }' | sed 's/[^0-9]*//g')
if [ $is_enabled -eq 1 ]; then
# device is enabled, so disable it
xinput_set_prop 0
notify_change "$ICON_DISABLE" "$DEVICE_DISPLAY_NAME Disabled"
else
# device is disabled, so enable it
xinput_set_prop 1
notify_change "$ICON_ENABLE" "$DEVICE_DISPLAY_NAME Enabled"
fi
add a comment |
For what it's worth, based on previous answers and my own playing around, I created the following script, which I call toggle_keyboard.sh
and place in my ~/bin
path. I have a keyboard shortcut that runs it set to CtrlWinK.
Some problems with the previous answers and benefit of my script:
- Relying on an id number with xinput fails when you reboot and the id number is changed. This happened to me when running
xinput float 13
. I ended up disabling the wrong hardware. - Relying on a file to hold the enabled/disabled state will fail if you reboot as well. The file will tell you the keyboard is disabled (if you disabled it with the script), but after a reboot it will be enabled again. My solution gets the enabled/disabled information from a parsed xinput command.
- My script will work with any xinput device that shows up when you type
xinput list --name-only
. Just get the name and edit the top four variables. I use it for my laptop keyboard, webcam, touchscreen monitor and a few other things I use only once in a while.
#!/bin/bash
# Toggle the laptop keyboard either on or off and notify the user about it
# Device name can be found by typing this command: xinput list --name-only
DEVICE_NAME="AT Translated Set 2 keyboard"
# The display name of the device in the notify-send popup
DEVICE_DISPLAY_NAME="Laptop Keyboard"
# Set these to the icons you want to use.
# If they are not found, the notification will still work.
ICON_ENABLE="$HOME/.icons/keyboard.png"
ICON_DISABLE="$HOME/.icons/keyboard_disabled.png"
function xinput_set_prop() {
xinput set-prop "$DEVICE_NAME" "Device Enabled" $1
}
function notify_change() {
if [ -f "$1" ]; then
notify-send --urgency=low --icon="$1" "$2"
else
notify-send --urgency=low "$2"
fi
}
# Returns 1 if device is enabled, 0 if disabled
is_enabled=$(xinput list-props "$DEVICE_NAME" | grep "Device Enabled" | awk '{ print $4 }' | sed 's/[^0-9]*//g')
if [ $is_enabled -eq 1 ]; then
# device is enabled, so disable it
xinput_set_prop 0
notify_change "$ICON_DISABLE" "$DEVICE_DISPLAY_NAME Disabled"
else
# device is disabled, so enable it
xinput_set_prop 1
notify_change "$ICON_ENABLE" "$DEVICE_DISPLAY_NAME Enabled"
fi
add a comment |
For what it's worth, based on previous answers and my own playing around, I created the following script, which I call toggle_keyboard.sh
and place in my ~/bin
path. I have a keyboard shortcut that runs it set to CtrlWinK.
Some problems with the previous answers and benefit of my script:
- Relying on an id number with xinput fails when you reboot and the id number is changed. This happened to me when running
xinput float 13
. I ended up disabling the wrong hardware. - Relying on a file to hold the enabled/disabled state will fail if you reboot as well. The file will tell you the keyboard is disabled (if you disabled it with the script), but after a reboot it will be enabled again. My solution gets the enabled/disabled information from a parsed xinput command.
- My script will work with any xinput device that shows up when you type
xinput list --name-only
. Just get the name and edit the top four variables. I use it for my laptop keyboard, webcam, touchscreen monitor and a few other things I use only once in a while.
#!/bin/bash
# Toggle the laptop keyboard either on or off and notify the user about it
# Device name can be found by typing this command: xinput list --name-only
DEVICE_NAME="AT Translated Set 2 keyboard"
# The display name of the device in the notify-send popup
DEVICE_DISPLAY_NAME="Laptop Keyboard"
# Set these to the icons you want to use.
# If they are not found, the notification will still work.
ICON_ENABLE="$HOME/.icons/keyboard.png"
ICON_DISABLE="$HOME/.icons/keyboard_disabled.png"
function xinput_set_prop() {
xinput set-prop "$DEVICE_NAME" "Device Enabled" $1
}
function notify_change() {
if [ -f "$1" ]; then
notify-send --urgency=low --icon="$1" "$2"
else
notify-send --urgency=low "$2"
fi
}
# Returns 1 if device is enabled, 0 if disabled
is_enabled=$(xinput list-props "$DEVICE_NAME" | grep "Device Enabled" | awk '{ print $4 }' | sed 's/[^0-9]*//g')
if [ $is_enabled -eq 1 ]; then
# device is enabled, so disable it
xinput_set_prop 0
notify_change "$ICON_DISABLE" "$DEVICE_DISPLAY_NAME Disabled"
else
# device is disabled, so enable it
xinput_set_prop 1
notify_change "$ICON_ENABLE" "$DEVICE_DISPLAY_NAME Enabled"
fi
For what it's worth, based on previous answers and my own playing around, I created the following script, which I call toggle_keyboard.sh
and place in my ~/bin
path. I have a keyboard shortcut that runs it set to CtrlWinK.
Some problems with the previous answers and benefit of my script:
- Relying on an id number with xinput fails when you reboot and the id number is changed. This happened to me when running
xinput float 13
. I ended up disabling the wrong hardware. - Relying on a file to hold the enabled/disabled state will fail if you reboot as well. The file will tell you the keyboard is disabled (if you disabled it with the script), but after a reboot it will be enabled again. My solution gets the enabled/disabled information from a parsed xinput command.
- My script will work with any xinput device that shows up when you type
xinput list --name-only
. Just get the name and edit the top four variables. I use it for my laptop keyboard, webcam, touchscreen monitor and a few other things I use only once in a while.
#!/bin/bash
# Toggle the laptop keyboard either on or off and notify the user about it
# Device name can be found by typing this command: xinput list --name-only
DEVICE_NAME="AT Translated Set 2 keyboard"
# The display name of the device in the notify-send popup
DEVICE_DISPLAY_NAME="Laptop Keyboard"
# Set these to the icons you want to use.
# If they are not found, the notification will still work.
ICON_ENABLE="$HOME/.icons/keyboard.png"
ICON_DISABLE="$HOME/.icons/keyboard_disabled.png"
function xinput_set_prop() {
xinput set-prop "$DEVICE_NAME" "Device Enabled" $1
}
function notify_change() {
if [ -f "$1" ]; then
notify-send --urgency=low --icon="$1" "$2"
else
notify-send --urgency=low "$2"
fi
}
# Returns 1 if device is enabled, 0 if disabled
is_enabled=$(xinput list-props "$DEVICE_NAME" | grep "Device Enabled" | awk '{ print $4 }' | sed 's/[^0-9]*//g')
if [ $is_enabled -eq 1 ]; then
# device is enabled, so disable it
xinput_set_prop 0
notify_change "$ICON_DISABLE" "$DEVICE_DISPLAY_NAME Disabled"
else
# device is disabled, so enable it
xinput_set_prop 1
notify_change "$ICON_ENABLE" "$DEVICE_DISPLAY_NAME Enabled"
fi
edited Apr 8 '18 at 3:36
muru
1
1
answered Apr 8 '18 at 3:27
cbp44cbp44
112
112
add a comment |
add a comment |
xinput float "AT Translated Set 2 keyboard"
After spending hours over years with different methods with different distros and releases. The above terminal command is what I rely on after problems..... I use this now with neon plasma and was using it a month ago in straight ubuntu 18.04.
(needs applying after restart - can be placed in startup)
New contributor
add a comment |
xinput float "AT Translated Set 2 keyboard"
After spending hours over years with different methods with different distros and releases. The above terminal command is what I rely on after problems..... I use this now with neon plasma and was using it a month ago in straight ubuntu 18.04.
(needs applying after restart - can be placed in startup)
New contributor
add a comment |
xinput float "AT Translated Set 2 keyboard"
After spending hours over years with different methods with different distros and releases. The above terminal command is what I rely on after problems..... I use this now with neon plasma and was using it a month ago in straight ubuntu 18.04.
(needs applying after restart - can be placed in startup)
New contributor
xinput float "AT Translated Set 2 keyboard"
After spending hours over years with different methods with different distros and releases. The above terminal command is what I rely on after problems..... I use this now with neon plasma and was using it a month ago in straight ubuntu 18.04.
(needs applying after restart - can be placed in startup)
New contributor
New contributor
answered 1 hour ago
duncan williamsduncan williams
1
1
New contributor
New contributor
add a comment |
add a comment |
I had a problem with a stuck key, there is a command somewhere that you can put into terminal and it will automatically disable it every time on startup, I am no programmer and I can't remember i (I just copy and paste into terminal, I have no clue how you guys know this stuff, or how you all can come up with different versions lol), had it on mint 17, but I also know there is one you can even put in so it disables it even before you login, although I never did that as it is more involved
But what I have done, is go into settings, keyboard ( on mint 18 xfce you click back where the start menu used to be and go to system then keyboard) and you can disable repeat keys, it's just a box you uncheck you'll see it, you'll still have to use your usb keyboard as if you use the other it will retype the offending letter every other key, but it does the job perfectly
By the way thank you all for helping me with computers over the years whoever you guys are, you rock, had win 8 and my computer like ev eryone elses who had a notebook touchscreen just couldn't handle it, and through your discussions on here I have kept going, you are heroes :)
add a comment |
I had a problem with a stuck key, there is a command somewhere that you can put into terminal and it will automatically disable it every time on startup, I am no programmer and I can't remember i (I just copy and paste into terminal, I have no clue how you guys know this stuff, or how you all can come up with different versions lol), had it on mint 17, but I also know there is one you can even put in so it disables it even before you login, although I never did that as it is more involved
But what I have done, is go into settings, keyboard ( on mint 18 xfce you click back where the start menu used to be and go to system then keyboard) and you can disable repeat keys, it's just a box you uncheck you'll see it, you'll still have to use your usb keyboard as if you use the other it will retype the offending letter every other key, but it does the job perfectly
By the way thank you all for helping me with computers over the years whoever you guys are, you rock, had win 8 and my computer like ev eryone elses who had a notebook touchscreen just couldn't handle it, and through your discussions on here I have kept going, you are heroes :)
add a comment |
I had a problem with a stuck key, there is a command somewhere that you can put into terminal and it will automatically disable it every time on startup, I am no programmer and I can't remember i (I just copy and paste into terminal, I have no clue how you guys know this stuff, or how you all can come up with different versions lol), had it on mint 17, but I also know there is one you can even put in so it disables it even before you login, although I never did that as it is more involved
But what I have done, is go into settings, keyboard ( on mint 18 xfce you click back where the start menu used to be and go to system then keyboard) and you can disable repeat keys, it's just a box you uncheck you'll see it, you'll still have to use your usb keyboard as if you use the other it will retype the offending letter every other key, but it does the job perfectly
By the way thank you all for helping me with computers over the years whoever you guys are, you rock, had win 8 and my computer like ev eryone elses who had a notebook touchscreen just couldn't handle it, and through your discussions on here I have kept going, you are heroes :)
I had a problem with a stuck key, there is a command somewhere that you can put into terminal and it will automatically disable it every time on startup, I am no programmer and I can't remember i (I just copy and paste into terminal, I have no clue how you guys know this stuff, or how you all can come up with different versions lol), had it on mint 17, but I also know there is one you can even put in so it disables it even before you login, although I never did that as it is more involved
But what I have done, is go into settings, keyboard ( on mint 18 xfce you click back where the start menu used to be and go to system then keyboard) and you can disable repeat keys, it's just a box you uncheck you'll see it, you'll still have to use your usb keyboard as if you use the other it will retype the offending letter every other key, but it does the job perfectly
By the way thank you all for helping me with computers over the years whoever you guys are, you rock, had win 8 and my computer like ev eryone elses who had a notebook touchscreen just couldn't handle it, and through your discussions on here I have kept going, you are heroes :)
answered Aug 6 '16 at 20:50
mattmatt
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f160945%2fis-there-a-way-to-disable-a-laptops-internal-keyboard%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What brand and model laptop is it?
– Mitch♦
Aug 21 '12 at 21:18
it's
HP pavilion dv9000
– atmon3r
Aug 21 '12 at 21:31
4
The most straightforward way would be to lift the keyboard and disconnect it from the motherboard. You can then place it right back down where it was, sans the connection. This way the keyboard will be disabled after reinstalls and you wont need to bother with software. See this link, about halfway down the page where it gets to the keyboard: insidemylaptop.com/…
– Mark Paskal
Aug 21 '12 at 22:00
Might also be worth taking it out, taking it apart, an cleaning between the layers..
– JonasCz
Mar 1 '15 at 14:25