If you use any of the Logitech solar keyboards on the Mac, you’ll sooner or later find out that Logitech provides this really cool application that lets you see how charged your keyboard is, but additionally, the amount of light (in lux, approximately of course) that the solar cells are getting. While the application is awesome, it does have a minor issue: it runs a service which does not terminate with the application, and writes several lines to your log every second until the keyboard hits a timeout. Not only is this wasteful of system resources, it also will fill up your disk with meaningless log entries. Fortunately, the fix is easy since your Mac provides all the tools you need:
Note: This assumes you’re using the Solar App installed from the Mac App store. It will probably work just fine if you have the Solar App from Logitech’s website, but I have only tested the App Store version.
- Copy this script somewhere to your hard drive. It doesn’t matter where you put it, as long as you can remember the full path to it. Personally, I use the
bindirectory in my home directory, so my file would be
#!/bin/bash if [[ "`pgrep Solar Service`" != "" && "`pgrep Solar App`" = "" ]]; then killall Solar Service fi
This script will terminate the Solar Service if it is running, but only if the Solar App (which requires it) is not running.
- Set the file as executable. From the console, substituting the path to your file:
chmod +x /Users/tom/bin/kill-solar-service.sh
- Edit your crontab. This will call whatever application is specified in the
EDITORshell variable to edit your crontab. Again, from the console:
Use caution if you use your crontab. It’s very easy to fat-finger and hit -r by mistake (e and r are next to each other on the keyboard, and -r will cause the system to remove rather than edit your crontab.
- Add the following line to your crontab, substituting the path to your file:
*/5 * * * * /Users/tom/bin/kill-solar-service.sh
This cron entry tells the Mac to run that script every 5 minutes. There’s no need to run it any more often than that.
That’s it! That’s all there is to it. Every 5 minutes, your Mac will dutifully check if the Solar Service is running unnecessarily, and terminate it. Problem solved.