Skip to content

Commit

Permalink
Fix kiosk mode & add desktop app
Browse files Browse the repository at this point in the history
  • Loading branch information
zaneclaes committed Dec 17, 2020
1 parent 1b50594 commit e96bfaf
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ deploy:
file:
- "releases/*.*"
token:
secure: NFvrOvBDkBwvJWANXEbkRtrFE0msZF+269Q4VHWL44izsIF/uTooIPt5FlMBvsroiDunwA6Zs/kX8Nnrf/D1zePybNu9zf8JarJuCzZuu80pWSn2aJQHCqH6mKkprSa6BoqxnptJG7Qdr0e16FaSOiDNE68DRhFYztlLZynf4EdD6k40UkP0k+6+v1Wg6qkNNykexP6SZDOzDBTyOLH3KVYvQdTaaiNL6+B1/HYWVF+D+QwGQVp2/k7FDUkaPJMY+1FLmjGuu/5Snl6I9+HqOEkS0zyrob/9DDZx158KhrfnTfx4IKmACA9lGo1eVFb1ZngupA7VYp329kHd7FVYWFbY1lcc2FdBP74xhilzJ4S1wtvDL6FTRbwTai0B7/c0Tsad31e2/2zucldv7Xh2UAzeCv4SPyihFA7cMpzqXncRH9N/JTTArspn9fFXbGsvU1Xo+0GppMHO0PQf77vjUoT7v6wPyE5OYcd9n1/xrTNTX9mttBF864qYEi8gGdZXaIN5ziaVvmaeYXOFuFww+hmRFGuBlNGueTdsHndAKW8oxPKjcQziiTpjuoWokXjp7zg2UUp9F5azihHo1whPmjNNnzfC8Vu2OHgXb3Nj2ugm1NXMRhTKyRt6Lsa8rKL8ZW8J3WpD65Jcm0Wq42q9JfOOgVn/+vf0olKu5wGT0rc=
secure: "$GITHUB_TOKEN"
overwrite: true
name: "$RELEASE_NAME"
# Travis does not support multi-line change logs / formatting.
Expand Down
8 changes: 8 additions & 0 deletions bin/Makerverse.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Desktop Entry]
Type=Application
Name=Makerverse
Comment=Makerverse UI (web browser)
Icon=/home/pi/makerverse/logo.png
Exec=/home/pi/makerverse/bin/kiosk
Terminal=false
Categories=Internet;
30 changes: 24 additions & 6 deletions bin/kiosk
Original file line number Diff line number Diff line change
@@ -1,21 +1,39 @@
#!/bin/bash
path=${1:-/}

# Figure out where the git checkout directory lives, if any:
if [[ -z "$MAKERVERSE_SRC_DIR" ]]; then
# Otherwise, the parent directory of this script should (hopefully) work.
MAKERVERSE_SRC_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../" && pwd)"
fi

fn="${MAKERVERSE_SRC_DIR}/kiosk.log"
echo "Launching Makerverse kiosk..." > $fn
printenv | grep "MAKERVERSE" >> $fn

MAKERVERSE_PROTOCOL="${MAKERVERSE_PROTOCOL:-http}"
MAKERVERSE_HOST="${MAKERVERSE_HOST:-localhost}"
MAKERVERSE_PORT="${MAKERVERSE_PORT:-8000}"
MAKERVERSE_KIOSK_SCALE="${MAKERVERSE_KIOSK_SCALE:-1.0}"
url="${MAKERVERSE_PROTOCOL}://${MAKERVERSE_HOST}:${MAKERVERSE_PORT}${path}"
MAKERVERSE_PATH="${MAKERVERSE_PATH:-/}"
url="${MAKERVERSE_PROTOCOL}://${MAKERVERSE_HOST}:${MAKERVERSE_PORT}${MAKERVERSE_PATH}"
flags=""

if [[ ! -z "$MAKERVERSE_SCALE" ]]; then
flags="${flags} --force-device-scale-factor=${MAKERVERSE_SCALE}"
fi

if [[ ! -z "$MAKERVERSE_KIOSK" ]]; then
flags="${flags} --noerrdialogs --disable-infobars --kiosk"
fi

while [[ ! $(curl -s $url) ]]; do
echo "Waiting for $url"
echo "Waiting for $url" >> $fn
sleep 1;
done

bash ${MAKERVERSE_SRC_DIR}/scripts/kiosk.sh "$url" \
-f "--noerrdialogs --disable-infobars --ignore-certificate-errors --force-device-scale-factor=${MAKERVERSE_KIOSK_SCALE}"
echo "Ready to launch: ${flags}" >> $fn

