我编写了一个 Perl 脚本,允许用户同时使用两个鼠标。一个右手鼠标,另一个左手鼠标。该脚本有效。问题是,从屏幕锁定返回后,两个鼠标都变成左手鼠标(这是我在鼠标配置中选择的配置)。我拥有的 Linux 发行版是 Lubuntu 16.04.2 LTS
脚本(twomice.pl)如下:
#!/usr/bin/perl
# print "Two Mice\n";
# one left-handed and the other right-handed: cool!
# enter strings from command "xinput list"
my $leftDevice = "Mouse";
my $rightDevice = "MOUSE";
my $leftHandedOptions = "1 2 3";
my $rightHandedOptions = "3 2 1";
my $infole = `/usr/bin/xinput list | grep $leftDevice`;
my $infori = `/usr/bin/xinput list | grep $rightDevice`;
my $beginPart = "id=";
my $endPart = "\t";
$infole =~ /$beginPart(.*?)$endPart/; $infole = $1;
$infori =~ /$beginPart(.*?)$endPart/; $infori = $1;
my $commandWords = "/usr/bin/xinput set-button-map";
my $leftMouseCfg = $commandWords . " " . $infole . " " . $leftHandedOptions;
my $rightMouseCfg = $commandWords . " " . $infori . " " . $rightHandedOptions;
#print $leftMouseCfg . "\n";
#print $rightMouseCfg ."\n";
system($leftMouseCfg);
system($rightMouseCfg);
答案1
在启动时禁用“gnome 设置守护进程”解决了这个问题