Page 1 of 2

Autostart with LXDE + VNC4 (SOLVED)

Posted: Tue Feb 06, 2018 11:11 pm
by Facel
What should I do in order to run on boot : LXDE (desktop environnement) + VNC4 in order to be able to connect to the Sparky from my PC via VNC Viewer (Sparky with no screen)

thanks for your help

Re: Autostart with LXDE + VNC4

Posted: Wed Feb 07, 2018 1:26 am
by WarHawk
# dietpi-launcher <-all selection list
or
# dietpi-software <-straight to software selection
*software optimized
select [ ] LXDE: ultra lightweight desktop
select [ ] VNC4 Server: desktop for remote connection
*Install

# dietpi-autostart
select Console: Manual login (default) to boot the board into headless mode

That should get you going

Re: Autostart with LXDE + VNC4

Posted: Wed Feb 07, 2018 11:50 am
by Facel
LXDE and VNC4 have already been installed.

#dietpi-autostart
I did not selected Console: Manual login (default) because I want to run LXDE + VNC4 automatically at boot whithout any
manual login.

In fact at boot I need to run JRiver (media center), and Jriver need LXDE for running.
When I select LXDE in #dietpi-autostart I have LXDE + Jriver running automatically at boot ... but I cannot
acces remotlly via VNC4.
VNC4 is needed only in the case I need to acces the Jriver application in order to modify some parameters.

I will try Console: Manual login (default) tonight but I am afraid it will not do the trick
I'll keep you informed

regards

Re: Autostart with LXDE + VNC4

Posted: Wed Feb 07, 2018 4:32 pm
by WarHawk
is VNC server running if you do a

# ps -A

?

Re: Autostart with LXDE + VNC4

Posted: Wed Feb 07, 2018 7:59 pm
by Facel
Please find below the result of #ps -A
I only have LXDE in the autostart dietpi-config
Jriver is started from LXDE as well as VNC - My problem is to automatically pass the different parameters to VNC in order to be properly running

PID TTY TIME CMD
1 ? 00:00:03 systemd
2 ? 00:00:00 kthreadd
3 ? 00:00:00 ksoftirqd/0
4 ? 00:00:01 kworker/0:0
5 ? 00:00:00 kworker/0:0H
6 ? 00:00:00 kworker/u8:0
7 ? 00:00:00 migration/0
8 ? 00:00:00 rcu_preempt
9 ? 00:00:00 rcu_bh
10 ? 00:00:00 rcu_sched
11 ? 00:00:00 migration/1
12 ? 00:00:00 ksoftirqd/1
13 ? 00:00:00 kworker/1:0
14 ? 00:00:00 kworker/1:0H
15 ? 00:00:00 migration/2
16 ? 00:00:00 ksoftirqd/2
17 ? 00:00:00 kworker/2:0
18 ? 00:00:00 kworker/2:0H
19 ? 00:00:00 migration/3
20 ? 00:00:00 ksoftirqd/3
21 ? 00:00:00 kworker/3:0
22 ? 00:00:00 kworker/3:0H
23 ? 00:00:00 khelper
24 ? 00:00:00 kdevtmpfs
25 ? 00:00:00 netns
26 ? 00:00:00 kworker/3:1
27 ? 00:00:00 kworker/0:1
28 ? 00:00:00 kworker/2:1
29 ? 00:00:00 kworker/1:1
30 ? 00:00:00 kworker/u8:1
51 ? 00:00:00 writeback
52 ? 00:00:00 bioset
53 ? 00:00:00 kblockd
54 ? 00:00:00 irq/215-atc2603
55 ? 00:00:00 b0200000.spi
56 ? 00:00:00 khubd
57 ? 00:00:00 ion_fb
58 ? 00:00:00 ion_system
59 ? 00:00:00 cfg80211
60 ? 00:00:00 cfinteractive
61 ? 00:00:00 rpciod
62 ? 00:00:00 khungtaskd
63 ? 00:00:00 kswapd0
64 ? 00:00:00 ksmd
65 ? 00:00:00 fsnotify_mark
66 ? 00:00:00 nfsiod
67 ? 00:00:00 cifsiod
68 ? 00:00:00 crypto
85 ? 00:00:00 atm705a-hdmi-hd
86 ? 00:00:00 aotg_start_mon_
87 ? 00:00:00 kpsmoused
88 ? 00:00:00 dm_bufio_cache
89 ? 00:00:00 host_add_work0
90 ? 00:00:00 host_add_work2
91 ? 00:00:00 binder
92 ? 00:00:00 kworker/0:2
93 ? 00:00:00 kworker/u8:2
94 ? 00:00:00 kworker/u8:3
95 ? 00:00:00 kworker/u8:4
96 ? 00:00:00 krfcommd
97 ? 00:00:04 mmcqd/0
98 ? 00:00:00 owlfb
99 ? 00:00:00 deferwq
100 ? 00:00:00 atc260x_charger
101 ? 00:00:00 usb_monitor
550 ? 00:00:00 kworker/2:1H
551 ? 00:00:00 kworker/1:1H
552 ? 00:00:00 kworker/3:1H
553 ? 00:00:00 kworker/0:1H
589 ? 00:00:00 jbd2/mmcblk0p2-
590 ? 00:00:00 ext4-dio-unwrit
633 ? 00:00:00 kworker/2:2
653 ? 00:00:00 atv5201-IRKEYPA
656 ? 00:00:00 kworker/3:2
657 ? 00:00:01 systemd-journal
662 ? 00:00:00 kauditd
682 ? 00:00:00 systemd-udevd
687 ? 00:00:00 kworker/1:2
821 ? 00:00:00 dbus-daemon
828 ? 00:00:00 kethernet_resum
829 ? 00:00:00 ethernet_work_q
830 ? 00:00:00 phy_detect_work
833 ? 00:00:00 atc260x_gauge_w
834 ? 00:00:00 systemd-logind
866 ? 00:00:00 aotg_dev0_onoff
867 ? 00:00:00 aotg_dev1_onoff
954 ? 00:00:00 sshd
1470 tty1 00:00:00 login
1471 ttyS3 00:00:00 agetty
1497 ? 00:00:00 systemd
1501 ? 00:00:00 (sd-pam)
1514 tty1 00:00:00 bash
1559 tty1 00:00:00 login
1704 ? 00:00:00 cron
1737 tty1 00:00:00 startx
1760 tty1 00:00:00 xinit
1761 tty1 00:00:03 Xorg
1770 ? 00:00:00 smbd
1772 tty1 00:00:00 lxsession
1773 ? 00:00:00 smbd-notifyd
1774 ? 00:00:00 cleanupd
1788 ? 00:00:00 lpqd
1807 tty1 00:00:00 dbus-launch
1808 ? 00:00:00 dbus-daemon
1815 ? 00:00:00 nmbd
1824 ? 00:00:00 ssh-agent
1849 ? 00:00:00 dhclient
1858 ? 00:00:00 lighttpd
1874 tty1 00:00:00 openbox
1877 tty1 00:00:00 lxpolkit
1887 tty1 00:00:01 lxpanel
1891 tty1 00:00:00 pcmanfm
1899 ? 00:00:00 php-fpm7.0
1910 ? 00:00:00 ssh-agent
1919 tty1 00:00:07 mediacenter23
1922 tty1 00:00:00 xcompmgr
1925 tty1 00:00:00 x11vnc
1937 ? 00:00:00 polkitd
1947 tty1 00:00:00 light-locker
1954 tty1 00:00:00 sh
1955 tty1 00:00:00 wish
1971 ? 00:00:00 dconf-service
1984 ? 00:00:00 menu-cached
2003 ? 00:00:00 php-fpm7.0
2004 ? 00:00:00 php-fpm7.0
2005 ? 00:00:00 php-fpm7.0
2006 ? 00:00:00 php-fpm7.0
2097 ? 00:00:00 mysqld_safe
2246 ? 00:00:00 mysqld
2247 ? 00:00:00 logger
2366 ? 00:00:00 mpd
2380 ? 00:00:00 avahi-daemon
2382 ? 00:00:00 avahi-daemon
2399 ? 00:00:00 shairport-sync
2422 ? 00:00:03 netdata
2463 ? 00:00:00 librespot
2499 ? 00:00:00 bash
2528 ? 00:00:02 apps.plugin
2530 ? 00:00:04 python
4714 ? 00:00:00 sshd
4730 pts/0 00:00:00 bash
4871 pts/0 00:00:00 ps

