Bamboo Ink Penの上キーを押すとコマンドを実行しようとしました。ボタンを押したときに接続が停止し、ボタンを離したときにBluetooth経由で接続されたことに気づきました。
私は倒れましたBluetoothデバイスが接続されたときにスクリプトを実行する私が走るとき
udevadm monitor --environment --udev --kernel --property
ボタンを1回押すと、次のような結果が出力されます。
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、modelを見つける必要があります。別の方法がありますか?
ベストアンサー1
これが私がする方法です:
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でペンと消しゴムを切り替えることです。 2つの必須スクリプトを以下に示します。 wmctrlとxdotoolという2つの小さなユーティリティが必要です。
「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: pen