Skip to main content
added 94 characters in body
Source Link
nohillside
  • 104.4k
  • 42
  • 222
  • 275

I developed the following simple Launch Daemon to provide a 'wake' trigger for scripts on Leopard:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>wake-alert</string>
    <key>ProgramArguments</key>
    <array>
        <string>/bin/bash</string>
        <string>-c</string>
        <string>z=/tmp/wake; test -s $z || { date > $z; say w; }; 
tail -1 /Library/Logs/DirectoryService/DirectoryService.server.log | grep -v Sleep || > $z
        </string>
    </array>
    <key>WatchPaths</key>
    <array>
        <string>/Library/Logs/DirectoryService/DirectoryService.server.log</string>
    </array>
    <key>ExitTimeOut</key>
    <integer>2</integer>
    <key>ThrottleInterval</key>
    <integer>1</integer><integer>
</dict>
</plist>

You can replace 'say w' with your code. I write a date to z but you could change this to write anything. You may need to increase 'ExitTimeOut' for some scripts. My Launch Daemon resides at /Library/LaunchDaemons/wake-alert.plist

The Launch Daemon watches DirectoryService.server.log and writes to a temporary file provided the file is empty. The file is cleared by a log 'Sleep' entry and by Shut Down.

If you use 'fast user switching' to sleep you will find that scripts which require a logged in user will attempt to run too early and fail unless you modify the Launch Daemon - perhaps grep 'Succeeded' in 'secure.log'.

I developed the following simple Launch Daemon to provide a 'wake' trigger for scripts on Leopard:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>wake-alert</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>-c</string>
<string>z=/tmp/wake; test -s $z || { date > $z; say w; }; 
tail -1 /Library/Logs/DirectoryService/DirectoryService.server.log | grep -v Sleep || > $z
</string>
</array>
<key>WatchPaths</key>
<array>
<string>/Library/Logs/DirectoryService/DirectoryService.server.log</string>
</array>
<key>ExitTimeOut</key>
<integer>2</integer>
<key>ThrottleInterval</key>
<integer>1</integer></dict>
</plist>

You can replace 'say w' with your code. I write a date to z but you could change this to write anything. You may need to increase 'ExitTimeOut' for some scripts. My Launch Daemon resides at /Library/LaunchDaemons/wake-alert.plist

The Launch Daemon watches DirectoryService.server.log and writes to a temporary file provided the file is empty. The file is cleared by a log 'Sleep' entry and by Shut Down.

If you use 'fast user switching' to sleep you will find that scripts which require a logged in user will attempt to run too early and fail unless you modify the Launch Daemon - perhaps grep 'Succeeded' in 'secure.log'.

I developed the following simple Launch Daemon to provide a 'wake' trigger for scripts on Leopard:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>wake-alert</string>
    <key>ProgramArguments</key>
    <array>
        <string>/bin/bash</string>
        <string>-c</string>
        <string>z=/tmp/wake; test -s $z || { date > $z; say w; }; 
tail -1 /Library/Logs/DirectoryService/DirectoryService.server.log | grep -v Sleep || > $z
        </string>
    </array>
    <key>WatchPaths</key>
    <array>
        <string>/Library/Logs/DirectoryService/DirectoryService.server.log</string>
    </array>
    <key>ExitTimeOut</key>
    <integer>2</integer>
    <key>ThrottleInterval</key>
    <integer>1</integer>
</dict>
</plist>

You can replace 'say w' with your code. I write a date to z but you could change this to write anything. You may need to increase 'ExitTimeOut' for some scripts. My Launch Daemon resides at /Library/LaunchDaemons/wake-alert.plist

The Launch Daemon watches DirectoryService.server.log and writes to a temporary file provided the file is empty. The file is cleared by a log 'Sleep' entry and by Shut Down.

If you use 'fast user switching' to sleep you will find that scripts which require a logged in user will attempt to run too early and fail unless you modify the Launch Daemon - perhaps grep 'Succeeded' in 'secure.log'.

Mid-command line feeds removed to reduce errors
Source Link

I developed the following simple Launch Daemon to provide a 'wake' trigger for scripts on Leopard:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 
 "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>wake-alert</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>-c</string>
<string>z=/tmp/wake; test -s $z || { date > $z; say w; } ; \
tail -1 /Library/Logs/DirectoryService/DirectoryService.server.log \
| grep -v Sleep || > $z<$z
</string>
</array>
<key>WatchPaths</key>
<array>
<string>/Library/Logs/DirectoryService/DirectoryService.server.log</string>
</array>
<key>ExitTimeOut</key>
<integer>2</integer>
<key>ThrottleInterval</key>
<integer>1</integer></dict>
</plist>

You can replace 'say w' with your code. I write a date to z but you could change this to write anything. You may need to increase 'ExitTimeOut' for some scripts. My Launch Daemon resides at /Library/LaunchDaemons/wake-alert.plist

The Launch Daemon watches DirectoryService.server.log and writes to a temporary file provided the file is empty. The file is cleared by a log 'Sleep' entry and by Shut Down.

If you use 'fast user switching' to sleep you will find that scripts which require a logged in user will attempt to run too early and fail unless you modify the Launch Daemon - perhaps grep 'Succeeded' in 'secure.log'.

I developed the following simple Launch Daemon to provide a 'wake' trigger for scripts on Leopard:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 
 "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>wake-alert</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>-c</string>
<string>z=/tmp/wake; test -s $z || { date > $z; say w; } ; \
tail -1 /Library/Logs/DirectoryService/DirectoryService.server.log \
| grep -v Sleep || > $z</string>
</array>
<key>WatchPaths</key>
<array>
<string>/Library/Logs/DirectoryService/DirectoryService.server.log</string>
</array>
<key>ExitTimeOut</key>
<integer>2</integer>
<key>ThrottleInterval</key>
<integer>1</integer></dict>
</plist>

