Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Unix Toggle Script' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Unix Toggle Script
Authored by: pobs on Aug 03, '05 03:31:33AM
Hello all,

Thank you for this script... it certainly seems to be useful for those who are wont for power (every process that isn't in use can save a few minutes of juice).

I made this simple bash script that toggles the "defaults write" command based on what it is currently set to. I'd like to share it with you all... for those who would rather use a unix script than another prefpane binary to handle this... or for those who like to muck around with unix like me :) . Improvements are welcome and I suppose you could use the same format with other 'defaults' settings.

Thoughts? comments? flames?

Best,
pobs
 
#!/bin/sh

#function to evaluate whether the widgets are on or off
function evalwidgets {
         domainvar="com.apple.dashboard mcx-disabled"
         defaults read $domainvar
return ; }

#case statement to decide whether to turn widgets on or off
case $( evalwidgets ) in
        1 )
                echo "TURNING ON WIDGETS"
                evalwidgets
                defaults write com.apple.dashboard mcx-disabled -boolean NO;;
        0 )
                echo "TURNING OFF WIDGETS"
                evalwidgets
                defaults write com.apple.dashboard mcx-disabled -boolean YES;;
        !1 | !0 )
                echo "this is the result of evalwidgets function..."
                evalwidgets
                echo "..."
                echo "sumpin aint workin";;
esac

#kill the dock to put the widget call in effect
killall "Dock"


[ Reply to This | # ]