822
Mp
macotron-plugin-caffeinate / files
macotron-plugin-caffeinate / README.md
1.9 KB
1# Caffeinate for Macotron 2 3Keep the Mac awake from the [Macotron](https://github.com/statico/macotron) menu bar. One click runs `caffeinate -dim`. Click again and that process stops. No terminal window stays open. 4 5- Click the cup to turn caffeinate on or off. 6- Right-click or Control-click the cup for status. 7- Run **Toggle Caffeinate** from the launcher, or bind it to a hotkey. 8 9A filled cup means a matching `caffeinate -dim` is running. A hollow cup means sleep is allowed. 10 11## Install 12 131. Open Macotron. Go to Settings → Plugins → Catalog → Community. 142. Find **Caffeinate**. Press **Add**. 153. Read the source in the review sheet. Press **Add** again. 16 17Macotron scans the plugin before it runs. 18 19## How it works 20 21The process list decides the icon. The plugin does not store its own on or off flag, so a reload picks up a `caffeinate` that is already running and does not start a new one. 22 23Every five seconds the plugin runs `pgrep` for `caffeinate -dim`, including a copy started in a terminal. Other `caffeinate` commands, such as `caffeinate -i make`, are ignored. 24 25Turning it on runs this in the background: 26 27```sh 28/usr/bin/caffeinate -dim -w $PPID >/dev/null 2>&1 &! 29``` 30 31`$PPID` is Macotron, because the command runs under `zsh -c`. caffeinate exits when Macotron quits, so quitting does not leave the Mac awake. `-d`, `-i`, and `-m` hold off idle display sleep, idle system sleep, and disk idle sleep. 32 33Turning it off runs `pkill` with the same pattern. The icon updates from a fresh `pgrep`, not from what the click asked for. The menu says "Keeping awake (caffeinate -dim)", "Sleep allowed", or "Checking...". 34 35## Debugging 36 37Plugin output goes to the system log under the `plugin` category. 38 39```sh 40log stream --level info --style compact \ 41 --predicate 'subsystem == "io.statico.macotron" AND category == "plugin"' 42``` 43 44The plugin logs when it loads and when the state changes. A failed start or stop logs the shell stderr. 45 46## License 47 48MIT