Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] automatically start scrcpy on phone plugin
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
skunk
l33t
l33t


Joined: 28 May 2003
Posts: 646
Location: granada, spain

PostPosted: Sun Jul 07, 2019 11:34 am    Post subject: [SOLVED] automatically start scrcpy on phone plugin Reply with quote

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
View user's profile Send private message
Etal
Veteran
Veteran


Joined: 15 Jul 2005
Posts: 1932

PostPosted: Fri Jul 12, 2019 1:08 am    Post subject: Reply with quote

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
View user's profile Send private message
skunk
l33t
l33t


Joined: 28 May 2003
Posts: 646
Location: granada, spain

PostPosted: Fri Jul 12, 2019 9:21 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
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