After yesterdays post around using a remote desktop connection to connect from my Mac to my Pi I decided to add some cron jobs on the Pi so that it would reboot every night and after rebooting it would log in (automatically using raspi-config settings) and then fire me up a Terminal session and a web browser session.
A few lines:
* 2 * * * sudo reboot
#does the reboot at 2am
@reboot chromium-browser http://www.geektechstuff.com
#at reboot open Chromium and open this site
#at reboot open Terminal
But when I logged in via remote desktop neither Chromium or Terminal was open. I did a reboot manually. Same issue. At first I thought I was writing the cron line wrong. Then I did a little digging and came across some advice about adding DISPLAY=:0 after the @reboot but before the application name. I jumped to it and added DISPLAY=0: and rebooted thinking “this will sort it”, only to be greeted by a blank desktop space when I remote connected back.
Weird I thought. So I used terminal’s top command and there in the list of running processes is Chromium.
So what’s happening? The Raspbian OS uses startx to display a session desktop; most of the time this is DISPLAY:0 (the first desktop session created). Using echo $DISPLAY in terminal it quickly becomes apparent that I am not viewing DISPLAY:0 but I am viewing (at the time) DISPLAY:10.0 when remote connected.
Now to hog the TV and see if the applications do actually show on the Pi when not using Remote Desktop….