You can replace 'say w' with your code. I write a date to z but you could change this to write anything. You may need to increase 'ExitTimeOut' for some scripts. My Launch Daemon resides at /Library/LaunchDaemons/wake-alert.plist

The Launch Daemon watches DirectoryService.server.log and writes to a temporary file provided the file is empty. The file is cleared by a log 'Sleep' entry and by Shut Down.

If you use 'fast user switching' to sleep you will find that scripts which require a logged in user will attempt to run too early and fail unless you modify the Launch Daemon - perhaps grep 'Succeeded' in 'secure.log'.

I developed the following simple Launch Daemon to provide a 'wake' trigger for scripts on Leopard:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>wake-alert</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>-c</string>
<string>z=/tmp/wake; test -s $z || { date > $z; say w; }; 
tail -1 /Library/Logs/DirectoryService/DirectoryService.server.log | grep -v Sleep || > $z
</string>
</array>
<key>WatchPaths</key>
<array>
<string>/Library/Logs/DirectoryService/DirectoryService.server.log</string>
</array>
<key>ExitTimeOut</key>
<integer>2</integer>
<key>ThrottleInterval</key>
<integer>1</integer></dict>
</plist>

You can replace 'say w' with your code. I write a date to z but you could change this to write anything. You may need to increase 'ExitTimeOut' for some scripts. My Launch Daemon resides at /Library/LaunchDaemons/wake-alert.plist

The Launch Daemon watches DirectoryService.server.log and writes to a temporary file provided the file is empty. The file is cleared by a log 'Sleep' entry and by Shut Down.

If you use 'fast user switching' to sleep you will find that scripts which require a logged in user will attempt to run too early and fail unless you modify the Launch Daemon - perhaps grep 'Succeeded' in 'secure.log'.

ExitTimeOut increased from 1 to 2
Source Link

I developed the following simple Launch Daemon to provide a 'wake' trigger for scripts on Leopard:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>wake-alert</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>-c</string>
<string>z=/tmp/wake; test -s $z || { date > $z; say w; } ; \
tail -1 /Library/Logs/DirectoryService/DirectoryService.server.log \
| grep -v Sleep || > $z</string>
</array>
<key>WatchPaths</key>
<array>
<string>/Library/Logs/DirectoryService/DirectoryService.server.log</string>
</array>
<key>ExitTimeOut</key>
<integer>1<<integer>2</integer>
<key>ThrottleInterval</key>
<integer>1</integer></dict>
</plist>

You can replace 'say w' with your code. I write a date to z but you could change this to write anything. You may need to increase 'ExitTimeOut' for some scripts. My Launch Daemon resides at /Library/LaunchDaemons/wake-alert.plist

The Launch Daemon watches DirectoryService.server.log and writes to a temporary file provided the file is empty. The file is cleared by a log 'Sleep' entry and by Shut Down.

If you use 'fast user switching' to sleep you will find that scripts which require a logged in user will attempt to run too early and fail unless you modify the Launch Daemon - perhaps grep 'Succeeded' in 'secure.log'.

I developed the following simple Launch Daemon to provide a 'wake' trigger for scripts on Leopard:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>wake-alert</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>-c</string>
<string>z=/tmp/wake; test -s $z || { date > $z; say w; } ; \
tail -1 /Library/Logs/DirectoryService/DirectoryService.server.log \
| grep -v Sleep || > $z</string>
</array>
<key>WatchPaths</key>
<array>
<string>/Library/Logs/DirectoryService/DirectoryService.server.log</string>
</array>
<key>ExitTimeOut</key>
<integer>1</integer>
<key>ThrottleInterval</key>
<integer>1</integer></dict>
</plist>

You can replace 'say w' with your code. I write a date to z but you could change this to write anything. You may need to increase 'ExitTimeOut' for some scripts. My Launch Daemon resides at /Library/LaunchDaemons/wake-alert.plist

The Launch Daemon watches DirectoryService.server.log and writes to a temporary file provided the file is empty. The file is cleared by a log 'Sleep' entry and by Shut Down.

If you use 'fast user switching' to sleep you will find that scripts which require a logged in user will attempt to run too early and fail unless you modify the Launch Daemon - perhaps grep 'Succeeded' in 'secure.log'.

I developed the following simple Launch Daemon to provide a 'wake' trigger for scripts on Leopard:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>wake-alert</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>-c</string>
<string>z=/tmp/wake; test -s $z || { date > $z; say w; } ; \
tail -1 /Library/Logs/DirectoryService/DirectoryService.server.log \
| grep -v Sleep || > $z</string>
</array>
<key>WatchPaths</key>
<array>
<string>/Library/Logs/DirectoryService/DirectoryService.server.log</string>
</array>
<key>ExitTimeOut</key>
<integer>2</integer>
<key>ThrottleInterval</key>
<integer>1</integer></dict>
</plist>

You can replace 'say w' with your code. I write a date to z but you could change this to write anything. You may need to increase 'ExitTimeOut' for some scripts. My Launch Daemon resides at /Library/LaunchDaemons/wake-alert.plist

The Launch Daemon watches DirectoryService.server.log and writes to a temporary file provided the file is empty. The file is cleared by a log 'Sleep' entry and by Shut Down.

If you use 'fast user switching' to sleep you will find that scripts which require a logged in user will attempt to run too early and fail unless you modify the Launch Daemon - perhaps grep 'Succeeded' in 'secure.log'.

Adding your code simplified, fast user switching note, ExitTimeOut and ThrottleInterval added
Source Link
Loading
Removed incorrect statement
Source Link
Loading
Source Link
Loading