1

My problem is: my bluetooth keyboard won't work with my new android phone (big screen), but it does work with my old android phone (small screen).

So I'd like to connect the keyboard to my old phone and stream its keystrokes to my new phone; type there, look here.

I'd also like the actual session and files to be on the new phone - but I guess that's not essential. They could be on the old phone, and only the display is mirrored/cast to the new phone.

Seems to me:

  1. how to pipe input into one shell from another

  2. how to pipe input from one machine to another

I've tried: tmux screen mirroring over wifi, but latency is too high.

I'm mostly using vim, so something using that would work too.

Would bluetooth have lower latency than wifi? Can you have a keyboard and a hotspot over bluetooth at the same time? Not sure how to setup a bluetooth connection, and I guess the latency is elsewhere, probably in tmux.

It seems that getting low latency should be easy with two devices sitting next to each other...

Any ideas?

BTW: I've given up on connecting the kb and new phone; and reluctant to factory reset. I could get a new kb, but I like this one.

  • Why not you ssh to your old phone from your new phone, given they are on same network or reachable to each other via public internet or vpn . – mkmayank May 15 '18 at 11:32
  • @mkmayank Thanks fo the response! Although that would make the kb work, and would use files etc on the new phone, it would use the display of the old phone - I want to use the (bigger) display of the new phone... Is there a way for ssh to display what's happening on the new phone's display? – hyperpallium May 15 '18 at 12:20
  • @mkmayank Though I'd like to use the display on the new phone, I realized it could be convenient to use the new phone for results (graphics), and code on the old - sweet, dual-monitor phone! So I tried your suggestion, and surprisingly it still had latency, so it seems to be wifi (same with telnet). – hyperpallium May 16 '18 at 8:52
  • @mkmayank And it opened up other options: I could code locally (on old phone), and push to git on new phone, with a hook to compile and run it. Similar alternatives: send the src files, use vim's feature of local editing of a remote file, send the executable. So thanks very much for that! But my wifi idea really doesn't work for me. (maybe the latency is reasonable, and I'm just too sensitive to it). Maybe there's a bluetooth way... – hyperpallium May 16 '18 at 8:57
  • Welcome, if it helps, though I still doesn't get the context of phone here, what is phone , a mobile phone (which keeps ringing to distract me) or something else ? – mkmayank May 16 '18 at 9:21
0

Bluetooth has much lower latency than wifi. Lag is usually imperceptible.

Assumimg the bluetooth keyboard is connected to the old phone.

  1. bluetooth hotspot Setup bluetooth hotspot on one machine (Android 5.1: Settings->More->tethering and portable hotspot->bluetooth tethering); on the other mark that machine for "internet sharing" (Settings->Bluetooth->icon on right of other phone's name->use for: internet connection sharing) NOTE: you don't have actually be online; it works in airplane mode too

  2. ssh Connect with ssh: sshd -p 8080 on new phone, ssh ssh://192.168.44.40:8080 on old phone (if you set up the hotspot on the old phone, use ssh ssh://192.168.44.1:8080. It's .44. for bluetooth (for both), and .1 for the hotspot, .40 for the hotspot user.

Note: to stop sshd you have to find the sshd session (ps |grep sshd) and kill it. Or you can keep it in the foreground with -D, and end it with ^C. I'm obviously not up on ssh and there's probably a better way of doing it than that.

  1. tmux attach Finally, setup your tmux session however you normally do (just tmux will work). Now, because you're on the same machine, we can use the magic of tmux and attach to the same session: from the other machine, just type tmux attach. Now, both phones are connected to the same tmux session. You can type in either, and see the display in both.

tmux will show the same term size (cols by rows), and will shade the remainder as unusable on the larger screen. So, adjust the terminals to have the same cols x rows (in termux you can do this with a two-finger zoom, or with Ctrl Alt +/- (plus minus keys) https://termux.com/hardware-keyboard.html - BTW that page says "hardware keyboard", but the shortcut also work for touchscreen keyboard).

Now we can type on the old phone's bluetooth keyboard, and view on the new phone.


It can be confusing to use this setup, because only the terminal is sent to the other phone - android controls (e.g. the home key) still only work on the old phone.

There also seems to be issues with getting disconnected sometimes. I've only just tried it, but I expect all of these problems are standard tmux, ssh or bluetooth hotspot issues.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.