···11+CMD_Q_SAFARI = hs.hotkey.new({ "cmd" }, "q", function()
22+ local app = hs.application.frontmostApplication()
33+ local appName = app:name()
44+ if app:name() == "Safari" then
55+ local button, text = hs.dialog.blockAlert("Are you sure you want to quit Safari?", "Safari has open windows or tabs.", "Quit", "Cancel")
66+ if button == "Quit" then
77+ app:kill() -- This command will close Safari if "Quit" is selected
88+ end
99+ else
1010+ CMD_Q_SAFARI:disable()
1111+ hs.eventtap.keyStroke({ "cmd" }, "Q")
1212+ CMD_Q_SAFARI:enable()
1313+ end
1414+end):enable()