class Focus::ToggleMacNotificationCenter
Public Instance Methods
perform()
click to toggle source
# File lib/focus/actions/toggle_mac_notification_center.rb, line 3 def perform fail_action!(error: "This action only works on MacOSX") unless mac? toggle end
Private Instance Methods
mac?()
click to toggle source
# File lib/focus/actions/toggle_mac_notification_center.rb, line 10 def mac? uname == "Darwin" end
setting()
click to toggle source
# File lib/focus/actions/toggle_mac_notification_center.rb, line 28 def setting context.enabled ? "load" : "unload" end
toggle()
click to toggle source
# File lib/focus/actions/toggle_mac_notification_center.rb, line 18 def toggle `launchctl #{setting} -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist &>/dev/null` if context.enabled? `killall NotificationCenter &>/dev/null` else `open -a NotificationCenter &>/dev/null` end end
uname()
click to toggle source
# File lib/focus/actions/toggle_mac_notification_center.rb, line 14 def uname `uname`.chomp end