A plea for help - x11vnc Autostart


12 posts
by DevonPaul » Sun Feb 10, 2013 5:58 pm
HELP! I have been at this for days and am giving up hope of ever finding a working solution. I have read just about every post I can find here and on other forums. I have followed a variety of instructions/methods. I have tried with autologin as pi and root.

No matter what I do, x11vnc will NOT autostart. I can open a terminal as pi or root and paste in the following and x11vnc works just fine (apart from the -noipv6 which still shows a stream of ipv6 errors during initialising).
Code: Select all
x11vnc -rfbauth /home/pi/.vnc/passwd -forever -noipv6 -display :0


My request - could someone upload a zipped .img file with x11vnc autostarting? Possibly with a link to the instructions they followed.

I know this is not a 'best solution' but I am at my wits end and am plain out of ideas.
User avatar
Posts: 26
Joined: Mon Jan 28, 2013 7:12 pm
by lewmur » Sun Feb 10, 2013 7:12 pm
DevonPaul wrote:HELP! I have been at this for days and am giving up hope of ever finding a working solution. I have read just about every post I can find here and on other forums. I have followed a variety of instructions/methods. I have tried with autologin as pi and root.

No matter what I do, x11vnc will NOT autostart. I can open a terminal as pi or root and paste in the following and x11vnc works just fine (apart from the -noipv6 which still shows a stream of ipv6 errors during initialising).
Code: Select all
x11vnc -rfbauth /home/pi/.vnc/passwd -forever -noipv6 -display :0


My request - could someone upload a zipped .img file with x11vnc autostarting? Possibly with a link to the instructions they followed.

I know this is not a 'best solution' but I am at my wits end and am plain out of ideas.
Don't panic. You just have to add your code to the right file. I don't recall the file offhand but if someone else doen't answer the question in the next few hours, I'll research it.
Last edited by lewmur on Sun Feb 10, 2013 7:23 pm, edited 1 time in total.
Posts: 282
Joined: Sun Dec 25, 2011 3:20 pm
by lewmur » Sun Feb 10, 2013 7:22 pm
DevonPaul wrote:HELP! I have been at this for days and am giving up hope of ever finding a working solution. I have read just about every post I can find here and on other forums. I have followed a variety of instructions/methods. I have tried with autologin as pi and root.

No matter what I do, x11vnc will NOT autostart. I can open a terminal as pi or root and paste in the following and x11vnc works just fine (apart from the -noipv6 which still shows a stream of ipv6 errors during initialising).
Code: Select all
x11vnc -rfbauth /home/pi/.vnc/passwd -forever -noipv6 -display :0


My request - could someone upload a zipped .img file with x11vnc autostarting? Possibly with a link to the instructions they followed.

I know this is not a 'best solution' but I am at my wits end and am plain out of ideas.
Don't panic. You just have to add your code to the right file. I don't recall the file offhand but if someone else doen't answer the question in the next few hours, I'll research it. I think it is /etc/rc.local
Posts: 282
Joined: Sun Dec 25, 2011 3:20 pm
by DevonPaul » Mon Feb 11, 2013 12:02 am
I think it is /etc/rc.local
Afraid not.

I added -o /home/pi/.vnc/vnclog.txt on a hunch. It reports XOpenDisplay (":0") failed.

I believe this is because rc.local is processed before X11 starts.
User avatar
Posts: 26
Joined: Mon Jan 28, 2013 7:12 pm
by topguy » Mon Feb 11, 2013 12:36 am
What you can do is make a script with two commands.

Code: Select all
#!/bin/bash
sleep 25
x11vnc -rfbauth /home/pi/.vnc/passwd -forever -noipv6 -display :0


You then call this script in local.rc with a '&' at the end, then the script will run in the background, it will take a 25 sec pause so the X can start and then run x11vnc.
Its not a pretty way of doing it but I think it would work.
User avatar
Posts: 509
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway
by DevonPaul » Mon Feb 11, 2013 1:16 am
No luck.

in/etc/rc.local I added
Code: Select all
/home/pi/.vnc/startvnc.sh &
in /home/pi/.vnc/startvnc.sh I have
Code: Select all
#!/bin/sh
sleep 25
x11vnc -rfbauth /home/pi/.vnc/passwd -forever -noipv6 -display :0 -o /home/pi/.vnc/vnclog.txt
chmod 755 startvnc.sh

Reboot, wait 30 sec after desktop appears, try to connect - nothing. Also - no vnclog.txt file created so I doubt it was run.

If I open a terminal as pi, cd .vnc and run ./startvnc.sh it runs properly so I doubt the problem is there.

rc.local is owned by root while startvnc.sh is owned by pi. Could that effect things?

Is there anywhere that errors would be logged? Doing this blind is extremely frustrating as an error log might point out something fixable.

01:40 in the UK - enough, time for some ZZZzzzzs and start fresh Monday.
User avatar
Posts: 26
Joined: Mon Jan 28, 2013 7:12 pm
by manxam » Mon Feb 11, 2013 6:06 am
You have a few options: You can create an .xsessionrc or an .xinitrc in your user 'pi' home folder with the x11vnc commands and it'll start upon X starting.

The other option is to create a directory under ~/.config/autostart if it doesn't already exist. In this folder create a file named 'x11vnc.desktop' with the following:
Code: Select all
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=X1VNC
Comment=
Exec=[i]x11vnc -whatever options you want to start x11vnc with...[/i]
StartupNotify=false
Terminal=false
Hidden=false
Posts: 22
Joined: Sat Feb 09, 2013 1:55 am
by manxam » Mon Feb 11, 2013 6:53 am
Apparently I can't use the italics code in the code block and I can't edit my post as it needed moderation first and too much time has passed. Ignore the "[ i ]" and "[ /i ]" in my post above :)
Posts: 22
Joined: Sat Feb 09, 2013 1:55 am
by DevonPaul » Mon Feb 11, 2013 9:48 am
Well, that was not fun.

I created the .xsessionrc and added the x11vnc command with parameters. Rebooted - black screen!

Should I have added #!/bin/sh as the first line?
Should I have marked the file as executable?

Do I now have to re-write the SD card and start again?

[Update]
I remembered that I can access from my PC using PuTTY. File deleted, reboot OK.
I will wait for a response before doing anything else.
User avatar
Posts: 26
Joined: Mon Jan 28, 2013 7:12 pm
by DevonPaul » Mon Feb 11, 2013 10:24 am
WOW!!!!

I have always been impatient :D

I decided to give the ~/.config/autostart/x11vnc.desktop route a try. I also made the file executable just in case.

IT WORKS!!!!

My RPi arrived exactly 1 week ago and this is the only thing I have been doing (4-5 hours each evening) since then. I thought I had tried this method before. I will now save an image so I can use it as a basic start in future.

THANK YOU.
User avatar
Posts: 26
Joined: Mon Jan 28, 2013 7:12 pm
by manxam » Mon Feb 11, 2013 5:02 pm
Glad to hear it all worked out. Other users have had issues with the black screen when running from xinitrc or sessionrc but I'm not certain why. Perhaps it's been initiated before LXDE? The autostart folder is read by the window manager after startup to it's initialized a little later in the chain.

Cheers!
Posts: 22
Joined: Sat Feb 09, 2013 1:55 am
by DevonPaul » Mon Feb 11, 2013 8:32 pm
I have made a minor change due to x11vnc sometimes not starting. I pointed the autostart command to the .vnc shell script. All seems stable now.
User avatar
Posts: 26
Joined: Mon Jan 28, 2013 7:12 pm