if [[ ! -z "${flags}" ]]; then
bash ${MAKERVERSE_SRC_DIR}/scripts/kiosk.sh "$url" -f "${flags}"
else
bash ${MAKERVERSE_SRC_DIR}/scripts/kiosk.sh "$url"
fi
6 changes: 4 additions & 2 deletions ci/raspbian-desktop.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
["mkdir", "$MOUNTPOINT/home/pi/makerverse/commands"],
["mkdir", "$MOUNTPOINT/home/pi/makerverse/events"],
["mkdir", "$MOUNTPOINT/home/pi/makerverse/widgets"],
["cp", "/build/docs/assets/logo.png", "$MOUNTPOINT/home/pi/makerverse/logo.png"],
["cp", "/build/bin/Makerverse.desktop", "$MOUNTPOINT/usr/share/applications/Makerverse.desktop"],
["cp", "/build/.makerverse.docker", "$MOUNTPOINT/home/pi/.makerverse"],
["cp", "/build/scripts/gpio.sh", "$MOUNTPOINT/home/pi/makerverse/commands/gpio.sh"],
["cp", "-r", "/build/bin", "$MOUNTPOINT/home/pi/makerverse/"],
Expand Down Expand Up @@ -86,8 +88,8 @@
"sudo usermod -aG docker pi",
"sudo systemctl enable docker",
"sudo systemctl start docker",
"cd /home/pi/makerverse && bash bin/build-service.sh install pi \"export MAKERVERSE_PORT=80\"",
"echo \"export MAKERVERSE_PORT=80\" >> /home/pi/.bashrc"
"echo \"MAKERVERSE_PORT=80\" >> /etc/environment",
"cd /home/pi/makerverse && bash bin/build-service.sh install pi \"export MAKERVERSE_PORT=80\""
]
}
]
Expand Down
1 change: 1 addition & 0 deletions ci/raspbian-lite.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"sudo usermod -aG docker pi",
"sudo systemctl enable docker",
"sudo systemctl start docker",
"echo \"MAKERVERSE_PORT=80\" >> /etc/environment",
"cd /home/pi/makerverse && bash bin/build-service.sh install pi \"export MAKERVERSE_PORT=80\""
]
}
Expand Down
16 changes: 11 additions & 5 deletions docs/installation/web-server/raspberry-pi.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ There are two download options in the [Latest Release](https://github.com/makerm

These are merely customized versions of [the official Raspberry Pi OS images of the same names](https://www.raspberrypi.org/downloads/raspberry-pi-os/) (Lite vs. Desktop). Once you have downloaded the appropriate release file, unzip it and flash the `.img` to your SD card with your preferred application (e.g., Balena Etcher).

_**Note**: the `lite` image means that there is no GUI! It is "command-line only" (headless), so everything will be text based (no desktop)._

Then, just plug the RPi in and power it up!

## Connecting to the RPi
Expand Down Expand Up @@ -79,22 +81,26 @@ However, this UI is not the default UI because it is much less full-featured (it

When running the `makerverse-raspberrypi-os-dekstop.**` (desktop version), you will need to follow on-screen instructions after the first boot to configure your Raspberry Pi. This image is based upon a standard Raspberry Pi OS Desktop installation, so please refer to the official documentation for any help.

You can open a web browser and navigate to Makerverse at `http://localhost`. Or, you can enable Kiosk mode...
You can find the Makerverse "application" in the "Other" section of the start menu. In fact, the "application" really just opens a web browser to `http://localhost`.

### Kiosk Mode

When running the "Desktop" variation, you can enable Kiosk mode:
When running the Desktop variation, you can enable "Kiosk" mode. This turn your Raspberry Pi into a dedicated Makerverse device.

_**Note**: kiosk mode causes Makerverse to run full-screen and effectively disable the Raspberry Pi desktop. It is best suited for scenarios where you only want to use Makerverse on the Raspberry Pi (single-purpose device). It also can fit more on the screen, and doesn't require a keyboard/mouse to use (e.g., touchscreen)._

To enable Kiosk mode, run the following command:

```
echo "@bash /home/pi/makerverse/bin/kiosk /" > /home/pi/.config/lxsession/LXDE-pi/autostart
echo "@bash /home/pi/makerverse/bin/kiosk" > /home/pi/.config/lxsession/LXDE-pi/autostart
```

Once configured, it will automatically launch Chromium in "Kiosk" mode during boot. This will load the Makerverse application in a full-screen web browser. Makerverse is still running as a Web Server in the background, so other clients can also simultaneously connect. In this mode, Chromium takes over the desktop, hiding all menus in order to maximize screen-space.
... and then reboot the Raspberry Pi. Once it has rebooted, you should notice that the normal desktop does not open. Instead, the screen stays black while Makerverse starts. Makerverse is still running as a Web Server in the background, so other clients can also simultaneously connect. In this mode, Chromium takes over the desktop, hiding all menus in order to maximize screen-space.

- If your keyboard/mouse are attached directly to the Pi, use the `Alt + F4` hotkey to close the full-screen web browser, and/or `Ctrl + Alt + T` to open a terminal.
- If you don't have an extra keyboard/mouse, just SSH and use `sudo raspi-config` to turn on the VNC in `Interfacing Options`. Then use an app like VNC Viewer to connect from your computer.

_**Note**: if your screen is smaller than 7" or so, you will likely want your Kiosk to use the Tablet UI specified above. To do so, edit the `/home/pi/.config/lxsession/LXDE-pi/autostart` file to become: `@bash /home/pi/makerverse/bin/kiosk /tablet`._
_**Note**: if your screen is smaller than 7" or so, you will likely want your Kiosk to use the Tablet UI specified above. To do so, use `sudo nano /etc/environment` to add the new line: `MAKERVERSE_PATH=/tablet`._

## Shared Directories

Expand Down
24 changes: 24 additions & 0 deletions docs/machines/cnc/grbl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
layout: default
title: Grbl
grand_parent: Machines
parent: CNC
nav_order: 1
---

# Grbl

Grbl is an extremely common firmware/protocol option for CNC machines.

Many manufacturers simply ship their CNC machines with Grbl, as it is such a well-known open-source (free) piece of Arduino code. If you're not sure what controller your CNC machine uses, chances are pretty good it uses Grbl.

## Grbl Versions

Find all versions on the [Grbl releases page](https://github.com/gnea/grbl/releases).

- Major versions of Grbl are `1.1h`, `1.1g`, etc.
- Minor versions are designated by the date of the release (`20190825` was released on August 25th, 2019).

## Updating Grbl

Please see [the Github README for Grbl](https://github.com/gnea/grbl).
2 changes: 1 addition & 1 deletion docs/machines/cnc/maslow.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ layout: default
title: Maslow
grand_parent: Machines
parent: CNC
nav_order: 1
nav_order: 2
---

# Maslow
Expand Down
16 changes: 14 additions & 2 deletions scripts/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ DOCKER_REPO="makerverse/core"

echo "Docker '$@' for $BUILD_PLATFORMS"

TAG2=""

if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ]; then
if [ "$1" = "build" ]; then
# Master branch has a deploy step. Others use the build as the deploy.
Expand All @@ -19,6 +21,7 @@ if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ]; then
TAG="prerelease"
else
TAG="latest"
TAG2="prerelease"
fi
else
if [ "$TRAVIS_BRANCH" = "master" ]; then
Expand All @@ -38,9 +41,18 @@ echo "Logged in to Docker."
# n.b., this ALWAYS pushes the resulting image. This is because the --load flag does not
# support multi-arch. https://github.com/docker/buildx/issues/59
if [[ ! -z "$CI_VERSION" ]]; then
docker buildx build --push "--platform=$BUILD_PLATFORMS" -t "$DOCKER_REPO:$TAG" -t "$DOCKER_REPO:v$CI_VERSION" .
if [[ -z "$TAG2" ]]; then
docker buildx build --push "--platform=$BUILD_PLATFORMS" -t "$DOCKER_REPO:$TAG" -t "$DOCKER_REPO:v$CI_VERSION" .
else
docker buildx build --push "--platform=$BUILD_PLATFORMS" -t "$DOCKER_REPO:$TAG" \
-t "$DOCKER_REPO:$TAG2" -t "$DOCKER_REPO:v$CI_VERSION" .
fi
else
docker buildx build --push "--platform=$BUILD_PLATFORMS" -t "$DOCKER_REPO:$TAG" .
if [[ -z "$TAG2" ]]; then
docker buildx build --push "--platform=$BUILD_PLATFORMS" -t "$DOCKER_REPO:$TAG" .
else
docker buildx build --push "--platform=$BUILD_PLATFORMS" -t "$DOCKER_REPO:$TAG" -t "$DOCKER_REPO:$TAG2" .
fi
fi

if [ $? -eq 0 ]; then
Expand Down
2 changes: 1 addition & 1 deletion scripts/kiosk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ assign_positional_args 1 "${_positionals[@]}"
sed -i 's/"exited_cleanly": false/"exited_cleanly": true/' ~/.config/chromium/Default/Preferences

# Start chromium
cmd="/usr/bin/chromium-browser $_arg_chromium_flags --kiosk --app=$_arg_kiosk_url"
cmd="/usr/bin/chromium-browser $_arg_chromium_flags --app=$_arg_kiosk_url"
echo "Opening chromium: $cmd"
$cmd &

Expand Down
2 changes: 1 addition & 1 deletion src/app/lib/ows/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import machines from './machines';
export default {
api,
machines,
};
};
7 changes: 0 additions & 7 deletions src/app/widgets/Macro/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import classNames from 'classnames';
import PropTypes from 'prop-types';
import get from 'lodash/get';
import includes from 'lodash/includes';
import React, { PureComponent } from 'react';
import api from 'app/api';
import Space from 'app/components/Space';
Expand All @@ -10,17 +8,12 @@ import Workspaces from 'app/lib/workspaces';
import i18n from 'app/lib/i18n';
import log from 'app/lib/log';
import analytics from 'app/lib/analytics';
import ActiveState from 'app/lib/active-state';
import WidgetConfig from '../WidgetConfig';
import Macro from './Macro';
import AddMacro from './AddMacro';
import EditMacro from './EditMacro';
import RunMacro from './RunMacro';
import {
// Grbl
GRBL,
// Marlin
MARLIN,
// Workflow
WORKFLOW_STATE_RUNNING
} from '../../constants';
Expand Down

0 comments on commit e96bfaf

Please sign in to comment.