23

I want to use the Screen Sharing OSx built-in App to manipulate the actual X session open in my Raspberry PI.

Just to be clear I want to see in my VNC session the same image the Raspberry is sending through the HDMI. So I can move the mouse in my computer and the cursor is also moving in the Raspberry screen.

I have tried several combinations of vnc-servers and configs but neither have worked.

fguillen
  • 36,125
  • 23
  • 149
  • 210
  • 1
    hi! vote up the question so it is not deleted. I worked hard in my answer below: http://stackoverflow.com/a/32361133/316700 ;) – fguillen Dec 01 '16 at 15:01

2 Answers2

40

As I have spent several hours solving this I so answer my self in case someone needs the instructions as I would wanted to find them.

First, the most popular vnc-server (tightvncserver) is not fullfilling my specification that the X-session has to be the same in my VNC client App and in the Raspberry screen.

The vnc-server that does the work is x11vnc

Install x11vnc

sudo apt-get install x11vnc

Looks like it requires you to set up a password:

x11vnc -storepasswd

Test installation and connection

You can already start the vnc-server:

x11vnc -forever -usepw -display :0 -ultrafilexfer

Check the service is active and listening

$ sudo netstat -nlp | grep vnc
tcp        0      0 0.0.0.0:5900            0.0.0.0:*               LISTEN      2575/x11vnc  

And connect from your Mac just opening Screen Sharing and introducing the Raspberry's ip:

enter image description here

Make x11vnc to start on boot

Config:

# ~/.config/autostart/x11vnc.desktop
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=X11VNC
Comment=
Exec=x11vnc -forever -usepw -display :0 -ultrafilexfer
StartupNotify=false
Terminal=false
Hidden=false

Be sure there is not problems to access to this file:

sudo chmod a+r ~/.config/autostart/x11vnc.desktop

Make the Raspberry to be visible in the sharing network of the Mac

sudo apt-get install netatalk
sudo apt-get install avahi-daemon
sudo update-rc.d avahi-daemon defaults

Config:

# /etc/avahi/services/afpd.service
<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
   <name replace-wildcards="yes">%h</name>
   <service>
      <type>_afpovertcp._tcp</type>
      <port>548</port>
   </service>
</service-group>

Config 2:

# /etc/avahi/services/rfb.service
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
  <name replace-wildcards="yes">%h</name>
  <service>
    <type>_rfb._tcp</type>
    <port>5900</port>
  </service>
</service-group>

Restart service:

sudo /etc/init.d/avahi-daemon restart

Finding the Raspberry from your Mac

Using Finder into the section Shared > All... should be your Raspberry. From there you can click in the button Share Screen...

enter image description here

fguillen
  • 36,125
  • 23
  • 149
  • 210
  • If you have comments to improve this manual please don't hesitate to suggest them. I have the feeling that the step installing `netatalk` and the file `/etc/avahi/services/rfb.service` is not necessary I think is something I did when I wast trying with `tightvncserver`. – fguillen Sep 02 '15 at 19:06
  • Nice one Fernando! (+1). I was already using avahi and both x11vc and vnc4server options. What I liked about x11vnc is it shows the main session with the main desktop (wheres as other severs I've tried, including tightvnc, seem to use a different desktop/screen). x11vnc feels a bit slower than vnc4server to me (I might be wrong). seeing GLES through X11 would be great ! – George Profenza Sep 03 '15 at 05:26
  • One recommendation: if any of the steps is not working try to [turn the Raspberry off and on again](https://community.rackspace.com/cfs-file.ashx/__key/communityserver-discussions-components-files/28/have_2D00_you_2D00_tried1.jpg) not kidding ;) – fguillen Sep 03 '15 at 11:23
  • I'm getting '# ~/.config/autostart/x11vnc.desktop doesn't exist' warnings – do i have to expand storage first or anything in particular to access before the home folder? – Andrew Lazarus Apr 12 '16 at 09:51
4

I found this post useful however I had to go looking for the following information to complete my setup - hope this help someone else

Just want to clarify the you need to do the following steps:

  • cd ~/.config/
  • mkdir autostart
  • nano x11vnc.desktop

and then paste code listed above

then you may also want to change the resolution by setting or uncommenting, the following lines, in /boot/config.txt:

hdmi_force_hotplug=1
hdmi_group=1
hdmi_mode=16 # (or any other pi resolution you want, 16 is for 1080p) Reboot your Pi (sudo reboot)
Kevin Lemaire
  • 949
  • 2
  • 12
  • 36
jd11
  • 41
  • 3