DEV Community

Fernando Tricas García
Fernando Tricas García

Posted on

So, you want to control your android from your linux desktop?

I'm usually in front of a Linux desktop computer but I'm using an Android tablet to listen to some music and so on. The problem is that when you want to switch applications of select another web, or video, you have to go to the tablet, and touch it; this is not very comfortable when you have your hands (and eyes) in the computer.
There are some solutions for remote desktop management. See, for example, How to remote control one Android device with another, but they look a bit complicated for me and (did't check all) they do not have Linux clients.

Writing this post while seeing the tablet with a YouTube video

Fortunately I discovered Display and control your Android device from Linux desktop where you can learn about scrcpy which helps to solve the problem:

This application provides display and control of Android devices connected via USB (or over TCP/IP). It does not require any root access. It works on GNU/Linux, Windows and macOS.

You can install it (in my Fedora):

$ sudo dnf copr enable zeno/scrcpy

$ sudo dnf install scrcpy 
Enter fullscreen mode Exit fullscreen mode

Then, you need Enabling Device Owner Mode using Android Debug Bridge (ADB).

  • Go to Settings
  • Go to “About device” (Might be named slightly different)
  • Click the “Build number” field 7 times. This will turn on “Developer options”
  • Go back to Settings
  • Go to “Developer options”
  • Scroll down and enable “USB debugging”

Then you can connect to the devide via an USB cable or (my preferred option), via TCP/IP. In this case, you can follow: Connect to a device over Wi-Fi (Android 10 and lower).
First you'll need to connect via USB and type:

adb tcpip 5555
Enter fullscreen mode Exit fullscreen mode

Secondly, you'll need to know your IP: Settings > About tablet (or About phone) > Status > IP address. Or, on a Wear OS device, you can find the IP address at Settings > Wi-Fi Settings > Advanced > IP address.

Finally, you'll connect to the android device:

adb connect device_ip_address:5555
Enter fullscreen mode Exit fullscreen mode

And lauch the program:

scrcpy
Enter fullscreen mode Exit fullscreen mode

The only limitation I can see is when the tablet goes to sleep mode for energy saving, you need to touch it again in order to recover control from your computer.

Hope this helps. Next step, controlling the tablet from the command line? :-)

Discussion (1)

Collapse
roneo profile image
Roneo.org

Nice! Some custom commands can also be started from a GUI with KDE connect.
(The name is misleading, it works fine with Gnome too)
Available as a Gnome extension, and in Fdroid