Skip to content

Commit

Permalink
kiosk
Browse files Browse the repository at this point in the history
  • Loading branch information
WebReflection committed Oct 30, 2023
1 parent 2699c99 commit 07e106a
Showing 1 changed file with 113 additions and 0 deletions.
113 changes: 113 additions & 0 deletions kiosk/base
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#!/usr/bin/env bash

if [ "$(whoami)" = "root" ] || [ "$USER" = "root" ]; then
echo 'You need to be a regular user to run this script'
exit 1
fi

if [ "$USER" = "" ]; then
USER="$(whoami)"
fi

kiosk() {
local wl=""
if [ "$(cat ~/.bashrc | grep -F '[archibold.io] weston')" = "" ]; then
echo '
# [archibold.io] weston
export KIOSK_WIDTH=1280
export KIOSK_HEIGHT=720
export KIOSK_OUTPUT=
export COG_PLATFORM_WL_VIEW_FULLSCREEN=1
setWestonMode() {
local MODE="$1"
local NAME=""
if [ -f ~/.config/weston.ini ]; then
sed -i "s/name=.*//;s/mode=.*//;/^$/d;s/\[/\n\[/" ~/.config/weston.ini
for NAME in $(ls /sys/class/drm | grep HDMI); do
if [ "$NAME" != "" ]; then
if [ "$KIOSK_OUTPUT" == "" ] || [ "$KIOSK_OUTPUT" == "${NAME:6}" ]; then
echo "name=${NAME:6}">>~/.config/weston.ini
echo "mode=${MODE}">>~/.config/weston.ini
# one output only
return
fi
fi
done
fi
}
if [[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && [ "$(pgrep --list-name weston)" = "" ]; then
setWestonMode "${KIOSK_WIDTH}x${KIOSK_HEIGHT}"
weston
fi
'>>~/.bashrc
fi

yes "$1" | su -c "
pacman-key --init
pacman-key --populate archlinuxarm
pacman -Syu --noconfirm
pacman -S --needed --noconfirm weston wpewebkit cpupower
echo 'governor=\"performance\"'>>/etc/default/cpupower
systemctl enable cpupower.service
systemctl start cpupower.service
groupadd weston 2> /dev/null
groupadd seat 2> /dev/null
usermod -a -G audio,games,lp,optical,power,render,scanner,seat,storage,video,weston,wheel ${USER}
if [ -f /boot/boot.txt ]; then
pacman -S --needed --noconfirm uboot-tools
sed -i 's/rootwait/rootwait quiet loglevel=0/' /boot/boot.txt
mkimage -T script -C none -n 'Raspberry Pi' -d /boot/boot.txt /boot/boot.scr
fi
if [ -f /boot/cmdline.txt ]; then
sed -i 's/rootwait/rootwait quiet loglevel=0/' /boot/cmdline.txt
fi
systemctl enable seatd
systemctl start seatd
"

wl="$(which weston 2> /dev/null)"
if [ "$wl" = "" ]; then
echo 'unable to complete weston kiosk installation'
exit 1
else
touch ~/.hushlogin
echo '
export HISTCONTROL=ignoredups:erasedups
shopt -s histappend
'>>~/.bashrc

echo '#!/usr/bin/env sh
weston-terminal --fullscreen'>~/.kiosk
chmod a+x .kiosk

mkdir -p ~/.config
echo "[core]
idle-time=0
repaint-window=15
require-input=false
[shell]
client=${HOME}/.kiosk
animation=none
close-animation=none
startup-animation=none
locking=false
[output]
name=
mode=
">~/.config/weston.ini
yes "$1" | su -c reboot
fi
}

source <(curl -s https://archibold.io/utils/ask-password)
kiosk "$(askPassword 'root password:')"

0 comments on commit 07e106a

Please sign in to comment.