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.

We attack any new problem we encounter with techniques we already know, and try small modifications if difficulties turn up.
Bram Cohen - Bit Torrent Creator
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?

"Character is determined more by the lack of certain experiences than by those one has had."
Friedrich Nietzsche
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: