Safe shutdown from Kisok mode I plan to deploy a kiosk with no keyboard and mouse. Can anyone think of a way to allow safe shutdown? I think the power button will put up a user prompt that requires a keyboard or mouse. The only thing I could think of was a usb enter key. This is silly so I'm asking for help.
Found an answer here with applescript

on idle
set i to 0

tell application "System Events"

    -- Get a count of all the windows belonging to the process
    set numberOfWindows to count windows of process "loginwindow"

    -- Check each window for a "Shut Down" button....
    repeat numberOfWindows times
        set i to i + 1

        -- ....and shut down if found
        if exists button "Shut Down" of window i of process "loginwindow" then
            click button "Shut Down" of window i of process "loginwindow"
        end if
    end repeat
end tell

-- How often the script checks for the window (in seconds). Change it as you see fit.
return 7
end idle


Haven't tested it yet, but it sounds reasonable.

edit
Option 2
Super simple (assuming no open applications will prompt for user interaction first)

tell app "System Events" to shut down


Option 3 (variation on option 1)

tell application "System Events" to set the visible of every process to true

set white_list to {"Finder"}
set white_list to {"Shutdown"}

try
  tell application "Finder"
      set process_list to the name of every process whose visible is true
    end tell
    repeat with i fron 1 to (number of items in process_list)
      set this_process to item i of the process_list
      if this_process is not in white_list then
        tell application this_process
          quit
        end tell
        end if
    end repeat
on error
    tell application "finder"
    shutdown
    end tell
end try
delay 2
tell application "Finder"
  shut down
end tell