Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Small daemon to send documents to your Kindle and eject it every time it's connected
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.interestinglythere.sendtokindle</string>
<key>StartOnMount</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>-c</string>
<string><![CDATA[
#!/bin/bash
set -eou pipefail
SRC="$HOME/Calibre Library/Send to Kindle"
DST="/Volumes/Kindle/documents/Sent to Kindle"
DST_DEVICE=/Volumes/Kindle
test -e "$SRC"
test -e "$DST"
IFS=$'\n'
for file in $(find "$SRC" -mindepth 1); do
osascript -e 'display notification "'"Sending $(basename "$file")"'" with title "Send to Kindle"'
mv "$file" "$DST"
done
unset IFS
diskutil eject "$DST_DEVICE"
osascript -e 'display notification "Sync Finished" with title "Send to Kindle"'
]]></string>
</array>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.