From 018011629ba638c59088fc82860633d208c0d1e6 Mon Sep 17 00:00:00 2001 From: zumbiepig <121742281+zumbiepig@users.noreply.github.com> Date: Tue, 28 Jan 2025 20:50:03 -0800 Subject: [PATCH] Update macos.plugin.zsh --- plugins/macos/macos.plugin.zsh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/plugins/macos/macos.plugin.zsh b/plugins/macos/macos.plugin.zsh index ceb158dec..ac826e02f 100644 --- a/plugins/macos/macos.plugin.zsh +++ b/plugins/macos/macos.plugin.zsh @@ -18,11 +18,18 @@ alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && alias hidefiles="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder" # Reset Launchpad layout (defaults method does not work in MacOS Sequoia and onward) -if [[ "$(sw_vers --productVersion)" -ge 15.0 ]]; then - alias resetlaunchpad='rm -rf /private/$(getconf DARWIN_USER_DIR)/com.apple.dock.launchpad && killall Dock' -else - alias resetlaunchpad='defaults write com.apple.dock ResetLaunchPad -bool true && killall Dock' -fi +function resetlaunchpad() { + if [[ "$(sw_vers --productVersion)" -ge 15.0 ]]; then + local user_dir="$(getconf DARWIN_USER_DIR)" + if [[ -n "$user_dir" && -d "$user_dir/com.apple.dock.launchpad" ]]; then + rm -rf "$user_dir/com.apple.dock.launchpad" && + killall Dock + fi + else + defaults write com.apple.dock ResetLaunchPad -bool true + && killall Dock + fi +} # Bluetooth restart function btrestart() {