robing
Posts: 3
Joined: Thu Jan 25, 2018 10:34 am

Re: VNC server in Jessie (using a systemd service)

Mon Jan 29, 2018 9:18 am

Thanks to everyone who responded! Have learned the hard way that VNC won't be much fun for configuring the device the way I plan to use it. But I've put TightVNC on there in any event.

What I've also learned is that whatever Raspi-Config says, you can't enable VNC on boot without TightVNC. RealVNC won't work.

On to the next stage in my project! :D

notorious.dds
Posts: 4
Joined: Tue Jun 30, 2015 1:20 am

Re: VNC server in Jessie (using a systemd service)

Sat Oct 26, 2019 4:43 pm

I realize that I'm necroing this thread, but here goes...

I like to have mulitple VNC displays running at any giving time so that I can connect at varying resolutions. Back with init.d, I could accomplish this with one init.d script. I figured out how to replicate the solution using systemd (thanks to this thread and some additional troubleshooting), although it required mulitple scripts for me to do so. (A better person that I may be able to do this with greater elegance.)

At any rate, here's what I did:

I needed to create one "tightvncserver.target" script and many "tightvncserver-X.service" scripts.

My /etc/systemd/system/tightvncserver.target file looks like this:

Code: Select all

[Install]
WantedBy=multi-user.target

[Unit]
Description=tightvncserver target
Requires=multi-user.target
After=multi-user.target
AllowIsolate=yes
and each of my /etc/systemd/system/tightvncserver-X.service (replace "X" with a something unique for each display) files look something like:

Code: Select all

[Unit]
Description=TightVNCServer :9
PartOf=tightvncserver.target

[Service]
Type=forking
User=pi
PIDFile=/home/pi/.vnc/%H:9.pid
PAMName=login
ExecStartPre=-/usr/bin/vncserver -kill :2 > /dev/null 2>&1
ExecStart=/usr/bin/tightvncserver :9 -geometry 1280x790 -depth 16
ExecStop=/usr/bin/vncserver -kill :9
Restart=on-failure

[Install]
WantedBy=tightvncserver.target
I then enabled the .target script and all of the .service scripts using the:

Code: Select all

sudo systemctl enable *****
command for each of the files I created.

Now, I can run

Code: Select all

sudo systemctl start/stop/restart tightvncserver.target
and all displays are affected.

Voila!

User avatar
rin67630
Posts: 615
Joined: Fri Mar 04, 2016 10:15 am

Re: VNC server in Jessie (using a systemd service)

Sun Oct 27, 2019 11:34 am

notorious.dds wrote:
Sat Oct 26, 2019 4:43 pm
I like to have multiple VNC displays running at any giving time so that I can connect at varying resolutions.
If connecting at varying resolutions is your main concern, you may want to try XRDP.
XRDP "builds the picture up" at client side within the remote desktop functionality. You may define and use dynamically any resolution, without changing anything on the Pi.

bls
Posts: 291
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA

Re: VNC server in Jessie (using a systemd service)

Sun Oct 27, 2019 11:46 pm

Like @notorious.dds I like to have multiple VNC displays running with different resolutions. I wrote up a detailed how to on how to implement it using systemd with either TigerVNC or TightVNC. You can find it at https://github.com/gitbls/RPiVNCHowTo.

Return to “Raspbian”