1 votes

Aidez-moi à créer un script qui s'exécute lorsque le clavier est désactivé.

J'ai fait ce qui suit

 # Saved as /etc/udev/rules.d/81-MSSP3-dock.rules

# Microsoft Surface Pro Keyboard
SUBSYSTEM=="input", ENV{ID_VENDOR_ID}=="045e", ENV{ID_MODEL_ID}=="07e3, GOTO="MSSP3_rules"
GOTO="MSSP3_rules_end"

LABEL="MSSP3_rules"
ACTION=="add", RUN+="/home/joshuarobison/Documents/Scripts/landscape.sh"
ACTION=="remove", RUN+="/home/joshuarobison/Documents/Scripts/portrait.sh"

LABEL="MSSP3_rules_end"

mon udev est comme suit

monitor will print the received events for:
UDEV - the event which udev sends out after rule processing

UDEV  [2672.635429] remove   /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/0003:045E:07E3.0012/input/input303/event3 (input)
ACTION=remove
BACKSPACE=guess
DEVLINKS=/dev/input/by-path/pci-0000:00:14.0-usb-0:3:1.0-event-kbd /dev/input/by-id/usb-Microsoft_Surface_Type_Cover-event-kbd
DEVNAME=/dev/input/event3
DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/0003:045E:07E3.0012/input/input303/event3
ID_BUS=usb
ID_INPUT=1
ID_INPUT_KEY=1
ID_INPUT_KEYBOARD=1
ID_MODEL=Surface_Type_Cover
ID_MODEL_ENC=Surface\x20Type\x20Cover
ID_MODEL_ID=07e3
ID_PATH=pci-0000:00:14.0-usb-0:3:1.0
ID_PATH_TAG=pci-0000_00_14_0-usb-0_3_1_0
ID_REVISION=0307
ID_SERIAL=Microsoft_Surface_Type_Cover
ID_TYPE=hid
ID_USB_DRIVER=usbhid
ID_USB_INTERFACES=:030000:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=Microsoft
ID_VENDOR_ENC=Microsoft
ID_VENDOR_ID=045e
LIBINPUT_DEVICE_GROUP=3/45e/7e3:usb-0000:00:14.0-3
MAJOR=13
MINOR=67
SEQNUM=4374
SUBSYSTEM=input
TAGS=:power-switch:
USEC_INITIALIZED=2297576881
XKBLAYOUT=jp
XKBMODEL=pc105

Les scripts fonctionnent déjà. Je sais que le problème est dans les règles udev en quelque sorte. Lorsque je détache et attache le clavier, le scripts n'est pas exécuté.

Même si les scripts portrait ou landscape.sh ne sont qu'une simple commande echo, rien ne se passe.

1voto

Joshua Robison Points 2862

La procédure suivante permet de configurer le Microsoft SP3 de manière à ce qu'il passe en mode portrait lorsque le clavier est retiré. Les scripts s'assurent que l'orientation du stylet actif et du toucher capacitif est correcte.

Merci à @george udeson pour le lien vers le tutoriel qui m'a aidé à écrire ceci.

Règles UDEV

# Saved as /etc/udev/rules.d/81-MSSP3-dock.rules

# Microsoft Surface Pro Keyboard

ACTION=="add" \
, ATTRS{idProduct}=="07e3" \
, ATTRS{idVendor}=="045e" \
, ENV{DISPLAY}=":0" \
, ENV{XAUTHORITY}="/home/joshuarobison/.Xauthority" \
, RUN+="//home/joshuarobison/Documents/Scripts/landscape.sh"

ACTION=="remove" \
, ATTRS{idProduct}=="07e3" \
, ATTRS{idVendor}=="045e" \
, ENV{DISPLAY}=":0" \
, ENV{XAUTHORITY}="/home/joshuarobison/.Xauthority" \
, RUN+="//home/joshuarobison/Documents/Scripts/portrait.sh"

portrait.sh script

#!/bin/sh
#Portrait
xrandr -o left
  xinput set-prop "NTRG0001:01 1B96:1B05" --type=float "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1
  xinput set-prop "NTRG0001:01 1B96:1B05" --type=float "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1
  xsetwacom set "NTRG0001:01 1B96:1B05 Pen stylus" Rotate ccw

landscape.sh script

#!/bin/sh
#landscape

  xrandr -o normal
  xinput set-prop "NTRG0001:01 1B96:1B05" --type=float "Coordinate Transformation Matrix" 0 0 0 0 0 0 0 0 0
  xinput set-prop "NTRG0001:01 1B96:1B05" --type=float "Coordinate Transformation Matrix" 0 0 0 0 0 0 0 0 0
  xsetwacom set "NTRG0001:01 1B96:1B05 Pen stylus" Rotate 0

Après avoir créé le fichier de règles udev, n'oubliez pas d'exécuter

sudo udevadm control --reload

SistemesEz.com

SystemesEZ est une communauté de sysadmins où vous pouvez résoudre vos problèmes et vos doutes. Vous pouvez consulter les questions des autres sysadmins, poser vos propres questions ou résoudre celles des autres.

Powered by:

X