Disable “not ejected properly” warning (as only charging and not writing data) [duplicate]
Is there any way to disable the "the disk was not ejected properly" message?
I use a KVM and need to switch between two systems and have a memory stick that is in the KVM. The problem is that it's very annoying to get the message every time I switch from one computer to the other. I know, I can unmount it (and probably should), but I switch all the time, so it's a inconvenience to unmount, and there is nothing sensitive on the memory stick.
Solution 1:
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.UserNotificationCenter.plist
Which will just stop the UserNotificationCenter service from running.
beware: as noted in the comments, this will disable all system notifications, including those when programs request access to system services like contacts, and there are a lot more of these notifications now than when this question was originally asked in 2011.
Solution 2:
This applescript will close them for you. Paste it into Script Editor and then Save as an application. Then grant access to that application in (System Preferences > Security & Privacy > Accessibility) Then you can use an application like ControlPlane https://www.controlplaneapp.com/ to run the application on wake thus closing them all automatically! ** Note: You will need to grant Accessibility access to ControlPlane as well.
tell application "System Events"
tell process "NotificationCenter"
set numwins to (count windows)
repeat with i from numwins to 1 by -1
tell window i
set temp to value of static text 1
end tell
if temp contains "Disk Not Ejected Properly" then
click button "Close" of window i
end if
end repeat
end tell
end tell
Solution 3:
Certainly not an elegant answer but, you can disable UserNotificationCenter.app found in /system/library/coreservices - replace it with another app or file with the same name. It will stop any warnings popping up (including that your drive is full) so watch out for that, but in my experience it does what you are looking for.
I actually did this to my mac a long time ago, and forgot about it until you asked you question. Credit to Macpadawon at http://macosx.com/forums/mac-os-x-system-mac-software/297194-disable-device-removal-message.html for the answer - same place I found my answer a couple of years back.
Solution 4:
Works with macOS Big Sur
This AppleScript dismisses all notifications about the disk not being ejected properly.
tell application "System Events"
tell process "Notification Center"
set group_index to 1
repeat
try
set the_window to group group_index of UI element 1 of scroll area 1 of window "Notification Center"
set notification to value of static text of the_window
set notification_title to item 1 of notification
if notification_title = "DISK NOT EJECTED PROPERLY" then
set the_actions to actions of the_window
repeat with the_action in the_actions
if description of the_action is "Close" then
tell the_window
perform the_action
end tell
end if
end repeat
# Wait for the notification to disappear so that the indexes of the remaining notifications are updated accordingly.
delay 0.25
# Do not increment `group_index` because all remaining notifications have their index decremented by 1 since this notification was dismissed. We do not need to worry about the notifications before the one just dismissed because we already know that they are not notifications about disk ejection.
else
# This is not a disk ejection notification, so skip it and look at the next notification.
set group_index to group_index + 1
end if
on error error_message
# There are no more notifications to process.
exit repeat
end try
end repeat
end tell
end tell
You can run this AppleScript every 10 seconds with the launchd PLIST below. Be sure to modify it to work with your own setup. Then place the PLIST in ~/Library/LaunchAgents
and run launchctl load ~/Library/LaunchAgents/file.plist
(replacing file.plist
with the name of the file) in Terminal.
What's really cool about launchd is that if a job does not run because the computer is asleep (e.g., when your laptop is closed), launchd will run the job as soon as the computer wakes up again (and if the job was supposed to run multiple times while the computer was asleep, the multiple runs will be coalesced into one run upon wakeup). This is really useful when unplugging a closed laptop from a home dock with a hard drive attached and then using the laptop on-the-go.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.YourName.DismissNotifications</string>
<key>ProgramArguments</key>
<array>
<string>osascript</string>
<string>/path/to/script</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>10</integer>
</dict>
</plist>