alfred-2-caffeinate-workflow
alfred-2-caffeinate-workflow copied to clipboard
Caffeinate is not running even after trying to enable multiple times
I just pushed a new version (both here and) to Packal. It fixes some problems with Alfred 3 compatibility, perhaps this is what was happening. If not, can you let me know what version of Alfred you're running and what version of OSX?
Okay, it seems to be working fine now, altho at first right after fresh install when I typed "caff" it shows up as "is active" even tho that's the first time I run it. And when I try to disable it, it still showed up as "active". But after trying different commands several more time, it behaves correctly.
FYI, yes, I'm running Alfred 3 and my OS version is El Capitan 10.11.5
Thanks for the update!
@shawnrice I still seem to have this issue where I activate caffeine but my computer still goes to sleep.
I too am having the issue where I activate the workflow, typing caff reports that caffeinate is running, but my computer still goes to sleep.
I am running Alfred v3.3 and MacOS Sierra 10.12.3.
caffeinate is available at my command line and is on my PATH, and making the command line calls directly keeps my computer awake as I would expect.
I take it back, the binary caffeinate command does NOT seem to be working as I expect when invoked from the command line. I would have sworn it worked when I first posted, but it's back to seemingly not working. However, trying again, it seems that the command does nothing.
Caffeinate has different options and controls different aspects of what can go to sleep. Here is the man page:
CAFFEINATE(8) BSD System Manager's Manual CAFFEINATE(8)
NAME
caffeinate -- prevent the system from sleeping on behalf of a utility
SYNOPSIS
caffeinate [-disu] [-t timeout] [-w pid] [utility arguments...]
DESCRIPTION
caffeinate creates assertions to alter system sleep behavior. If no assertion flags are specified, caffeinate creates an assertion to
prevent idle sleep. If a utility is specified, caffeinate creates the assertions on the utility's behalf, and those assertions will per-
sist for the duration of the utility's execution. Otherwise, caffeinate creates the assertions directly, and those assertions will per-
sist until caffeinate exits.
Available options:
-d Create an assertion to prevent the display from sleeping.
-i Create an assertion to prevent the system from idle sleeping.
-m Create an assertion to prevent the disk from idle sleeping.
-s Create an assertion to prevent the system from sleeping. This assertion is valid only when system is running on AC power.
-u Create an assertion to declare that user is active. If the display is off, this option turns the display on and prevents the dis-
play from going into idle sleep. If a timeout is not specified with '-t' option, then this assertion is taken with a default of 5
second timeout.
-t Specifies the timeout value in seconds for which this assertion has to be valid. The assertion is dropped after the specified
timeout. Timeout value is not used when an utility is invoked with this command.
-w Waits for the process with the specified pid to exit. Once the the process exits, the assertion is also released. This option is
ignored when used with utility option.
EXAMPLE
caffeinate -i make
caffeinate forks a process, execs "make" in it, and holds an assertion that prevents idle sleep as long as that process is running.
SEE ALSO
pmset(1)
LOCATION
/usr/bin/caffeinate
So typing caffeinate -d will prevent the display from sleeping. caffeinate -i will prevent the system from idling (although the display might still sleep). caffeinate -m keeps the disks from sleeping (but the display might still sleep). caffienate -s keeps the system from sleeping (but the display might still sleep). caffeinate -u makes the computer stay on entirely (even if it's a laptop and close it).
The -t option is time in seconds. So caffeinate -dism -t 3600 is most likely what you want to achieve to keep the computer "awake." The workflow reads the preferences of what you want to set and inserts these as arguments. If the preferences aren't saving, then that's a different story and my error, but I'd recommend configuring the workflow like this:

to achieve the effect of the computer being awake.
I face the same issue. If I run caff 23 through Alfred workflow, I get a notification saying it's active. But the workflow still says it's not active. If i manually run caffeinate on the terminal, the workflow correctly identifies it as active.
Looks like this might not be maintained but I got the same issue and found a work around.
If you switch on debug in Alfred (I am using Alfred 4) I got this error:
STDERR: Caffeinate v3.03.0[Script Filter] mkdir: /Users/<myID>/Library/Application Support/Alfred 2/Workflow Data: No such file or directory
So I created this directory in the terminal and it worked.
I think the issue is in file library.sh it doesn't check for Alfred 4