#!/bin/zsh

echo ""

echo "I Am Somewhat Conflicted On Solarium (ISCS): Disable (and re-enable) macOS Tahoe's new Solarium UI (and in some cases re-enable Launchpad)"
echo "Thank you to BetaWiki for showing me the commands required, you may find them here: https://betawiki.net/wiki/MacOS_Tahoe_build_25A5279m"
echo "Shell script by N64onosu (https://n64onosu.neocities.org/)"

echo ""

echo "Disabling Solarium is likely to result in visual bugs, if you like absolute perfection this is not for you!"

echo ""

echo "What would you like to do?"
echo "1) Disable Solarium"
echo "2) Enable Solarium"
echo "3) Disable New Spotlight and bring back Launchpad (Beta 4 and below)"
echo "4) Enable New Spotlight and revert Launchpad (Beta 4 and below)"
echo "5) Why are some options labelled with 'Beta 4 and below'?"
echo "6) Exit"

echo ""

echo -n "Your Choice: "

while :
do

read what

case $what in
	1) echo ""
	defaults write -g com.apple.SwiftUI.DisableSolarium -bool YES
	echo "Disabled Solarium globally..."
	defaults write com.apple.finder com.apple.SwiftUI.DisableSolarium -bool YES
	echo "Disabled Solarium for Finder..."
	defaults write com.apple.Preview com.apple.SwiftUI.DisableSolarium -bool YES
	echo "Disabled Solarium for Preview..."
	echo "Solarium has been disabled! Enjoy your new-old macOS!"
	echo "Please restart for all changes to take effect."
	echo ""
	;;
	
	2) echo "" 
	defaults write -g com.apple.SwiftUI.DisableSolarium -bool NO
	echo "Re-enabling Solarium globally..."
	defaults write com.apple.finder com.apple.SwiftUI.DisableSolarium -bool NO
	echo "Re-enabling Solarium for Finder..."
	defaults write com.apple.Preview com.apple.SwiftUI.DisableSolarium -bool NO
	echo "Re-enabling Solarium for Preview..."
	echo "Solarium has been (re-)enabled! Welcome back to Liquid Glass!"
	echo "Please restart for all changes to take effect."
	echo ""
	;;

	3) echo ""
	sudo mkdir -p /Library/Preferences/FeatureFlags/Domain
	echo "Made directory for flags..."
	sudo defaults write /Library/Preferences/FeatureFlags/Domain/SpotlightUI.plist SpotlightPlus -dict Enabled -bool false
	echo "Disabling SpotlightPlus..."
	echo "Launchpad reactivated! Very nice :)"
	echo "Please restart for all changes to take effect."
	echo ""
	;;
	
	4) echo ""
	#notice a significant lack of removing directories?
	sudo defaults write /Library/Preferences/FeatureFlags/Domain/SpotlightUI.plist SpotlightPlus -dict Enabled -bool true
	echo "Enabling SpotlightPlus..."
	echo "Launchpad deactivated! Out with the old, in with the new!"
	echo "Please restart for all changes to take effect."
	echo ""
	;;
	
	5) echo ""
	echo "With the first betas of macOS Tahoe, Apple simply disabled Launchpad and did not remove it."
	echo "However, with the introduction of Tahoe Beta 5/Public Beta 2, Launchpad was completely removed."
	echo "Therefore, running Option 3 on macOS versions beyond Beta 5 will only disable SpotlightPlus, and will not reactivate Launchpad."
	echo "TLDR: DON'T run Options 3 or 4 on versions beyond Tahoe Beta 5!"
	echo ""
	;;
	
	6) exit;;
	
	*) echo "what?";;
esac
	echo -n "Your Choice: "
done
