Flycut icon indicating copy to clipboard operation
Flycut copied to clipboard

[Feature] Timed Clear of oldest item

Open technobly opened this issue 8 years ago • 1 comments

As a user, for security purposes I would love to have oldest copied items automatically remove themselves from the list after a Set Time.

This fits in line with a lot of password tools that remove the item from the clipboard after a period of time.

I realize this could be annoying for non-sensitive text and passwords mixed if you want to set an aggressive time limit for sensitive info's sake. We can be smarter about not saving passwords from known apps or from password fields as well, however it also might be a good add-on to have another hotkey sequence for copy that tells Flycut to apply the Timed Clear properties to this item. CMD + SHIFT/ALT + C (user definable). Then you can have a preference option to apply Timed Clear to every item, or just those used with the hotkey.

technobly avatar Mar 02 '16 21:03 technobly

Until this is built in...

  • Save the following as /usr/local/bin/clear-pasteboard and make it executable:

    #!/usr/bin/env bash
    set -euo pipefail
    
    FLYCUT_PATH="/Applications/Flycut.app"
    FLYCUT_CONF="${HOME}/Library/Application Support/Flycut/com.generalarcade.flycut.plist"
    
    if [ -d "$FLYCUT_PATH" ] ; then
      set +o pipefail
      pid=$(ps aux | grep Flycut.app | grep -v grep | awk '{print $2}')
      set -o pipefail
    
      # if Flycut is running, kill it. else it will keep and persist current history...
      if [ "${pid}" != "" ] ; then
        kill ${pid}
        sleep 10
      fi
    
      # empty the Flycut history "store"...
      plutil -replace 'store.jcList' -json '[]' "${FLYCUT_CONF}"
    
      # if Flycut *was* running, restart it...
      if [ "${pid}" != "" ] ; then
        open "${FLYCUT_PATH}"
      fi
    fi
    
  • Save the following as $HOME/Library/LaunchAgents/io.pivotal.clear-pasteboard.plist

    <?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>io.pivotal.clear-pasteboard</string>
        <key>ProgramArguments</key>
        <array>
            <string>/usr/local/bin/clear-pasteboard</string>
        </array>
        <key>StartCalendarInterval</key>
        <dict>
            <key>Hour</key>
            <integer>00</integer>
        </dict>
    </dict>
    </plist>
    
  • Execute: launchctl load -w ~/Library/LaunchAgents/io.pivotal.clear-pasteboard.plist

This will clear the Flycut history every day at midnight. Adjust the StartCalendarInterval, if you'd like a different schedule.

coreyti avatar Oct 29 '16 00:10 coreyti