Re: Autostart with LXDE + VNC4

Posted: Thu Feb 08, 2018 2:30 am
by WarHawk
1925 tty1 00:00:00 x11vnc

looks like its active

Found this
https://askubuntu.com/questions/120973/ ... er-on-boot
you create the config file under /etc/init.d/x11vnc.conf and populate it with the correct commands to be executed

start on login-session-start
script
/usr/bin/x11vnc -xkb -auth
/var/run/lightdm/root/:0
-noxrecord -noxfixes -noxdamage
-rfbauth /etc/x11vnc.pass
-forever -bg -rfbport 5900 -o /var/log/x11vnc.log
end script

this too
https://superuser.com/questions/147109/ ... on-startup <- this looks like better scripting

Also this stood out
you'll need to run vncserver AT LEAST ONCE AS EACH USER you want to login as. I put that in caps because if you skip that step none of it will work

Re: Autostart with LXDE + VNC4

Posted: Thu Feb 08, 2018 7:44 am
by Facel
In order to get VNC starting automatically I have simply opened the X11 windows (with mouse +screen connected to the Sparky) and I did a "drag and drop" of the vnc application into the .config/autostart/ folder
This action created a file named : x11vnc.desktop with the following contend

[Desktop Entry]
Name=X11VNC Server
Comment=Share this desktop by VNC
Exec=x11vnc -gui tray=setpass -rfbport PROMPT -bg -o %%HOME/.x11vnc.log.%%VNCDI$
Icon=computer
Terminal=true
Type=Application
StartupNotify=false
#StartupWMClass=x11vnc_port_prompt
Categories=Network;RemoteAccess;
X-KeepTerminal=true

At boot I have a dialog windows opened by VNC that is asking for parameters in oder to finalise the VNC configuration.

Is it not possible to simply include theses parameters in the x11vnc.desktop file ?

Re: Autostart with LXDE + VNC4

Posted: Thu Feb 08, 2018 8:41 am
by WarHawk
run it once, don't start a x service...run xserver

Code: Select all

su - *user* -c "cd /home/*user*/ && vncserver :1 -geometry 1024x768 -depth 24" 2>/dev/null &
You can then put that command in /etc/rc.local

https://www.linuxquestions.org/question ... ost3214061

Re: Autostart with LXDE + VNC4

Posted: Thu Feb 08, 2018 11:11 am
by Facel
It is "almost working" ... with your solution ... the VNC Viewer connection (on my remote PC) is prompting the VNC authentification window where a password is needed.
I have create a password and have it stored in a new file at /home/dietpi/.vnc/passwd
I have modified your command line in /etc/rc.local by the following line:
su - dietpi -c "cd /home/dietpi/ && vncserver -rfbauth /home/dietpi/.vnc/passwd :1 -geometry 1024x768 -depth 24" 2>/dev/null &

but the result is the same ... error message in VNC Viewer : "No password configured for VNC Auth"

by the way I do not have any user (I believe) other than root... and in the home directory I only have a folder named dietpi

Re: Autostart with LXDE + VNC4

Posted: Thu Feb 08, 2018 12:02 pm
by WarHawk
You would have to create user dietpi for that

Code: Select all

# adduser dietpi
to make dietpi user a sudoer (so you can run sudo commands)

Code: Select all

# usermod -aG sudo dietpi
make sure /home/dietpi/.vnc/passwd is owned by dietpi:dietpi

Code: Select all

# chown -R dietpi:dietpi /home/dietpi 
Logout as root, log in as dietpi

Code: Select all

$ cd /home/dietpi/ && vncserver -rfbauth /home/dietpi/.vnc/passwd :1 -geometry 1024x768 -depth 24" 2>/dev/null &
That will start it once as "user" dietpi, which will ask you to generate a password

Correct command in /etc/rc.local would then be

Code: Select all

sudo  -u  dietpi 'cd /home/dietpi/ && vncserver :1 -geometry 1024x768 -depth 24' 2>/dev/null &
Since there is no user other than root...it will not work...create user dietpi, start server as dietpi, setup password as dietpi, run command in /etc/rc.local as root telling it to start vncserver as dietpi

Also check to ensure /etc/rc.local is executable...if not

Code: Select all

# chmod 755 /etc/rc.local