and then a binary number echo Usage: Enter 1..." /> and then a binary number echo Usage: Enter 1..." />

Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Enable/Disable Mac Widgets Bash Script
02-08-2010, 12:22 PM (This post was last modified: 02-09-2010 09:38 AM by codecaine.)
Post: #1
Enable/Disable Mac Widgets Bash Script
It is good to disable widgets to save memory if your computer does not have much.
Code:
#!/bin/bash

usage()
{
    #echos program name which is $0 and then a binary number
    echo "Usage: Enter 1 to enable or 0 to disable as the script parameter";
        echo "$0 1"
}


if [ $# -gt 0 ]; then
    if [ $1 -eq 1 ]; then
        defaults write com.apple.dashboard mcx-disabled -boolean NO
    echo "enabled widgets"
        killall Dock
    elif [ $1 -eq 0 ]; then
        defaults write com.apple.dashboard mcx-disabled -boolean YES
    echo "disabled widgets"
        killall Dock
    else
        usage;
    fi
else
   usage;    
fi
Visit this user's website Find all posts by this user
Quote this message in a reply
02-08-2010, 11:46 PM
Post: #2
RE: Enable/Disable Mac Widgets Bash Script
I don't use MAC. But in Windows i have a tool for enabling and disabling services.

"I dont know with what weapons World War 3 will be fought with, but i know World War 4 will be fought with stones and sticks" - Albert Einstein
Visit this user's website Find all posts by this user
Quote this message in a reply
02-09-2010, 08:02 AM
Post: #3
RE: Enable/Disable Mac Widgets Bash Script
what exactly does "fi" do in bash?
Visit this user's website Find all posts by this user
Quote this message in a reply
02-09-2010, 09:33 AM (This post was last modified: 02-09-2010 09:40 AM by codecaine.)
Post: #4
RE: Enable/Disable Mac Widgets Bash Script
end a if statement in bash closing statements is the word spelled backwords unless its a loop then you use done. like for a case statement beginning->case end-> esac
I made a correction to my script I had if [ $# > 1 ]; then instead of if [ $# -gt 0 ]; then what my first statement was doing it justing making a file name 1 in the current directory lol
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


 Quick Theme: