Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to check for F1 and F8 key presses
- local function checkKeys()
- local timer = os.startTimer(1) -- Start a timer for 1 second
- while true do
- local event, key = os.pullEvent()
- -- If Recovery.sys exists, show recovery mode and do nothing else
- if fs.exists("Recovery.sys") then
- print("Doggy OS Recovery Mode")
- return
- end
- -- Check if F1 is pressed
- if event == "key" and key == keys.f1 then
- -- Cancel the timer
- os.cancel(timer)
- -- Wait for 1 second before displaying recovery mode
- sleep(1)
- if not fs.exists("Recovery.sys") then
- -- Create Recovery.sys if it doesn't exist
- local file = fs.open("Recovery.sys", "w")
- file.write("Recovery mode activated.")
- file.close()
- print("Doggy OS Recovery Mode")
- end
- return
- end
- -- Check if F8 is pressed
- if event == "key" and key == keys.f8 then
- if fs.exists("Recovery.sys") then
- -- Delete Recovery.sys and reboot
- fs.delete("Recovery.sys")
- print("Recovery.sys deleted. Rebooting...")
- sleep(2) -- Sleep for 2 seconds before reboot
- os.reboot()
- else
- print("Recovery.sys does not exist.")
- end
- end
- -- Check if timer event is triggered
- if event == "timer" and key == timer then
- -- Run the boot animation script if no key was pressed in 1 second
- shell.run("/disk/boot/boot-animation") -- Removed the .lua extension
- return
- end
- end
- end
- -- Check for recovery mode at startup
- if fs.exists("Recovery.sys") then
- print("Doggy OS Recovery Mode")
- else
- -- Start listening for key presses
- checkKeys()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement