博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
linux中为用户添加权限_如何在Linux中为X.org服务器禁用和启用笔记本电脑键盘
阅读量:2517 次
发布时间:2019-05-11

本文共 3956 字,大约阅读时间需要 13 分钟。

linux中为用户添加权限

Attaching a USB keyboard to a laptop is common when using a laptop because a normal keyboard may provide a more convenient typing experience. The laptop keyboard is not used in these situations. However, the laptop keyboard may still be touched by accident. In this post, we will discuss how to disable and enable the laptop keyboard in . I will also provide scripts ready for you to directly use them for disabling/enabling the laptop keyboard.

使用便携式计算机时,通常将USB键盘连接到便携式计算机,因为普通键盘可能会提供更方便的键入体验。 在这些情况下不使用笔记本电脑键盘。 但是,笔记本电脑的键盘可能仍然会被意外触摸。 在本文中,我们将讨论如何在禁用和启用笔记本电脑键盘。 我还将提供脚本,供您直接使用它们来禁用/启用笔记本电脑键盘。

禁用/启用笔记本电脑键盘的脚本 (Scripts for disabling/enabling laptop keyboard )

For those in hurry to have try, you can download the scripts from .

对于那些急于尝试的人,您可以从下载脚本。

These scripts use the tool for controlling the keyboard. You will need to install it on your Linux if your Linux hasn’t it installed by default.

这些脚本使用工具控制键盘。 如果默认情况下未安装Linux,则需要在Linux上安装它。

The scripts are in a git repository, you may clone the whole repository and copy these scripts out only by

这些脚本位于git存储库中,您可以克隆整个存储库并仅通过以下方式复制这些脚本:

$ git clone https://github.com/zma/usefulscripts$ cp -rv usefulscripts/script/ ./

The laptopkb-disable.sh will disable the keyboard and the laptopkb-enable.sh will enable the keyboard.

laptopkb-disable.sh将禁用键盘,而laptopkb-enable.sh将启用键盘。

laptop-keyboard.jpg

Before disabling your keyboard on your laptop, make sure you have an external USB keyboard connected to your laptop. Otherwise, you will have no way to input commands to enable your keyboard back unless you restart Linux using the power button or run the commands through a session to your laptop (if you enabled the SSH service).

在笔记本电脑上禁用键盘之前,请确保已将外部USB键盘连接到笔记本电脑。 否则,除非您使用电源按钮重启Linux或通过与笔记本电脑的会话运行命令,否则您将无法输入命令来启用键盘,除非您启用了SSH服务。

脚本背后的机制 (The mechanisms behind the scripts )

is a utility to configure and test X input devices including the keyboard and we use it to control the laptop keyboard.

是一个实用程序,用于配置和测试X输入设备(包括键盘),我们使用它来控制笔记本电脑键盘。

The float slave command of xinput removes slave from its current master device, and the --reattach slave master command reattachs slave to master. So these two commands can be used to disable/enable a keyboard (and other devices).

xinputfloat slave命令将从其当前主设备中删除从设备,-- --reattach slave master命令将从设备重新连接到主设备。 因此,这两个命令可用于禁用/启用键盘(和其他设备)。

The remaining problem is to find out the “slave” and “master”. xinput list shows a list of devices as follows.

剩下的问题是找出“奴隶”和“主人”。 xinput list显示设备列表,如下所示。

⎡ Virtual core pointer id=2 [master pointer (3)]⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]⎜ ↳ Logitech Optical USB Mouse id=9 [slave pointer (2)]⎜ ↳ SynPS/2 Synaptics TouchPad id=11 [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)]  ↳ Power Button id=8 [slave keyboard (3)]  ↳ HP WMI hotkeys id=12 [slave keyboard (3)]  ↳ AT Translated Set 2 keyboard id=10 [slave keyboard (3)]⎡ mouse pointer id=13 [master pointer (14)]⎜ ↳ mouse XTEST pointer id=15 [slave pointer (13)]⎣ mouse keyboard id=14 [master keyboard (13)]  ↳ mouse XTEST keyboard id=16 [slave keyboard (14)]

Usually the “AT Translated Set 2 keyboard” is the laptop keyboard. “Virtual core keyboard” is the keyboard master (which is 3 from my observations and 3 is used directly in the script. Yes, it’s a dirty trick. Let me know if you find it is not 3 for you by leaving a comment). From the output of xinput list, we can find out the ids. To find out the laptop keyboard id, we can use grep + cut:

通常,“ AT Translated Set 2键盘”是笔记本电脑键盘。 “虚拟核心键盘”是键盘母版(根据我的观察,这是3个,直接在脚本中使用3个。是的,这是一个肮脏的把戏。请通过评论让我知道您是否不是3个)。 从xinput list的输出中,我们可以找到id。 要找出笔记本电脑的键盘ID,我们可以使用grep + cut

$ xinput list | grep 'AT Translated Set' | cut -f2 | cut -d'=' -f2

So, adter combining them together, we have the scripts I put in the repository.

因此,将它们组合在一起,我们就将脚本放到了存储库中。

翻译自:

linux中为用户添加权限

转载地址:http://yplwd.baihongyu.com/

你可能感兴趣的文章
Java中的线程Thread方法之---suspend()和resume() 分类: ...
查看>>
经典排序算法回顾:选择排序,快速排序
查看>>
BZOJ2213 [Poi2011]Difference 【乱搞】
查看>>
c# 对加密的MP4文件进行解密
查看>>
AOP面向切面编程C#实例
查看>>
Win form碎知识点
查看>>
避免使用不必要的浮动
查看>>
第一节:ASP.NET开发环境配置
查看>>
sqlserver database常用命令
查看>>
rsync远程同步的基本配置与使用
查看>>
第二天作业
查看>>
访问属性和访问实例变量的区别
查看>>
Spring MVC 异常处理 - SimpleMappingExceptionResolver
查看>>
props 父组件给子组件传递参数
查看>>
【loj6038】「雅礼集训 2017 Day5」远行 树的直径+并查集+LCT
查看>>
十二种获取Spring的上下文环境ApplicationContext的方法
查看>>
UVA 11346 Probability 概率 (连续概率)
查看>>
linux uniq 命令
查看>>
Openssl rand命令
查看>>
HDU2825 Wireless Password 【AC自动机】【状压DP】
查看>>