/dev/nullelsexinput--set-button-map$id3212"/> /dev/nullelsexinput--set-button-map$id3212">

Home  >  Article  >  System Tutorial  >  Linux left and right mouse button swap implementation code

Linux left and right mouse button swap implementation code

WBOY
WBOYforward
2024-01-07 19:02:18730browse

linux鼠标左右键互换脚本,作者今天, 使用 GNOME, 发现 Linux 也需要这些工具之一, 所以有了这个脚本。非常简单好用。

lr="l"
for id in `xinput list | grep "pointer" | sed -r 's/.*id=([0-9]+).*/\1/'`;
do
	if [[ $lr == "r" ]]
	then
		xinput --set-button-map $id 1 2 3 2>/dev/null
	else
		xinput --set-button-map $id 3 2 1 2>/dev/null
	fi
done
filepath=$0
if [[ $lr == "r" ]]
then
	echo "now is right hand."
	sed -i '1s/lr="r"/lr="l"/' $filepath
else
	echo "now is left hand."
	sed -i '1s/lr="l"/lr="r"/' $filepath
fi

ubuntu命令切换鼠标左右键

话不多说,让我们开始切换:
首先让我们把鼠标切换到反手(这里之所以用反手一词,是因为有人可能是左撇子,有人是右撇子「还有右撇子?」):

xmodmap -e 'pointer = 3 2 1'

请拿出你的小鼠标摇一摇点一点,
是不是已经切换到反手了捏?!
好的,那让我们再切换回来:

xmodmap -e 'pointer = 1 2 3'

请再次猛烈的点击一次!
是不是又肥来了?!

不过每次切换都要输入29个字符,雅蠛蝶!
那就给他们起个小昵称嘛!

# filename .bashrc
alias mr="xmodmap -e 'pointer = 3 2 1'"
alias ml="xmodmap -e 'pointer = 1 2 3'"

好了,这篇文章就介绍到这了,希望大家以后多多支持本站。

The above is the detailed content of Linux left and right mouse button swap implementation code. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:jb51.net. If there is any infringement, please contact admin@php.cn delete