FelixKratz / SketchyBar

A highly customizable macOS status bar replacement
https://felixkratz.github.io/SketchyBar/
GNU General Public License v3.0
5.2k stars 82 forks source link

add service managment into sketchybar like yabai #541

Closed k2662 closed 2 months ago

k2662 commented 2 months ago

It would be nice to have sketchybar manage itself instead of buggy brew.

FelixKratz commented 2 months ago

It is true that brew is a bit buggy and there are so many bug reports just because of strangeness in brew, however it seems to work great most of the times. It is very simple to work directly with the launchctl cli to manage the service completely without relying on brew or sketchybar:

  1. Compile the sketchybar program from source and copy it to /usr/local/bin/sketchybar
  2. Create a git.felix.sketchybar.plist file in ~/Library/LaunchAgents/
    <?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>git.felix.sketchybar</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/sketchybar</string>
    </array>
    <key>EnvironmentVariables</key>
    <dict>
        <key>PATH</key>
        <string>/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/homebrew/bin:/opt/homebrew/sbin</string>
    </dict>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
    <key>StandardOutPath</key>
    <string>/tmp/sketchybar.out.log</string>
    <key>StandardErrorPath</key>
    <string>/tmp/sketchybar.err.log</string>
    <key>ThrottleInterval</key>
    <integer>30</integer>
    <key>ProcessType</key>
    <string>Interactive</string>
    <key>Nice</key>
    <integer>-20</integer>
    </dict>
    </plist>
  3. Bootstrap the plist with
    launchctl bootstrap gui/$UID $HOME/Library/LaunchAgents/git.felix.sketchybar.plist
    launchctl load -w $HOME/Library/LaunchAgents/git.felix.sketchybar.plist