We help IT Professionals succeed at work.

Need to run chromium browser on startup

Zeke Rich
Zeke Rich asked
on
I just installed linux 2019-09-26-raspbian-buster-lite for Raspberry Pi (headless)

 I need to to run chromium browser on startup. I have installed:

xserver-xorg xinit
chromium-browser
unclutter //to hide the cursor/pointer

I have created a file on my home directory called: ~/.xinitrc
with:
#!/bin/sh
xset -dpms
xset s off
xset s noblank

unclutter &
chromium-browser /path/to/your/file.html --window-size=1920,1080 --start-fullscreen --kiosk --incognito --noerrdialogs --disable-translate --no-first-run --fast --fast-start --disable-infobars --disable-features=TranslateUI --disk-cache-dir=/dev/null  --password-store=basic

Open in new window


I have added startx & to my rc.local

I cant get chromium to start on boot.
Comment
Watch Question

CERTIFIED EXPERT

Commented:
@Zeke Rich

Comments given after executing following script
$ cat ./29176469.sh
#!/bin/sh
export PS4='$0 $LINENO: '
if [ -z "$DISPLAY" ]
then
	echo -e "----------- PREVIOUS_ERROR1 ----------\nExecute $0 only at GUI mode.\nExecuting at CHUI mode not allowed." >> ~/HandleError.txt
	echo "cat ~/HandleError.txt"
	cat ~/HandleError.txt
else
	xset -dpms
	xset s off
	xset s noblank
	type "unclutter" >/dev/null 2>&1
	if [ 0 -eq $? ]
	then
		unclutter &
		type chromium-browser >/dev/null 2>&1
		if [ 0 -eq $? ]
		then
			chromium-browser /path/to/your/file.html --window-size=1920,1080 --start-fullscreen --kiosk --incognito --noerrdialogs --disable-translate --no-first-run --fast --fast-start --disable-infobars --disable-features=TranslateUI --disk-cache-dir=/dev/null  --password-store=basic
		else
			echo "----------- PREVIOUS_ERROR2 ----------" >> ~/HandleError.txt
			date >> ~/HandleError.txt
			echo "type chromium-browser" >> ~/HandleError.txt
			type "chromium-browser" >> ~/HandleError.txt 2>&1
			echo "cat ~/HandleError.txt"
			cat ~/HandleError.txt
		fi
	else
		echo "----------- PREVIOUS_ERROR3 ----------" >> ~/HandleError.txt
		date >> ~/HandleError.txt
		echo "type unclutter" >> ~/HandleError.txt
		type unclutter >> ~/HandleError.txt 2>&1
		echo "cat ~/HandleError.txt"
		cat ~/HandleError.txt
	fi
fi

Open in new window


Example output using putty.exe
$ ./29176469.sh
cat ~/HandleError.txt
----------- PREVIOUS_ERROR1 ----------
Execute ./29176469.sh only at GUI mode.
Executing at CHUI mode not allowed.

Open in new window


Output using GUI:
$ ./29176469.sh
cat ~/HandleError.txt
----------- PREVIOUS_ERROR1 ----------
Execute ./29176469.sh only at GUI mode.
Executing at CHUI mode not allowed.
----------- PREVIOUS_ERROR3 ----------
Tue Mar 24 05:41:25 GMT 2020
type unclutter
./29176469.sh: line 32: type: unclutter: not found

Open in new window


I am not having unclutter
Sample testing using touch command at GUI:
$ touch ./unclutter
$ chmod a+x  ./unclutter
$ ./29176469.sh
$ cat ~/HandleError.txt
----------- PREVIOUS_ERROR1 ----------
Execute ./29176469.sh only at GUI mode.
Executing at CHUI mode not allowed.
----------- PREVIOUS_ERROR3 ----------
Tue Mar 24 05:41:25 GMT 2020
type unclutter
./29176469.sh: line 32: type: unclutter: not found
----------- PREVIOUS_ERROR2 ----------
Tue Mar 24 05:42:00 GMT 2020
type chromium-browser
./29176469.sh: line 24: type: chromium-browser: not found
$

Open in new window


Hence try the same at your OS.
Owner
Commented:
I found the problem was I was logged in as root. Chromium doesnt want to run as root@raspberrypi
CERTIFIED EXPERT

Commented:
@Zeke Rich

wc
and thank you for sharing the same across the readers at Earth :)