View previous topic :: View next topic |
Author |
Message |
skunk l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
![](images/avatars/11317999223f8841cedbe91.gif)
Joined: 28 May 2003 Posts: 646 Location: granada, spain
|
Posted: Sun Jul 07, 2019 11:34 am Post subject: [SOLVED] automatically start scrcpy on phone plugin |
|
|
hello everybody!
i've recently discovered app-mobilephone/scrcpy::maggu2810-overlay, an excellent application that let you control your android smartphone while docked on your pc's usb port...
my intention was to start the application automatically when the phone is plugged, so i've added the following udev rule:
Code: | # cat /etc/udev/rules.d/20-phone.rules
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", ATTRS{idProduct}=="2e81", RUN+="/usr/local/bin/moto.sh"
# cat /usr/local/bin/moto.sh
#!/bin/sh
su skunk -c /usr/bin/scrcpy
|
unfortunatelly nothing happens after plugging the phone:
Code: | [950475.568435] usb 2-1.6: new high-speed USB device number 12 using ehci-pci
[950475.647947] usb 2-1.6: New USB device found, idVendor=22b8, idProduct=2e81, bcdDevice= 3.18
[950475.647951] usb 2-1.6: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[950475.647953] usb 2-1.6: Product: Moto G (5)
[950475.647954] usb 2-1.6: Manufacturer: motorola
[950475.647956] usb 2-1.6: SerialNumber: ZY3222W47R
|
yes, i did run "udevadm control -R" and /usr/local/bin/moto.sh script is working correctly when executed manually by root
please, is somebody so kind to tell me what i'm missing?
thank you
Last edited by skunk on Fri Jul 12, 2019 9:21 am; edited 1 time in total |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Etal Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
![](images/avatars/820592678480527eca4354.png)
Joined: 15 Jul 2005 Posts: 1932
|
Posted: Fri Jul 12, 2019 1:08 am Post subject: |
|
|
First, I would check if the script actually runs. Try adding "echo device connected >> /tmp/moto.log" to your shell script.
Maybe also add tee to capture the error message: "su skunk -c /usr/bin/scrcpy |& tee -a /tmp/moto.log"
My guess is it's a graphical application and it's missing the DISPLAY env variable and so can't connect to the X server. _________________ “And even in authoritarian countries, information networks are helping people discover new facts and making governments more accountable.”– Hillary Clinton, Jan. 21, 2010 |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
skunk l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
![](images/avatars/11317999223f8841cedbe91.gif)
Joined: 28 May 2003 Posts: 646 Location: granada, spain
|
Posted: Fri Jul 12, 2019 9:21 am Post subject: |
|
|
Etal wrote: | My guess is it's a graphical application and it's missing the DISPLAY env variable and so can't connect to the X server. |
that was it, good catch Etal
thank you! |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|