我一直在尝试运行一个命令,当我按下我的竹子墨水笔的顶部键。我意识到它通过蓝牙连接,当我按下按钮并停止连接时,当我释放它。
我被连接蓝牙设备时运行脚本绊倒了,当我跑
udevadm monitor --environment --udev --kernel --property然后按一次按钮,得到以下输出:
KERNEL[5118.647193] add /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0/hci0:3585 (bluetooth)
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0/hci0:3585
SUBSYSTEM=bluetooth
DEVTYPE=link
SEQNUM=4094
UDEV [5118.657098] add /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0/hci0:3585 (bluetooth)
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0/hci0:3585
SUBSYSTEM=bluetooth
DEVTYPE=link
SEQNUM=4094
USEC_INITIALIZED=5118654305
SYSTEMD_ALIAS=/sys/subsystem/bluetooth/devices/hci0:3585
SYSTEMD_WANTS=bluetooth.target
SYSTEMD_USER_WANTS=bluetooth.target
TAGS=:systemd:
KERNEL[5119.311809] remove /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0/hci0:3585 (bluetooth)
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0/hci0:3585
SUBSYSTEM=bluetooth
DEVTYPE=link
SEQNUM=4095
UDEV [5119.317304] remove /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0/hci0:3585 (bluetooth)
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0/hci0:3585
SUBSYSTEM=bluetooth
DEVTYPE=link
SEQNUM=4095
USEC_INITIALIZED=5118654305
SYSTEMD_ALIAS=/sys/subsystem/bluetooth/devices/hci0:3585
SYSTEMD_WANTS=bluetooth.target
SYSTEMD_USER_WANTS=bluetooth.target
TAGS=:systemd:不幸的是,没有idVendor或idProduct。
当我跑的时候
sudo tail -f /var/log/syslog但是,它会抱怨该文件不存在。
到目前为止,我的udev rules看起来是这样的。
# Run a program when my Bamboo Ink is connected
ACTION=="add" , SUBSYSTEM=="bluetooth", ATTR{idVendor}=="xxx", ATTR{idProduct}=="yyy", ATTRS{model}=="Bamboo Ink", RUN+="xournalpp"猜测模型是“竹墨”,因为我在journalctl -b中找到了这一行
Feb 26 14:57:35 X380-Yoga kernel: wacom 0005:056A:035F.000C: Unknown device_type for 'Bamboo Ink'. Ignoring.
所以我需要找到idVendor,idProduct和模型。还有别的办法吗?
发布于 2020-06-19 15:07:57
我就是这样做的:
ACTION=="add" , SUBSYSTEM=="bluetooth", DEVPATH=="/devices/pci0000:00/0000:00:14.0/usb1/1-10/1-10:1.0/bluetooth/hci0/hci0:3585", RUN+="/home/gvb/bin/run-pen-state.sh"我想做的是在钢笔和橡皮擦之间切换,在Xournal中切换。所需的两个脚本如下所示。他们需要两个小的工具: wmctrl和xdotool..。
"run-pen-state.sh“的内容是
#!/bin/csh
sudo -u gvb -i /home/gvb/bin/pen-state而“笔式”本身
#!/usr/bin/perl -w
$home=$ENV{'HOME'};
$store=`grep "#state: " ~/bin/pen-state | grep -v store`;
chomp($store);
$command=`export DISPLAY=:0; export XAUTHORITY=$home/.Xauthority; wmctrl -l`;
foreach $line (split(/\n/,$command)){
if (($line=~ /Xournal/)&&($line=~ /$filename/)){
$winid=(split(/ /,$line))[0];
}
}
if($winid){
system("export DISPLAY=:0; export XAUTHORITY=$home/.Xauthority; wmctrl -i -a $winid");
if($store =~ /pen/){
$now="state: eraser";
system("export DISPLAY=:0; export XAUTHORITY=$home/.Xauthority; xdotool key shift+ctrl+e");
}else{
$now="state: pen";
system("export DISPLAY=:0; export XAUTHORITY=$home/.Xauthority; xdotool key shift+ctrl+p");
}
$now="#$now";
print "$store\n";
print "$now\n";
open(SELF,"$home/bin/pen-state");
read(SELF,$self,-s "$home/bin/pen-state",0);
close(SELF);
$self=~ s/$store/$now/;
open(SELF,">$home/bin/pen-state");
print SELF $self;
close(SELF);
}
#state: penhttps://unix.stackexchange.com/questions/569814
复制相似问题