Skip to content

Commit

Permalink
Support for different display numbers as envars
Browse files Browse the repository at this point in the history
Change-type: minor
Signed-off-by: Alex Bucknall <[email protected]>
  • Loading branch information
Bucknalla committed Dec 7, 2021
1 parent 19e35ad commit 78a68fe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ The following environment variables allow configuration of the `browser` block:
| Environment variable | Options | Default | Description |
| --- | --- | --- | --- |
|`LAUNCH_URL`|`http` or `https` URL|N\A|Web page to display|
|`DISPLAY_NUM`|`n`|0|Display number to use|
|`LOCAL_HTTP_DELAY`|Number (seconds)|0|Number of seconds to wait for a local HTTP service to start before trying to detect it|
|`KIOSK`|`0`, `1`|`0`|Run in kiosk mode with no menus or status bars. <br/> `0` = off, `1` = on|
|`SHOW_CURSOR`|`0`, `1`|`0`|Enables/disables the cursor when in kiosk mode<br/> `0` = off, `1` = on|
Expand Down
10 changes: 8 additions & 2 deletions src/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ echo "balenaBlocks browser version: $(<VERSION)"
echo "Setting CPU Scaling Governor to 'performance'"
echo 'performance' > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

#Set whether to show a cursor or not
# check if display number envar was set
if [[ -z "$DISPLAY_NUM" ]]
then
export DISPLAY_NUM=0
fi

# set whether to show a cursor or not
if [[ ! -z $SHOW_CURSOR ]] && [[ "$SHOW_CURSOR" -eq "1" ]]
then
export CURSOR=''
Expand Down Expand Up @@ -51,4 +57,4 @@ environment=$(env | grep -v -w '_' | awk -F= '{ st = index($0,"=");print substr(
environment="${environment::-1}"

# launch Chromium and whitelist the enVars so that they pass through to the su session
su -w $environment -c "export DISPLAY=:0 && startx /usr/src/app/startx.sh $CURSOR" - chromium
su -w $environment -c "export DISPLAY=:$DISPLAY_NUM && startx /usr/src/app/startx.sh $CURSOR" - chromium

0 comments on commit 78a68fe

Please sign in to comment.