MacOS

Spotlight

mds or mds_stores using tons of CPU

To stop it, run sudo mdutil -a -i off. To restart it again, use sudo mdutil -a -i on.

Reindex

If you have problems where spotlight isn't finding applications or files for some reason, you can initiate the indexing manually via sudo mdutil -E /.

High CPU Usage

  1. Restart the computer.
  2. Kill spotlight process in activity monitor: corespotlightd. It should restart with lower CPU usage.
  3. If that didn't work, kill spotlight processes in the terminal: killall corespotlightd.
  4. Restart again.

Not visible

Sometimes spotlight just won't show up. Try:

  1. Click on the spotlight icon in the menubar and hold it for a few seconds. If it is stuck off screen (multiple monitors or just on far edge), this will recenter it.
  2. Could be the indexing got broken and it is stuck. Run sudo mdutil -a -i off && mdutil -a -i on && mdutil -E.

Set list as default view

This has annoyed the shit out of me forever. I want list view as default, but it never seems to stick. This forces it.

# Use list view in all Finder windows by default
# Four-letter codes for the other view modes: `icnv`, `clmv`, `glyv`
defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv"
# This helps to remove other views, which Finder remembered because of the
#.DS_Store files:
sudo find / -name ".DS_Store" -exec rm {} \;

Notifications

Background Items Added

You can automatically clean up "Background Items Added" notifications using this script:

#!/bin/bash
# Script Last Updated: October 8th, 2024
PLIST_PATH="$HOME/Library/LaunchAgents/com.user.clearBackgroundItemsAddedNotifications.plist"
LABEL="com.user.clearBackgroundItemsAddedNotifications"

cat <<EOF > "$PLIST_PATH"
<?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>$LABEL</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/bin/osascript</string>
        <string>-e</string>
        <string>tell application "System Events"
    try
        set _groups to groups of UI element 1 of scroll area 1 of group 1 of window "Notification Center" of application process "NotificationCenter"
        repeat with _group in _groups
            set temp to value of static text 1 of _group
            if temp contains "Background Items Added" or temp contains "Managed Login Items Added" then
                perform (first action of _group where description is "Close")
            end if
        end repeat
    end try
end tell</string>
    </array>
    <key>StartInterval</key>
    <integer>30</integer>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>
EOF
# Check if the Launch Agent is loaded, and unload it if so, this allows you to update by re-running this script
if launchctl list | grep -q "$LABEL"; then
    launchctl unload "$PLIST_PATH"
fi

launchctl load "$PLIST_PATH"

echo "Done. The AppleScript will run every 30 seconds to clear all 'Background Items Added' and 'Managed Login Items Added' notifications. To uninstall, run 'launchctl unload ~/Library/LaunchAgents/com.user.clearBackgroundItemsAddedNotifications.plist'."

References

  1. Reindexing for Spotlight
  2. mds and mds_stores diagnosing
  3. https://apple.stackexchange.com/questions/284467/how-to-set-finder-to-always-use-list-view
Incoming Links

Last modified: 202610110325