Created
December 13, 2022 19:32
-
-
Save lacostenycoder/1de15cb0f8a6b440da830ac126d0bc32 to your computer and use it in GitHub Desktop.
Toggle showing or hiding MacOS Dock
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
#!/usr/bin/ruby | |
# idea from https://gist.github.com/mattitanskane/43eb9a4b59f16ce46d2a6dbf6c02b87d | |
if ['-h','--hide'].any?{|h| h == ARGV[0]} | |
# Hide Dock | |
shell = <<~BASH | |
defaults write com.apple.dock autohide -bool true && killall Dock | |
defaults write com.apple.dock autohide-delay -float 1000 && killall Dock | |
defaults write com.apple.dock no-bouncing -bool TRUE && killall Dock | |
BASH | |
good = 'hidden' | |
end | |
if ['-s','--show'].any?{|h| h == ARGV[0]} | |
# Restore Dock | |
shell = <<~BASH | |
defaults write com.apple.dock autohide -bool false && killall Dock | |
defaults delete com.apple.dock autohide-delay && killall Dock | |
defaults write com.apple.dock no-bouncing -bool FALSE && killall Dock | |
BASH | |
good = 'shown' | |
end | |
if good | |
system(shell) | |
puts "Your dock is now #{good}!" | |
else | |
puts 'Invalid argument. Valid args: -h, --hide, -s, --show' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment