Removing Power Manager

Removing, or uninstalling, Power Manager is a little different from other application only products. Even though the process is slightly different, removing Power Manager remains simple.

Before Power Manager can be used, it must be installed on your Mac. Installation is required because Power Manager works closely with macOS, and to achieve this we need to place files in various locations outside of your home folder.

You can choose to Remove the Scheduler or Remove Power Manager.

Avoiding Problems

Do not use third party tools to remove Power Manager, and do not attempt to find and remove all the files by hand. Both approaches are prone to mistakes and leaving files behind. The only sure way of removing Power Manager is by following these steps.

Power Manager can be left uninstalled in your Applications folder. Only if the scheduler is installed will any scheduling occur.

Having Power Manager available, but not performing scheduling duties, is designed where access to pmctl, documentation, or other aspects of Power Manager are needed.

Remove the Scheduler

To remove the Scheduler and leave the application in-place:

  1. Launch Power Manager.
  2. Select the menu item: Scheduler > Remove Scheduler….
  3. Follow the steps to confirm and remove the Scheduler.

Remove Power Manager

To remove the application and Scheduler:

  1. Launch Power Manager.
  2. Select the menu item: Scheduler > Remove… (with Option key)
  3. Follow the steps to confirm and entirely remove Power Manager.

What is removed?

For the complete removal, Power Manager uses an installer package, .pkg, that completely removes both installed and runtime created files.

The removal package requires administrator rights to run. The package also deals with previous versions of Power Manager. The package can be found at Power Manager.app/Contents/Resources/remove-power-manager.pkg and online at dssw.co.uk/powermanager/remove.

Removal Script

The script embedded within the package is presented in full below.

The aim is to keep the script approachable to administrators and advanced users comfortable with shell scripting. Expect the script to change between versions and releases of Power Manager.

#!/bin/bash
#
# Part of DssW Power Manager
# Copyright (c) 2022 Dragon Systems Software Limited
# Support: support@dssw.co.uk
#
# This script removes Power Manager from the target drive. A restart is required.

TARGET_DRIVE="$3"

# Ensure script has root authority
if ! [ "$(id -u)" = 0 ]; then
  echo "You must be root to run this script" 2>&1
  exit 1
fi

##
# Remove static files
REMOVE_FILES=(
  # ...PM5 only
  'Library/LaunchDaemons/uk.co.dssw.powermanager.pmd.plist'  # Launchd job ticket
  # ...PM3+PM4
  'Applications/Power Manager.app' # Application
  'etc/pam.d/uk.co.dssw.powermanager' # PAM policy
  'Library/Application Support/Power Manager' # Shared tools and core engine
  'Library/Automator/PMCancelEvents.action'
  'Library/Automator/PMDelayEvents.action'
  'Library/Automator/PMDeleteEvents.action'
  'Library/Automator/PMEvent.definition'
  'Library/Automator/PMEventsToStrings.caction'
  'Library/Automator/PMExportEvents.action'
  'Library/Automator/PMFilterEvents.action'
  'Library/Automator/PMImportEvents.action'
  'Library/Automator/PMListEvents.action'
  'Library/Automator/PMNewEvent.action'
  'Library/Automator/PMNextEvent.action'
  'Library/Automator/PMResetEvents.action'
  'Library/Automator/PMToggleScheduler.action'
  'Library/Frameworks/PowerManager.framework' # Shared framework
  'Library/LaunchAgents/uk.co.dssw.pmnotify.login.plist' # Launchd job ticket
  'Library/LaunchAgents/uk.co.dssw.pmnotify.plist' # Launchd job ticket
  'Library/LaunchAgents/uk.co.dssw.pmuser.plist' # Launchd job ticket
  'Library/LaunchDaemons/uk.co.dssw.pmd.plist' # Launchd job ticket
  'Library/LaunchDaemons/uk.co.dssw.powermanager.installer.plist' # Automated installer job ticket
  'Library/PrivilegedHelperTools/uk.co.dssw.powermanager.installer' # Automated installer
  'Library/Caches/uk.co.dssw.powermanager.certtool.cache.json' # certtool cache
  'var/tmp/uk.co.dssw.powermanager' # Unix socket directory
  # ...PM3 only
  'Library/Documentation/Help/Power Manager Help' # Help Book symlink
  'Library/PreferencePanes/Power Manager.prefPane' # Preference pane
  'Library/StartupItems/PowerManager' # StartupItem (Mac OS X 10.3.9)
  'Library/Widgets/Power Manager.wdgt' # Dashboard widget (Mac OS X 10.4+)
  'System/Library/CoreServices/SecurityAgentPlugins/pmauth.bundle' # loginwindow plugin
  'usr/local/powermanager' # Unix daemon
  );
for (( i = 0 ; i < "${#REMOVE_FILES[@]}" ; i++ ))
do
  FILEPATH="${TARGET_DRIVE}${REMOVE_FILES[$i]}"
  if [ -e "$FILEPATH" ]; then
    rm -r "${FILEPATH}"
  fi
done

##
# Remove the run time created files
find "${TARGET_DRIVE}Library/Receipts" -name 'Power Manager *.pkg' -type d -print0 | xargs -0 rm -r
find "${TARGET_DRIVE}Library/Preferences" -name 'uk.co.dssw.powermanager.*' -type f -delete
find "${TARGET_DRIVE}var/root/Library/Preferences" -name 'uk.co.dssw.powermanager.*' -type f -delete

exit 0