Using Jiggle to stop a mac going to sleep when playing music

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • b33k34
    Senior Member
    • Mar 2007
    • 109

    Using Jiggle to stop a mac going to sleep when playing music

    Can anyone give me some tips on how to get this to work. Ideally i'd like my mac to go to sleep pretty quickly under normal conditions but stay awake when i'm streaming music to a squeezebox.

    Is there some way of doing this? Running jiggle will just stop the mac sleeping at all - can it be integrated somehow?
  • Eric Seaberg
    Senior Member
    • Oct 2006
    • 818

    #2
    Why is your Mac going to sleep? I'm using a Mini as my server and it's been on for over a year, never going to sleep... even when all of the SB3s and Transporter are off.

    Have you confirmed all of your ENERGY SAVER settings?
    Eric Seaberg - San Diego
    A.E.S., I.E.E.E., S.M.P.T.E., S.P.A.R.S.
    [email protected]
    _____________________________
    Transporter, Multiple Duets and SB3s

    Comment

    • b33k34
      Senior Member
      • Mar 2007
      • 109

      #3
      I've found the power save settings and i'd like to use them to send the mac to sleep when i'm not using it or streaming music - it doesn't need to be on all the time. However, slimserver doesn't get picked up by the mac as 'in use' so i'm looking for a way to over-ride the sleep settings when i'm playing music.

      Comment

      • danco
        Senior Member
        • Apr 2005
        • 1573

        #4
        The Mac should not go to sleep if music is being played from the main hard drive (though I have a vague impression that it has happened once or twice).

        I'm not exactly sure what stops a Mac from sleeping. Certainly any keyboard or mouse activity will prevent sleep. I think activity on the main hard drive will prevent it. I'm not quite sure about external hard drive activity, and I rather think that AlienBBC (which doesn't touch the hard drive) will not prevent sleep.

        Anyway, the way to use Jiggler is to use the Execute Script plugin with suitable scripts (the plugin isn't totally intuitive to set up). The scripts need to be shell scripts, not Applescript, but an Applescript can be run from within an shell script. You can create a suitable script using any text editor (make sure you use Unix line endings), but must make it executable via the Terminal.

        The scripts I use are

        Jiggle:

        #!/bin/bash
        osascript -e 'tell application "Jiggler" to activate' -e 'quit application "Terminal" saving no'

        and Unjiggle:

        #!/bin/bash
        osascript -e 'quit application "Jiggler"' -e 'quit application "Terminal" saving no'

        Jiggle runs on Play or Open File, Unjiggle on Stop or Power Off.

        I also use, with a different plugin (which is slightly more convenient if one has only one script to run), the following script to put the computer to sleep

        Sleeper:

        #!/bin/bash
        osascript -e 'delay 1' -e 'quit application "Terminal" saving no' -e 'tell application "System Events" to sleep'


        Roughly speaking, osascript -e

        means

        treat the bit between the two occurrences of ' as an Applescript

        the second -e is needed for the next line of the Applescript IIRC.

        You can also use a bunch of lines beginning with osascript -e

        and you could call by name an Applescript that has been saved as a file, which is better if the script is more than one or two lines.

        Comment

        • b33k34
          Senior Member
          • Mar 2007
          • 109

          #5
          Originally posted by danco

          Anyway, the way to use Jiggler is to use the Execute Script plugin with suitable scripts (the plugin isn't totally intuitive to set up). The scripts need to be shell scripts, not Applescript, but an Applescript can be run from within an shell script. You can create a suitable script using any text editor (make sure you use Unix line endings), but must make it executable via the Terminal.
          :/ new to mac and new to unix so can you give slightly more idiot proof instructions!
          - Suitable text editor on the mac?
          - unix line endings?
          - make executable via the Terminal?

          thanks

          Comment

          • danco
            Senior Member
            • Apr 2005
            • 1573

            #6
            Originally posted by b33k34
            :/ new to mac and new to unix so can you give slightly more idiot proof instructions!
            - Suitable text editor on the mac?
            - unix line endings?
            - make executable via the Terminal?

            thanks
            TextWrangler is good, and free. TextEdit (which comes with the Mac) not so good, as its default is Rich Text Format, rather than plain text; also I forget if it will save with Unix endings. Also TextWrnagler, in the Text Files section of the preferences has an option (it may be the default) to use Unix line endings.

            Briefly, the difference between Mac and Unix line endings used to be that Unix used Line Feed for a new line while Mac used Carriage Return (and, I think, Windows uses Carriage Return plus Line Feed). I have a vague memory that recent versions of Mac OS do use Line Feed as the default for a new line, but some older text editors still use Carriage Reutrn.


            Anyway, bottom line here is to download (Google to find it) and use TextWrangler.

            Make executable. Read and write permissions on a file can be changed by getting information on the file, but unfortunately execute permissions (which, in this context, means whether an alleged application can actually be run) have to be set via the Terminal.

            Terminal is an application found in the Utilities folder that provides an interface with the Unix underpinnings of OS X.

            Run terminal, and on the line that you get, type

            chmod a+x

            followed by a space

            In Unix you would have to follow this by typing the full name of the file you want to make executable (full name meaning the complete path to it, going through all relevant folders). In the Mac OS, the GUI kicks in and you don't have to type the name, instead you can just drag the file into the terminal window and its name gets filled in for you.

            So at this point you are looking at a line which (after the initial prompt, which looks something like computername: ~username$) reads

            chmod a+x fullfilename

            Just press Return and the command gets run and you are back in the prompt (you won't actually see the action, but it will be done).

            If you want to investigate and see what has happened, before doing the chmod, type ls -l followed by a space and drag the file to the window and press Return, and do the same again after doing the chmod.

            Before it will read something like
            -rw-r--r-- plus other stuff,

            and after it will say something like -rwxr-xr-x plus other sutff.

            If you really want to know more (and it can be worthwhile) look at either an introductory book on Unix or a book on Mac and Unix.

            Comment

            • ks10
              Member
              • Mar 2007
              • 55

              #7
              danco, thank you for your detailed description, but let me know:

              which plugin do you use to activate the scripts on start / pause / stop. i looked for available plugins and most are inactive - like bandwith sleeper (by the way I could send it to you).

              thanks.
              ks10

              Comment

              • danco
                Senior Member
                • Apr 2005
                • 1573

                #8
                I am not entirely sure which plugins are currently available for which versions of SlimServer/Squeezecenter. I think they are ok in 6.5.x but may not for 7 as yet.

                I use Execute Script for keeping the machine awake via Jiggler, and for switching Jiggler off, and ShutdownServer (which can actually run any script) for putting the server to sleep.

                One does not actually need ShutdownServer, but I find it slightly easier to use than Execute Script for the occasions when it is needed.

                Comment

                Working...