N/A
This commit is contained in:
@@ -4,7 +4,7 @@ set -Eeuo pipefail
|
|||||||
# Fikakassan kiosk setup - V5
|
# Fikakassan kiosk setup - V5
|
||||||
# Debian 13 / X11 / Openbox / Chromium / NetworkManager
|
# Debian 13 / X11 / Openbox / Chromium / NetworkManager
|
||||||
#
|
#
|
||||||
# V5 adds automatic display + touchscreen rotation using iio-sensor-proxy.
|
# V6 fixes touchscreen device detection and reuses saved Wi-Fi profiles using iio-sensor-proxy.
|
||||||
# It is designed to be rerunnable on an already partially configured V4 host.
|
# It is designed to be rerunnable on an already partially configured V4 host.
|
||||||
|
|
||||||
KIOSK_USER="${KIOSK_USER:-joakim}"
|
KIOSK_USER="${KIOSK_USER:-joakim}"
|
||||||
@@ -26,14 +26,6 @@ SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
|||||||
[[ -f "$SCRIPT_DIR/app/main.py" ]] || die "app/main.py saknas. Kör skriptet från Fikakassans projektkatalog."
|
[[ -f "$SCRIPT_DIR/app/main.py" ]] || die "app/main.py saknas. Kör skriptet från Fikakassans projektkatalog."
|
||||||
[[ -f "$SCRIPT_DIR/requirements.txt" ]] || die "requirements.txt saknas."
|
[[ -f "$SCRIPT_DIR/requirements.txt" ]] || die "requirements.txt saknas."
|
||||||
|
|
||||||
if [[ -z "$WIFI_SSID" ]]; then
|
|
||||||
read -r -p "Wi-Fi SSID för Samsung A50-hotspot: " WIFI_SSID
|
|
||||||
fi
|
|
||||||
if [[ -z "$WIFI_PASSWORD" ]]; then
|
|
||||||
read -r -s -p "Wi-Fi-lösenord: " WIFI_PASSWORD
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
|
|
||||||
log "Installerar systempaket"
|
log "Installerar systempaket"
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
apt-get update
|
apt-get update
|
||||||
@@ -62,6 +54,35 @@ systemctl enable ssh.service
|
|||||||
systemctl enable nftables.service
|
systemctl enable nftables.service
|
||||||
systemctl enable systemd-timesyncd.service || true
|
systemctl enable systemd-timesyncd.service || true
|
||||||
|
|
||||||
|
# Reuse an existing NetworkManager Wi-Fi profile whenever possible.
|
||||||
|
# Only ask for SSID/password if no suitable saved profile exists.
|
||||||
|
WIFI_PROFILE_EXISTS=0
|
||||||
|
if nmcli -t -f NAME,TYPE connection show 2>/dev/null | awk -F: -v n="$WIFI_CONNECTION" '$1 == n && $2 == "802-11-wireless" {found=1} END{exit !found}'; then
|
||||||
|
WIFI_PROFILE_EXISTS=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$WIFI_SSID" && "$WIFI_PROFILE_EXISTS" == "1" ]]; then
|
||||||
|
WIFI_SSID="$(nmcli -g 802-11-wireless.ssid connection show "$WIFI_CONNECTION" 2>/dev/null || true)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If no named profile exists, reuse the currently active Wi-Fi profile.
|
||||||
|
if [[ -z "$WIFI_SSID" ]]; then
|
||||||
|
ACTIVE_WIFI_PROFILE="$(nmcli -t -f NAME,TYPE connection show --active 2>/dev/null | awk -F: '$2 == "802-11-wireless" {print $1; exit}')"
|
||||||
|
if [[ -n "$ACTIVE_WIFI_PROFILE" ]]; then
|
||||||
|
WIFI_CONNECTION="$ACTIVE_WIFI_PROFILE"
|
||||||
|
WIFI_PROFILE_EXISTS=1
|
||||||
|
WIFI_SSID="$(nmcli -g 802-11-wireless.ssid connection show "$WIFI_CONNECTION" 2>/dev/null || true)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$WIFI_SSID" ]]; then
|
||||||
|
read -r -p "Wi-Fi SSID för Samsung A50-hotspot: " WIFI_SSID
|
||||||
|
fi
|
||||||
|
if [[ "$WIFI_PROFILE_EXISTS" == "0" && -z "$WIFI_PASSWORD" ]]; then
|
||||||
|
read -r -s -p "Wi-Fi-lösenord: " WIFI_PASSWORD
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
|
||||||
log "Kontrollerar kiosk-användare"
|
log "Kontrollerar kiosk-användare"
|
||||||
id "$KIOSK_USER" >/dev/null 2>&1 || die "Användaren '$KIOSK_USER' finns inte."
|
id "$KIOSK_USER" >/dev/null 2>&1 || die "Användaren '$KIOSK_USER' finns inte."
|
||||||
usermod -s /bin/bash "$KIOSK_USER"
|
usermod -s /bin/bash "$KIOSK_USER"
|
||||||
@@ -118,7 +139,10 @@ systemctl enable --now NetworkManager.service
|
|||||||
nmcli radio wifi on
|
nmcli radio wifi on
|
||||||
WIFI_IF="$(nmcli -t -f DEVICE,TYPE device status | awk -F: '$2 == "wifi" {print $1; exit}')"
|
WIFI_IF="$(nmcli -t -f DEVICE,TYPE device status | awk -F: '$2 == "wifi" {print $1; exit}')"
|
||||||
[[ -n "$WIFI_IF" ]] || die "Hittade inget Wi-Fi-interface."
|
[[ -n "$WIFI_IF" ]] || die "Hittade inget Wi-Fi-interface."
|
||||||
nmcli connection delete "$WIFI_CONNECTION" >/dev/null 2>&1 || true
|
|
||||||
|
if [[ "$WIFI_PROFILE_EXISTS" == "1" ]]; then
|
||||||
|
log "Återanvänder sparad Wi-Fi-profil '$WIFI_CONNECTION'"
|
||||||
|
else
|
||||||
nmcli connection add type wifi \
|
nmcli connection add type wifi \
|
||||||
ifname "$WIFI_IF" \
|
ifname "$WIFI_IF" \
|
||||||
con-name "$WIFI_CONNECTION" \
|
con-name "$WIFI_CONNECTION" \
|
||||||
@@ -129,6 +153,8 @@ nmcli connection add type wifi \
|
|||||||
ipv4.never-default yes \
|
ipv4.never-default yes \
|
||||||
ipv4.route-metric 600 \
|
ipv4.route-metric 600 \
|
||||||
ipv6.method disabled >/dev/null
|
ipv6.method disabled >/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
nmcli connection modify "$WIFI_CONNECTION" \
|
nmcli connection modify "$WIFI_CONNECTION" \
|
||||||
connection.autoconnect yes \
|
connection.autoconnect yes \
|
||||||
connection.autoconnect-retries 0 \
|
connection.autoconnect-retries 0 \
|
||||||
@@ -262,14 +288,7 @@ get_output() {
|
|||||||
|
|
||||||
set_touch_matrix() {
|
set_touch_matrix() {
|
||||||
orientation="$1"
|
orientation="$1"
|
||||||
# Find likely touchscreen devices. Some X1 Yoga revisions expose names
|
|
||||||
# containing ELAN, Wacom or Touchscreen.
|
|
||||||
for id in $(xinput --list --id-only 2>/dev/null); do
|
|
||||||
name="$(xinput --list --name-only 2>/dev/null | sed -n "${id}p" 2>/dev/null || true)"
|
|
||||||
props="$(xinput list-props "$id" 2>/dev/null || true)"
|
|
||||||
if printf '%s\n' "$props" | grep -qi 'Coordinate Transformation Matrix'; then
|
|
||||||
label="$(xinput list --name-only 2>/dev/null | head -n "$((id + 1))" | tail -n 1 2>/dev/null || true)"
|
|
||||||
if printf '%s\n%s\n' "$name" "$label" | grep -Eqi 'touchscreen|touch screen|ELAN|Wacom|Touch'; then
|
|
||||||
case "$orientation" in
|
case "$orientation" in
|
||||||
normal|undefined)
|
normal|undefined)
|
||||||
matrix='1 0 0 0 1 0 0 0 1' ;;
|
matrix='1 0 0 0 1 0 0 0 1' ;;
|
||||||
@@ -282,9 +301,21 @@ set_touch_matrix() {
|
|||||||
*)
|
*)
|
||||||
matrix='1 0 0 0 1 0 0 0 1' ;;
|
matrix='1 0 0 0 1 0 0 0 1' ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# V5 tried to map device IDs to --name-only output by line number.
|
||||||
|
# That is not valid: xinput IDs are not array indexes. V6 instead gets
|
||||||
|
# the actual device name for every ID and only changes real touch devices.
|
||||||
|
xinput --list --id-only 2>/dev/null | while IFS= read -r id; do
|
||||||
|
[ -n "$id" ] || continue
|
||||||
|
info="$(xinput list "$id" 2>/dev/null || true)"
|
||||||
|
props="$(xinput list-props "$id" 2>/dev/null || true)"
|
||||||
|
|
||||||
|
printf '%s\n' "$props" | grep -q 'Coordinate Transformation Matrix' || continue
|
||||||
|
|
||||||
|
if printf '%s\n' "$info" | grep -Eqi 'touchscreen|touch screen|touchpad|ELAN|Wacom'; then
|
||||||
|
echo "Touch: id=$id $info -> $matrix" >> /tmp/fikakassa-orientation.log
|
||||||
xinput set-prop "$id" 'Coordinate Transformation Matrix' $matrix 2>/dev/null || true
|
xinput set-prop "$id" 'Coordinate Transformation Matrix' $matrix 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -393,7 +424,7 @@ test -x /usr/local/bin/fikakassa-orientation
|
|||||||
cat <<EOF2
|
cat <<EOF2
|
||||||
|
|
||||||
========================================
|
========================================
|
||||||
FIKAKASSAN KIOSK V5 ÄR KONFIGURERAD
|
FIKAKASSAN KIOSK V6 ÄR KONFIGURERAD
|
||||||
========================================
|
========================================
|
||||||
|
|
||||||
Kiosk-användare: $KIOSK_USER
|
Kiosk-användare: $KIOSK_USER
|
||||||
@@ -412,6 +443,7 @@ Kiosk:
|
|||||||
Rotation:
|
Rotation:
|
||||||
iio-sensor-proxy + monitor-sensor
|
iio-sensor-proxy + monitor-sensor
|
||||||
display + touchscreen roteras automatiskt
|
display + touchscreen roteras automatiskt
|
||||||
|
touchscreen-device identifieras korrekt via xinput
|
||||||
|
|
||||||
FastAPI:
|
FastAPI:
|
||||||
systemctl status fikakassa
|
systemctl status fikakassa
|
||||||
@@ -424,8 +456,9 @@ Starta om när du är klar:
|
|||||||
sudo reboot
|
sudo reboot
|
||||||
|
|
||||||
OBS:
|
OBS:
|
||||||
Om skärmen roteras men touch inte gör det korrekt, kontrollera:
|
Om touch fortfarande inte följer skärmen, kontrollera:
|
||||||
xinput list
|
xinput list --short
|
||||||
|
xinput list-props <ID>
|
||||||
och:
|
och:
|
||||||
cat /tmp/fikakassa-orientation.log
|
cat /tmp/fikakassa-orientation.log
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user