-
-
Save altercation/b5faf1c89ee7570cc4c4dce09e88839f to your computer and use it in GitHub Desktop.
macOS Minecraft Controller - Limit minecraft play to specific times
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# replace following with local user running minecraft | |
LOCALUSER=username | |
function mc_off () { | |
# echo "minecraft off" | |
spctl --add --label "Minecraft" /Users/flint/Library/Application\ Support/minecraft/runtime/jre-legacy/mac-os/jre-legacy/jre.bundle/Contents/Home/bin/java | |
spctl --disable --label "Minecraft" | |
pkill -f "Minecraft.app" | |
pkill -f "CurseForge.app" | |
pkill -f "minecraft/launcher" | |
pkill -f Lunar | |
pkill -f Minecraft | |
pkill -f minecraft | |
pkill -f '.lunarclient' | |
pkill -f lunarclient | |
pkill -f badlion | |
pkill -f '.badlion' | |
pkill -f '.badlion' | |
pkill -f Badlion | |
chmod -rx /Applications/Minecraft.app/Contents/MacOS/launcher | |
chmod -rx /Applications/CurseForge.app/Contents/MacOS/CurseForge | |
chmod -rx /Applications/Lunar\ Client.app/Contents/MacOS/Lunar\ Client | |
chmod -rx /Applications/Badlion\ Client.app/Contents/MacOS/Badlion\ Client | |
chmod -rx /Users/$LOCALUSER/Library/Application\ Support/minecraft/runtime/jre-legacy/mac-os/jre-legacy/jre.bundle/Contents/Home/bin/java | |
chmod -rx /Users/$LOCALUSER/Library/Application\ Support/minecraft | |
echo "off" > /var/mc | |
} | |
function mc_on () { | |
# echo "minecraft on" | |
spctl --add --label "Minecraft" /Users/flint/Library/Application\ Support/minecraft/runtime/jre-legacy/mac-os/jre-legacy/jre.bundle/Contents/Home/bin/java | |
spctl --enable --label "Minecraft" | |
chmod +rx /Applications/Minecraft.app/Contents/MacOS/launcher | |
chmod +rx /Applications/CurseForge.app/Contents/MacOS/CurseForge | |
chmod +rx /Applications/Lunar\ Client.app/Contents/MacOS/Lunar\ Client | |
chmod +rx /Applications/Badlion\ Client.app/Contents/MacOS/Badlion\ Client | |
chmod +rx /Users/$LOCALUSER/Library/Application\ Support/minecraft/runtime/jre-legacy/mac-os/jre-legacy/jre.bundle/Contents/Home/bin/java | |
chmod +rx /Users/$LOCALUSER/Library/Application\ Support/minecraft | |
echo "on" > /var/mc | |
} | |
function mc_auto () { | |
case "$(date +%u)" in | |
1) mc_off ;; # monday - no | |
2) (($(date +%H) >= 17)) && (($(date +%H) <= 19)) && mc_on || mc_off ;; # tuesday - 5pm to 7pm | |
3) (($(date +%H) >= 16)) && (($(date +%H) <= 18)) && mc_on || mc_off ;; # wednesday - 4pm to 6pm | |
4) mc_off ;; # thursday - no | |
5) (($(date +%H) > 14)) && mc_on || mc_off ;; # friday - 3 onwards | |
6) (($(date +%H) > 12)) && mc_off || mc_on ;; # sat - up till noon | |
7) (($(date +%H) > 15)) && mc_off || mc_on ;; # sun - up till 3pm | |
esac | |
} | |
function mc_auto_holiday () { | |
case "$(date +%u)" in | |
*) mc_on ;; # monday - no | |
esac | |
} | |
# case "$USER" in | |
# root) ;; | |
# *) echo "please run this script as root" && exit ;; | |
# esac | |
if [ "$(whoami)" != "root" ] | |
then | |
# echo "switching to root" | |
sudo "$0" | |
exit | |
fi | |
case "$1" in | |
on) mc_on ;; | |
off) mc_off ;; | |
*) mc_off ;; | |
esac | |
#*) mc_auto ;; | |
# *) mc_auto_holiday ;; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment