Go Back   The macosxhints Forums > OS X Help Requests > System



Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 2.50 average. Display Modes
Old 10-06-2012, 11:00 AM   #1
cpragman
All Star
 
Join Date: Jan 2004
Location: Limerick, PA
Posts: 687
Want a means to gracefully quit iTunes running in another user's account

Background:
My family all shares a single iTunes library, located in a shared folder. This has worked well for years, but has one mild annoyance. Only one user can be running iTunes at a time, since the library is locked when in use. Sometimes another user wants to run iTunes, but first needs to log-in as another user to quit their running iTunes, then switch back to their account to launch it again.

With kids in the house, this is not optimal, as we don't want them having the login passwords of the adults.

I've tried using force quit, and the UNIX kill command to stop iTunes running when it is in use by another user, but neither of these has been desirable, because they don't get Tunes to quit gracefully (like using the Quit menu item does). For example, sending "killall -v -TERM -c 'iTunes' " causes a instantaneous quit, and the next time iTunes is launched, it has to rebuild it's library.

The Question:
I'm looking for a UNIX command that can tell iTunes to Quit gracefully. Once I have that, I can throw together a shell script that User X can run that will close iTunes in User Y's account.

Last edited by cpragman; 10-06-2012 at 11:14 AM.
cpragman is offline   Reply With Quote
Old 10-06-2012, 01:48 PM   #2
NaOH
Hall of Famer
 
Join Date: Dec 2007
Posts: 3,642
I have no help to offer with the solution you're proposing, but I'm wondering if enabling Sharing in the iTunes Preferences of each account would work as an alternative.
NaOH is online now   Reply With Quote
Old 10-06-2012, 03:04 PM   #3
chabig
Hall of Famer
 
Join Date: Jan 2002
Posts: 2,934
I think the media should be on a shared volume, but each account should have its own library. You'll have to start each iTunes account with a blank library. Then drag the shared media folder onto the iTunes window while holding down the option key. That'll tell iTunes to use that media without copying it.
chabig is offline   Reply With Quote
Old 10-06-2012, 08:02 PM   #4
acme.mail.order
League Commissioner
 
Join Date: Sep 2003
Location: Tokyo
Posts: 6,050
sudo -u otherusername osascript -e 'tell application "iTunes" to quit'


Sharing sounds like a cleaner option.
acme.mail.order is offline   Reply With Quote
Old 10-06-2012, 08:37 PM   #5
ganbustein
MVP
 
Join Date: Apr 2008
Location: Berkeley CA USA
Posts: 1,010
Quote:
Originally Posted by acme.mail.order
sudo -u otherusername osascript -e 'tell application "iTunes" to quit'

That would require letting the kids know an admin password.
ganbustein is offline   Reply With Quote
Old 10-06-2012, 08:44 PM   #6
acme.mail.order
League Commissioner
 
Join Date: Sep 2003
Location: Tokyo
Posts: 6,050
Ah, you want the one-click child-and-management-proof option?

Write a stone-simple C program that runs the above command for all regular users (minus `sudo`). Compile, test, set the suid bit and change the owner to root. Now write an Applescript to simply call it with `do shell script`, followed by `open iTunes.app`.
acme.mail.order is offline   Reply With Quote
Old 10-07-2012, 05:01 PM   #7
cpragman
All Star
 
Join Date: Jan 2004
Location: Limerick, PA
Posts: 687
Does it have to be a C program, or can a shell script also run with setuid?
cpragman is offline   Reply With Quote
Old 10-07-2012, 05:45 PM   #8
ganbustein
MVP
 
Join Date: Apr 2008
Location: Berkeley CA USA
Posts: 1,010
No. suid is ignored on shell scripts. (It would be too easy to invade a system otherwise.)
ganbustein is offline   Reply With Quote
Old 10-07-2012, 06:48 PM   #9
acme.mail.order
League Commissioner
 
Join Date: Sep 2003
Location: Tokyo
Posts: 6,050
We're not talking a complex XCode project here:
Code:
#include <stdlib.h>

int main (int argc, char *argv[])
{
   system("your shell command here");
   return 0;
}
acme.mail.order is offline   Reply With Quote
Old 10-10-2012, 06:58 PM   #10
cpragman
All Star
 
Join Date: Jan 2004
Location: Limerick, PA
Posts: 687
Perhaps something like this? Figuring out the escaping of all the quotes took a few tries.



Quote:
#include <stdio.h>
#include <stdlib.h>

int main (int argc, char *argv[])

{
system( "osascript -e \'tell application \"iTunes\" to quit\' " );


return 0;
}

cpragman is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting 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

Forum Jump



All times are GMT -5. The time now is 06:53 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.