Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Applescript to apply terminal commands.

Applescript to apply terminal commands.
Thread Tools
Fresh-Faced Recruit
Join Date: Jan 2009
Location: Rip off Britain
Status: Offline
Reply With Quote
May 21, 2011, 02:03 AM
 
Hi there chaps, (With the help of Automator maybe), there is something I've been trying to achieve for a little while, with virtually no success I might add.
Every time a new MacOS is released there are a number of hidden terminal commands I like to play around with. Entering these into terminal though is getting to be a bit of a hassle.
What I wanted to do was have an Applescript application I could write which I could double click that would;
When run, just pop up a dialog box asking me whether I want to apply or remove an effect.
I had thought about something along these lines;
This section is the initial pop up I want to appear when the script is run.
display dialog "Please make your choice" buttons {"Apply Effect, or...", "Remove Effect"} default button 2 with icon 1
--> {button returned:"Remove Effect"}
end
This section is the what I want to appear next, so that if I choose Apply one list of selections will appear and if I choose Remove an alternate list of selections will appear - I'm only showing a few choices for ease.
set hacks_ to {"View hidden files", "Alter iTunes Contrast"}
set chosen_ to (choose from list hacks_ with prompt "Choose your Hack." without multiple selections allowed) as text
if chosen_ is ......... then
end if
In the next section, I would like to have the choice previously made point to and run certain shell scripts- for example:
The View hidden files choice would refer to : defaults write com.apple.finder ShowAllFiles TRUE
The Alter iTunes contrast choice would refer to : defaults write com.apple.iTunes high-contrast-mode-enable -bool TRUE

Any help would be much appreciated.
(Last edited by Bravestarr; May 21, 2011 at 03:44 AM. )
     
Fresh-Faced Recruit
Join Date: Jan 2009
Location: Rip off Britain
Status: Offline
Reply With Quote
May 21, 2011, 03:54 AM
 
I think I'm getting it, this is where I am so far;
display dialog "Please make your choice" buttons {"Apply Effect, or...", "Remove Effect"} default button 2 with icon 1
--> {button returned:"Remove Effect"}
end
set hack_ to {"View hidden files", "Alter iTunes Contrast"}
set chosen_ to (choose from list hack_ with prompt "Choose your Hack." without multiple selections allowed) as text
if chosen_ is "View hidden files" then
do shell script "defaults write com.apple.finder ShowAllFiles TRUE"
else if chosen_ is "Alter iTunes Contrast" then
do shell script "defaults write com.apple.iTunes high-contrast-mode-enable -bool TRUE"
end if

With the exception of having two different lists it seems to be getting there. I can't seem to get the set button returned thing to point at a certain action.
(Last edited by Bravestarr; May 21, 2011 at 04:17 AM. )
     
Fresh-Faced Recruit
Join Date: Jan 2009
Location: Rip off Britain
Status: Offline
Reply With Quote
May 21, 2011, 06:09 AM
 
I must apologise, some reading, (here and elsewhere), and experimenting brought me to a satisfactory solution.
Tks.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:58 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2