Tue, 18 Apr 2023 04:48:40 GMT

Tip for rcmd macOS.

Problem

rcmd is a macOS application that help switching among applications instantly.

However, this is a shareware. The trial version has a limitation, it stops working after a few hours, you have to restart the app to resets the trial.

In this article, I will guide you how to restart rcmd automatically.

Solution

We will create a macOS background service that run at start up. The service will restart rcmd each 30 minutes.

Steps:

1. Launch rcmd app. You should see its icon in the system tray menu.

2. Launch your favorite terminal app.

3. Run

cat << EOF > ~/Library/LaunchAgents/xyz.ansidev.rcmd.autorestart.plist
<?xml version="1.0" encoding="UTF-8"?>

<plist version="1.0">
  <dict>
    <key>RunAtLoad</key>
    <true />
    <key>Label</key>
    <string>xyz.ansidev.rcmd.autorestart</string>
    <key>ProgramArguments</key>
    <array>
      <string>/usr/bin/osascript</string>
      <string>-e</string>
      <string>quit app "rcmd"</string>
      <string>-e</string>
      <string>delay 5</string>
      <string>-e</string>
      <string>launch app "rcmd"</string>
    </array>
    <key>StartInterval</key>
    <integer>1800</integer>
  </dict>
</plist>
EOF


cat << EOF > ~/Library/LaunchAgents/xyz.ansidev.rcmd.autorestart.plist
<?xml version="1.0" encoding="UTF-8"?>

<plist version="1.0">
  <dict>
    <key>RunAtLoad</key>
    <true />
    <key>Label</key>
    <string>xyz.ansidev.rcmd.autorestart</string>
    <key>ProgramArguments</key>
    <array>
      <string>/usr/bin/osascript</string>
      <string>-e</string>
      <string>quit app "rcmd"</string>
      <string>-e</string>
      <string>delay 5</string>
      <string>-e</string>
      <string>launch app "rcmd"</string>
    </array>
    <key>StartInterval</key>
    <integer>1800</integer>
  </dict>
</plist>
EOF

4. Load service

launchctl load ~/Library/LaunchAgents/xyz.ansidev.rcmd.autorestart.plist


launchctl load ~/Library/LaunchAgents/xyz.ansidev.rcmd.autorestart.plist

You should see the rcmd icon in the system tray menu was disappeared, then displayed again (because it was restarted successfully)

5. Check whether the service was started successfully

launchctl list | grep xyz.ansidev.rcmd.autorestart


launchctl list | grep xyz.ansidev.rcmd.autorestart

The second column (exit code) should display 0 as the output value.

-	0	xyz.ansidev.rcmd.autorestart


-	0	xyz.ansidev.rcmd.autorestart