I finally got around to learning how udev works and using that to switch off the phone screen when the lapdock is connected.
apt install wlr-randr
to be able to change screen configuration from scripts- Look for a suitable device in
lsusb
to trigger the rule. I used this line from the output:Bus 003 Device 004: ID 27c0:0819 Cadwell Laboratories, Inc. WingCoolTouch
, i.e. the lapdock touch screen. - Create file
/etc/udev/rules.d/99-lapdock-then-phone-screen-off.rules
with following contents:
ACTION=="add" \
, ATTRS{idVendor}=="27c0" \
, ATTRS{idProduct}=="0819" \
, ENV{XDG_RUNTIME_DIR}="/run/user/1000" \
, RUN+="/usr/bin/wlr-randr --output DSI-1 --off"
Adapt the vendor and product id to what you found in lsusb
if you don’t have the same model as me, and the RUN+= lines if you want to do other stuff when the lapdock is connected.
Hope this helps!