Close OS X notifications

360 views
Skip to first unread message

Oliver Schrenk

unread,
Mar 21, 2015, 2:34:45 PM3/21/15
to hamme...@googlegroups.com
Hi,

Is there a way of listing or more importantly closing the native OS X notification bubbles?

It really annoys me that I can't close these via some keyboard shortcut and my hope was to remedy this with hammerspoon

Cheers,
Oliver

Oliver Schrenk

unread,
Mar 21, 2015, 3:25:02 PM3/21/15
to hamme...@googlegroups.com
I found an applescript to do my bidding here


But I have some troubles getting to run this script from within hammerspoon. At the moment I have

-- Close notifications
hs.hotkey.bind(hyper, "n", function()
  hs.alert.show("Close notifications")
  script = [[
my closeNotif()
on closeNotif()

tell application "System Events"
tell process "Notification Center"
set theWindows to every window
repeat with i from 1 to number of items in theWindows
set this_item to item i of theWindows
try
click button 1 of this_item
on error

my closeNotif()
end try
end repeat
end tell
end tell

end closeNotif ]]
  ok,result = hs.applescript(script)
  hs.alert.show(result)
end)

I see the "Close" button flash up blue as if it would be clicked, but it doesn't close. When I run this script from Script Editor it works like expected.

Cheers
Oliver
Reply all
Reply to author
Forward
0 new messages