aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.sh90
1 files changed, 63 insertions, 27 deletions
diff --git a/configure.sh b/configure.sh
index 1cc55e2..2a88573 100644
--- a/configure.sh
+++ b/configure.sh
@@ -12,33 +12,46 @@ show_menu() {
# Function to configure start.sh
configure_start_sh() {
- SCALE_FACTOR=$(dialog --title "Display Scaling Factor" --inputbox "Enter the display scaling factor (e.g., 1 for 1080p, 2 for 4K):" 8 50 "1" 3>&1 1>&2 2>&3 3>&-)
+ if [[ $# -eq 0 ]]; then # Interactive mode
+ SCALE_FACTOR=$(dialog --title "Display Scaling Factor" --inputbox "Enter the display scaling factor (e.g., 1 for 1080p, 2 for 4K):" 8 50 "1" 3>&1 1>&2 2>&3 3>&-)
- DIALOG_RESULT=$(dialog --title "start.sh Configuration" --menu "Choose the script example:" 15 50 2 \
- 1 "Simple website script" \
- 2 "Two or more tabs alternating every 30 seconds" \
- 3>&1 1>&2 2>&3 3>&-)
+ DIALOG_RESULT=$(dialog --title "start.sh Configuration" --menu "Choose the script example:" 15 50 2 \
+ 1 "Simple website script" \
+ 2 "Two or more tabs alternating every 30 seconds" \
+ 3>&1 1>&2 2>&3 3>&-)
- if [ "$DIALOG_RESULT" = "1" ]; then
- WEBSITE=$(dialog --title "Enter Website URL" --inputbox "Please enter the URL for the simple website:" 8 50 "https://www.example.com" 3>&1 1>&2 2>&3 3>&-)
- set_start_script_single $SCALE_FACTOR $WEBSITE
- elif [ "$DIALOG_RESULT" = "2" ]; then
- TAB_COUNT=$(dialog --title "Number of Tabs" --inputbox "Enter number of tabs:" 8 50 "3" 3>&1 1>&2 2>&3 3>&-)
- local tab_urls=()
- for (( i=1; i<=TAB_COUNT; i++ )); do
- URL=$(dialog --title "Enter URL for Tab $i" --inputbox "Enter URL:" 8 50 "http://example$i.com" 3>&1 1>&2 2>&3 3>&-)
- tab_urls+=("$URL")
- done
- configure_tabs $SCALE_FACTOR "${tab_urls[@]}"
+ if [ "$DIALOG_RESULT" = "1" ]; then
+ WEBSITE=$(dialog --title "Enter Website URL" --inputbox "Please enter the URL for the simple website:" 8 50 "https://www.example.com" 3>&1 1>&2 2>&3 3>&-)
+ set_start_script_single $SCALE_FACTOR $WEBSITE
+ elif [ "$DIALOG_RESULT" = "2" ]; then
+ TAB_COUNT=$(dialog --title "Number of Tabs" --inputbox "Enter number of tabs:" 8 50 "3" 3>&1 1>&2 2>&3 3>&-)
+ local tab_urls=()
+ for (( i=1; i<=TAB_COUNT; i++ )); do
+ URL=$(dialog --title "Enter URL for Tab $i" --inputbox "Enter URL:" 8 50 "http://example$i.com" 3>&1 1>&2 2>&3 3>&-)
+ tab_urls+=("$URL")
+ done
+ configure_tabs $SCALE_FACTOR "${tab_urls[@]}"
+ fi
+ else # Automated mode
+ local scaling_factor=$1
+ shift # Remove the first argument (scaling factor) to get URLs
+ if [ $# -eq 1 ]; then # Single website
+ set_start_script_single $scaling_factor $1
+ else # Multiple tabs
+ configure_tabs $scaling_factor "$@"
+ fi
fi
}
# Helper function to configure start.sh for a single website
set_start_script_single() {
+ local scaling_factor=$1
+ local website=$2
+
# Write the script with properly formatted commands
cat > /home/kiosk/start.sh <<EOF
#!/bin/bash
-/usr/bin/chromium --no-first-run --disable-translate --no-default-browser-check --disable-cache --kiosk $2
+/usr/bin/chromium --no-first-run --disable-translate --no-default-browser-check --disable-cache --kiosk $website
EOF
chmod a+x /home/kiosk/start.sh
}
@@ -95,13 +108,36 @@ change_vnc_password() {
echo "VNC password changed"
}
-# Main loop
-while true; do
- choice=$(show_menu)
- case $choice in
- 1) configure_start_sh ;;
- 2) change_vnc_password ;;
- 3) exit 0 ;;
- *) echo "Invalid option, please try again" ;;
- esac
-done
+# Check for help option
+if [[ "$1" == "-h" || "$1" == "--help" ]]; then
+ echo "Usage: $0 [--auto <scaling_factor> <url1> [<url2> ... <urlN>]]"
+ echo "Options:"
+ echo " --auto Run the script in automatic mode with no user interaction."
+ echo " Requires specifying the scaling factor (e.g., '1' for 1080p, '2' for 4K),"
+ echo " and at least one URL. Additional URLs are optional and will open in new tabs."
+ echo " -h, --help Display this help and exit."
+ echo ""
+ echo "Example:"
+ echo " $0 --auto 1 \"https://www.example.com\""
+ echo " $0 --auto 2 \"https://www.example1.com\" \"https://www.example2.com\""
+ exit 0
+fi
+
+# Automated or interactive mode check
+if [[ $1 == "--auto" ]]; then
+ shift # Remove the first argument (script name)
+ scaling_factor=$1
+ shift # Remove the scaling factor to get URLs
+ configure_start_sh $scaling_factor "$@"
+else
+ # Main loop
+ while true; do
+ choice=$(show_menu)
+ case $choice in
+ 1) configure_start_sh ;;
+ 2) change_vnc_password ;;
+ 3) exit 0 ;;
+ *) echo "Invalid option, please try again" ;;
+ esac
+ done
+fi