mirror of
https://github.com/karl0ss/AnotterKiosk.git
synced 2025-06-08 12:45:08 +01:00
Compare commits
9 Commits
1d7c60ff8b
...
5fdb39ea81
Author | SHA1 | Date | |
---|---|---|---|
5fdb39ea81 | |||
7565fb2bdc | |||
8dce7fb3fd | |||
df89a6b54e | |||
956ac7bf66 | |||
ba0da7622c | |||
5046d5249c | |||
![]() |
1c702f90e4 | ||
2fb4f35f6b |
@ -2,13 +2,21 @@
|
|||||||
[general]
|
[general]
|
||||||
hostname = "kioskpi"
|
hostname = "kioskpi"
|
||||||
|
|
||||||
|
[reboot]
|
||||||
|
; can be used to set an automatic reboot on a specific time (time in 24 horus format)
|
||||||
|
enabled=0
|
||||||
|
reboot_time = 04:00
|
||||||
|
|
||||||
[screen]
|
[screen]
|
||||||
; can be used to force 1080p on 4k screens or workaround broken EDID communication
|
; can be used to force 1080p on 4k screens or workaround broken EDID communication
|
||||||
;force_resolution = "1920x1080"
|
;force_resolution = "1920x1080"
|
||||||
; force a custom modelines (for specialty diplays like embedded monitors, car screens, etc.)
|
; force a custom modelines (for specialty diplays like embedded monitors, car screens, etc.)
|
||||||
;custom_modeline = "40.141 1024 1032 1064 1104 600 604 612 618 +HSync -VSync"
|
;custom_modeline = "40.141 1024 1032 1064 1104 600 604 612 618 +HSync -VSync"
|
||||||
; can be used for forcing screen rotation on raspberry pi boards (normal, left, right, inverted)
|
; set screen rotation to be used (normal, left, right, inverted)
|
||||||
;rotate_screen = "normal"
|
;rotate_screen = "normal"
|
||||||
|
; configure screen to power on/off as specific time of day (time format in 24 hours)
|
||||||
|
;screen_off_time=23:00
|
||||||
|
;screen_on_time=07:00
|
||||||
|
|
||||||
[wifi]
|
[wifi]
|
||||||
; If you need more complex WiFi settings (like WPA2-Enterprise, hidden SSIDs, etc.)
|
; If you need more complex WiFi settings (like WPA2-Enterprise, hidden SSIDs, etc.)
|
||||||
|
@ -78,6 +78,9 @@ systemctl enable ntpdate
|
|||||||
systemctl enable lightdm
|
systemctl enable lightdm
|
||||||
systemctl enable nginx
|
systemctl enable nginx
|
||||||
systemctl enable ssh
|
systemctl enable ssh
|
||||||
|
systemctl enable kiosk-sechedule-screen.service
|
||||||
|
systemctl enable schedule-reboot.service
|
||||||
|
|
||||||
|
|
||||||
# generate a version info/build info file
|
# generate a version info/build info file
|
||||||
echo -n "Chromium version: " >> /version-info
|
echo -n "Chromium version: " >> /version-info
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
# /etc/systemd/system/kiosk-sechedule-screen.service
|
||||||
|
[Unit]
|
||||||
|
Description=Schedule Screen On/Off Timers
|
||||||
|
After=multi-user.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/usr/bin/schedule-screen-timers
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
10
kiosk_skeleton/etc/systemd/system/schedule-reboot.service
Normal file
10
kiosk_skeleton/etc/systemd/system/schedule-reboot.service
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Schedule Reboot from kioskbrowser.ini
|
||||||
|
After=multi-user.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/usr/bin/schedule-reboot
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
51
kiosk_skeleton/usr/bin/schedule-reboot
Normal file
51
kiosk_skeleton/usr/bin/schedule-reboot
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
INI_FILE="/boot/kioskbrowser.ini"
|
||||||
|
REBOOT_ENABLED=$(awk -F '=' '/^\[reboot\]/ { in_reboot=1; next }
|
||||||
|
in_reboot && /^\[/ { in_reboot=0 }
|
||||||
|
in_reboot && $1 ~ /enabled/ { gsub(/ /, "", $2); print $2 }' "$INI_FILE")
|
||||||
|
|
||||||
|
REBOOT_TIME=$(awk -F '=' '/^\[reboot\]/ { in_reboot=1; next }
|
||||||
|
in_reboot && /^\[/ { in_reboot=0 }
|
||||||
|
in_reboot && $1 ~ /reboot_time/ { gsub(/ /, "", $2); print $2 }' "$INI_FILE")
|
||||||
|
|
||||||
|
if [[ "$REBOOT_ENABLED" -eq 1 ]] && [[ "$REBOOT_TIME" =~ ^[0-2][0-9]:[0-5][0-9]$ ]]; then
|
||||||
|
echo "Scheduling reboot for $REBOOT_TIME..."
|
||||||
|
|
||||||
|
TARGET_TIME=$(date -d "$REBOOT_TIME" +%s)
|
||||||
|
NOW=$(date +%s)
|
||||||
|
|
||||||
|
if [ "$TARGET_TIME" -le "$NOW" ]; then
|
||||||
|
TARGET_TIME=$(date -d "tomorrow $REBOOT_TIME" +%s)
|
||||||
|
fi
|
||||||
|
|
||||||
|
TARGET_ISO=$(date -d "@$TARGET_TIME" --iso-8601=seconds)
|
||||||
|
|
||||||
|
REBOOT_UNIT="/etc/systemd/system/reboot-at.timer"
|
||||||
|
cat <<EOF > "$REBOOT_UNIT"
|
||||||
|
[Unit]
|
||||||
|
Description=One-off reboot timer
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=$TARGET_ISO
|
||||||
|
Persistent=false
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Create the associated service
|
||||||
|
cat <<EOF > /etc/systemd/system/reboot-at.service
|
||||||
|
[Unit]
|
||||||
|
Description=Scheduled Reboot
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/sbin/reboot
|
||||||
|
EOF
|
||||||
|
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable --now reboot-at.timer
|
||||||
|
else
|
||||||
|
echo "Reboot not scheduled (disabled or invalid time)"
|
||||||
|
fi
|
65
kiosk_skeleton/usr/bin/schedule-screen-timers
Normal file
65
kiosk_skeleton/usr/bin/schedule-screen-timers
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
INI_FILE="/boot/kioskbrowser.ini"
|
||||||
|
SYSTEMD_DIR="/etc/systemd/system"
|
||||||
|
|
||||||
|
get_ini_value() {
|
||||||
|
local section=$1 key=$2
|
||||||
|
awk -F '=' -v sec="$section" -v k="$key" '
|
||||||
|
$0 ~ /^\[.*\]/ { in_section = ($0 == "[" sec "]") }
|
||||||
|
in_section && $1 ~ "^"k"$" {
|
||||||
|
gsub(/^[ \t]+|[ \t]+$/, "", $2)
|
||||||
|
print $2
|
||||||
|
exit
|
||||||
|
}' "$INI_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
create_recurring_timer() {
|
||||||
|
local action=$1
|
||||||
|
local time=$2
|
||||||
|
local name="screen-${action}"
|
||||||
|
|
||||||
|
echo "Setting daily screen ${action} at ${time}"
|
||||||
|
|
||||||
|
cat <<EOF > "$SYSTEMD_DIR/${name}.timer"
|
||||||
|
[Unit]
|
||||||
|
Description=Daily screen ${action} timer
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=*-*-* ${time}:00
|
||||||
|
Persistent=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat <<EOF > "$SYSTEMD_DIR/${name}.service"
|
||||||
|
[Unit]
|
||||||
|
Description=Turn screen ${action}
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
Environment=DISPLAY=:0
|
||||||
|
ExecStart=/usr/bin/xset dpms force ${action}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable --now "${name}.timer"
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup_screen_timers() {
|
||||||
|
for action in on off; do
|
||||||
|
systemctl disable --now screen-${action}.timer 2>/dev/null
|
||||||
|
rm -f "$SYSTEMD_DIR/screen-${action}.timer" "$SYSTEMD_DIR/screen-${action}.service"
|
||||||
|
done
|
||||||
|
systemctl daemon-reload
|
||||||
|
}
|
||||||
|
|
||||||
|
# === MAIN ===
|
||||||
|
SCREEN_ON=$(get_ini_value screen screen_on_time)
|
||||||
|
SCREEN_OFF=$(get_ini_value screen screen_off_time)
|
||||||
|
|
||||||
|
cleanup_screen_timers
|
||||||
|
|
||||||
|
[[ "$SCREEN_ON" =~ ^[0-2][0-9]:[0-5][0-9]$ ]] && create_recurring_timer on "$SCREEN_ON"
|
||||||
|
[[ "$SCREEN_OFF" =~ ^[0-2][0-9]:[0-5][0-9]$ ]] && create_recurring_timer off "$SCREEN_OFF"
|
Loading…
x
Reference in New Issue
Block a user