- Joined
- Nov 4, 2016
- Messages
- 80
- Motherboard
- Asus Z690 Creator Wifi
- CPU
- i7 -12700K
- Graphics
- AMD RX 6600XT
- Mac
- Mobile Phone
Hi Byteminer,I might be able to help with this.
Initially I also ran into this problem because by design, Yoda has to be running continuously given that it has to check for changes in temperature to adjust the fan and pump speeds.
This is in contrast to liquidctl, which dispatches its fan and pump profiles to the actual device, hence the script can quit once the data has been written. Of course that makes it very simple to run as a launch agent since it only has to run once and then quit.
With yoda, we have to take a slightly more advanced approach to run it as some kind of background service.
As a preface, I'm not an expert on how macOS operates and while my solution may work, it might not be optimal. Nevertheless, here we go.
Overall, I ran into two problems while trying to get Yoda to run as a background service:
1. Yoda has to run continuously
2. liquidctl may raise an OSError: Failed to open if we access the Kraken or the Smart Device too quickly
To circumvent 1. I made use a of a very useful little utility from Linux: screen
This command-line tool will allow us to create multiple "headless" terminal sessions in which we can run commands programmatically without having to bother with i.e. Terminal.app. I'm using this to dispatch my yoda commands into their individual shell environments where they can keep running indefinitely.
An added bonus is that we can attach to any of these sessions later on to check the output of the script, for example.
Tackling 2. is rather simple: We use the sleep command to wait a little between each command we issue to our cooling devices to prevent hammering the tiny embedded processors in them too much.
Wrapping this knowledge up in a script nets us something like this:
Bash:#!/bin/bash # Init the Smart Device liquidctl initialize -d 0 sleep 1 # Init the Kraken liquidctl initialize -d 1 sleep 1 # Configure lighting (all off in this case) liquidctl -d 0 set led color off liquidctl -d 1 set ring color off liquidctl -d 1 set logo color off sleep 1 # Start Yoda for Kraken screen -d -m -S yoda-kraken bash -c 'yoda --match "Kraken" control pump with "(60,40),(90,90)" on istats.cpu and fan with "(60,20),(90,50)" on istats.cpu' sleep 1 # Start Yoda for Smart Device screen -d -m -S yoda-smart-device bash -c 'yoda --match "Smart Device" control fan2 with "(60,30),(90,85)" on istats.cpu and fan3 with "(60,30),(90,50)" on istats.cpu'
Please take care to adjust the CPU temperatures and fan values to your system!
The ones shown here are exemplary and will likely only work well with my specific cooling setup and ambient temperature.
Save this script somewhere, i.e. in /Users/Shared/yodactl.sh, similar to what was done with the original liquidctl script.
Please note that this script will supersede liquidctl.sh as it handles the initialisation as well as the fan control!
We can now register a new LaunchAgent in /Library/LaunchAgents/.
Before doing this, please remove the original LaunchAgent for liquidtcl.sh, we won't need it anymore.
After this is done, we can register the new agent as follows:
XML:<?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>liquidctl.sh</string> <key>ProgramArguments</key> <array> <string>/Users/Shared/yodactl.sh</string> </array> <key>RunAtLoad</key> <true/> <key>KeepAlive</key> <false/> <key>EnvironmentVariables</key> <dict> <key>PATH</key> <string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string> </dict> </dict> </plist>
Note that I add the PATH environment variable to point to my Python installation. By default this should not be necessary, however if you have installed multiple versions of Python, i.e. using Homebrew, Pyenv, Conda or what have you, then you should tweak this path to primarily point to the location of the installation that actually has liquidctl installed.
In my case I am using Conda, so my path would have the first component: /usr/local/Caskroom/miniconda/base/envs/<conda_evironment_name>/bin
After setting everything up as described above, your cooling devices should be initialized a few seconds after login and yoda should be running and handling fan control.
You can verify this with two methods:
- Open Terminal.app and run: screen -ls
This should show you two screens with the names from the script and the status Detached
- Run a benchmarking tool like Cinebench to load the system and listen for the fans spinning up.
If they do, everything is working. If they don't, immediately abort the program to avoid overheating.
As a general note, the timing of the sleep calls could probably be shortened with some trial and error, but I find that these values work alright in most cases, so I didn't bother tuning them down to the minimum delay possible. Given that it's likely to differ from system to system, sticking with slightly higher sleep values seems the safer choice in my eyes.
I am building a Hackintosh with Kraken X52 which already works with liquidctl and have been very interested in using Yoda with iStats for relying on CPU temp directly.
But I struggle to get the script for Yoda launching correctly at startup. Maybe you can help me on this?
I will try to explain this the best I can with my bad English and light Bash skills...
-I installed "liquidctl" and "yoda" using "pip3 install" command (as recommended by Jonas to have the access to istats.cpu function) as well as istats
-I can correctly see kraken and sensors, and also send commands with liquidctl and yoda with responding fan/pump behaviour. Yoda is showing the istats.cpu temp with "show-sensors" command. The only thing different for "yoda" is that I have to specify the /usr/bin/yoda path to have the command working (maybe I didn't install at the right place?)
-I managed to have the LaunchAgent working for regular liquidctl, as explained in first page guide by @CaseySJ and it's working on startup, loading the fan and pump properties
-I followed your post about replacing this script by a script for yoda to run instead, removed the former liquidctl.plist in LaunchAgents and replaced by a new one. I've made some little changes because I don't care about the led color things and also I wanted to have a liquidctl settings applied before yoda in case this one fails at some point (I realised when doing some tests that when yoda execution was stopped the behaviour of Kraken was returning to the last profile that had been set with liquidctl)
Se here are my yodactl.sh script
Code:
#!/bin/bash
# Init the Kraken
liquidctl initialize
sleep 1
# Set base fan profile for Kraken
liquidctl set fan speed 20 35 30 40 40 50 50 60 60 80
sleep 1
# Set base Pump profile for Kraken
liquidctl set pump speed 20 50 60 100
sleep 1
# Start Yoda for Kraken
screen -d -m -S yoda-kraken bash -c '/usr/bin/yoda --match "Kraken" control pump with "(20,50),(80,90)" on istats.cpu and fan with "(20,30),(50,35),(60,40),(70,45),(90,80)" on istats.cpu'
And my yodactl.plist Launch Agent (which is same as yours)
Code:
<?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>liquidctl.sh</string>
<key>ProgramArguments</key>
<array>
<string>/Users/Shared/yodactl.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
</dict>
</dict>
</plist>
As a result, when booting up, the scripts seems to load because I can hear that the liquidctl "base" profiles are applied, but the yoda part doesn't load (I can hear the difference in term of fan noise). The "screen -ls" command doesn't give me anything neither.
But if I open terminal and copy paste the command (#Start Yoda for Kraken), it works! I just don't understand why this doesn't work at startup load. I tried removing the /usr/bin path I added without change. Tried to remove the KeepAlive / False variable in the Launch Agent. Tried to increase the sleep command value to 2.
Any idea?
Thanks