Prefer pretty hostname

This commit is contained in:
Corey Smith
2025-07-23 11:02:06 -07:00
2 changed files with 96 additions and 2 deletions

94
kiosk.sh Normal file
View File

@ -0,0 +1,94 @@
#!/bin/sh
set -e
echo "Setting up Kiosk..."
cat > /etc/apk/repositories << 'EOF'
http://mirror.fcix.net/alpine/v3.22/main
http://mirror.fcix.net/alpine/v3.22/community
EOF
apk update && apk upgrade
# Install packages
apk add \
mesa-dri-gallium mesa-egl mesa-gl mesa-gles \
xorg-server xf86-video-fbdev xf86-input-libinput \
dbus setxkbmap kbd xrandr xset xinit chromium
# Configure boot with custom config.txt and cmdline.txt (usercfg.txt is used becuase config.txt get's overwritten on updates)
cat > /boot/usercfg.txt << 'EOF'
camera_auto_detect=0
disable_overscan=1
dtoverlay=vc4-kms-v3d
gpu_mem=128
hdmi_force_hotplug=1
hdmi_group=2
hdmi_mode=82
config_hdmi_boost=4
boot_delay=0
disable_splash=1
EOF
echo "root=UUID=$(findmnt -no UUID /) modules=sd-mod,usb-storage,ext4 rootfstype=ext4 console=tty3 loglevel=0 vt.global_cursor_default=0" > /boot/cmdline.txt
# Remove unnecessary services
for service in acpid chronyd crond modules seedrng; do
rc-update del $service 2>/dev/null || true
done
# Create kiosk user
adduser -D -h /srv/kiosk -s /bin/ash kiosk
# Setup kiosk profile
cat > /srv/kiosk/.profile << 'EOF'
#!/bin/sh
if [ -z "$DISPLAY" ] && [ "$(tty)" = "/dev/tty1" ]; then
exec startx >/dev/null 2>&1
fi
EOF
# Setup xinitrc
cat > /srv/kiosk/.xinitrc << 'EOF'
#!/bin/sh
export DISPLAY=:0
(sleep 2 && xset -dpms s off s noblank) &
while ! ping -c 1 -W 1 google.com > /dev/null 2>&1; do
sleep 2
done
while true; do
chromium \
--kiosk \
--no-sandbox \
--disable-dev-shm-usage \
--force-device-scale-factor=1 \
--window-size=3840,2160 \
--disable-features=TranslateUI \
--disable-component-update \
--no-first-run \
--num-raster-threads=4 \
--use-gl=egl \
--disable-infobars \
--disable-session-crashed-bubble \
--disable-breakpad \
--disable-sync \
--disable-translate \
--metrics-recording-only \
--disable-default-apps \
--mute-audio \
--no-default-browser-check \
${KIOSK_URL:-https://benewahauto.com}
sleep 5
done
EOF
chown -R kiosk:kiosk /srv/kiosk
chmod +x /srv/kiosk/.profile /srv/kiosk/.xinitrc
# Configure autologin
sed -i 's/^tty1::respawn:.*$/tty1::respawn:\/bin\/login -f kiosk/' /etc/inittab
echo "Setup complete! Rebooting..."
reboot

View File

@ -34,7 +34,7 @@ set -g status-interval 5
# Add a space to the beginning of the status bar
# This keeps the default session name '[#S]' and adds a space before it
set -g status-left-length 300
set -g status-left ' #[bold] #{session_name}#[nobold] | #{user}@#(hostnamectl --pretty 2>/dev/null || hostname) | #(curl -s ifconfig.me) | '
set -g status-left ' #[bold] #{session_name}#[nobold] | #{user}@#(pretty=$(hostnamectl --pretty 2>/dev/null); [ -n "$pretty" ] && echo "$pretty" || hostname) | #(curl -s ifconfig.me) | #(if docker info >/dev/null 2>&1; then echo " $(docker ps -q | wc -l)/$(docker ps -aq | wc -l)"; else echo "#[fg=red] down#[default]"; fi) | '
# Add a space to the end of the status bar
# This keeps the default hostname and date/time, and adds a space after
@ -164,7 +164,7 @@ fi
# Automatically start tmux if not already running in an interactive session
if [[ -z "$TMUX" ]] && [[ "$-" == *i* ]]; then
tmux attach -t Default || tmux new -s Default
tmux attach -t "$HOSTNAME" || tmux new -s "$HOSTNAME"
fi
EOF