{"id":98,"date":"2009-01-18T22:18:06","date_gmt":"2009-01-19T05:18:06","guid":{"rendered":"http:\/\/www.lothlorien.com\/kf6gpe\/?p=98"},"modified":"2009-01-18T22:20:21","modified_gmt":"2009-01-19T05:20:21","slug":"whither-thee-launchd","status":"publish","type":"post","link":"https:\/\/www.lothlorien.com\/kf6gpe\/whither-thee-launchd\/","title":{"rendered":"Whither thee launchd?"},"content":{"rendered":"<p>Unfortunately, for a number of reasons, I&#8217;ve been far too busy to follow up my previous\u00c2\u00a0<a title=\"Better printing to the Sony eReader using CUPS-PDF\" href=\"http:\/\/www.lothlorien.com\/kf6gpe\/?p=93\">post<\/a>\u00c2\u00a0to use Mac OS X&#8217;s launchd to detect when the Sony eReader connects. There&#8217;s a lot of good launchd stuff on the Web, though, and it promises to be pretty easy once I sit down and actually write a plist for it.<\/p>\n<p>In the mean time, here&#8217;s a revised script for moving the printed PDF files from a spooling directory to the eReader on connection. The setup is <a title=\"Improving Interaction Between the Sony eReader and Mac OS X\" href=\"http:\/\/www.lothlorien.com\/kf6gpe\/?p=64\">the same as before<\/a>; simply kick the script with a Folder Action.<\/p>\n<pre>#!\/usr\/bin\/env sh\r\nPATH=\/opt\/local\/bin:\/usr\/bin:\/bin:\/usr\/sbin:\/sbin:\/usr\/local\/bin\r\nexport PATH\r\n\r\nreadermain=\"\/Volumes\/PRS 700\"\r\nreadercard=\"\/Volumes\/700 CARD\"\r\nspool=\"\/Users\/kf6gpe\/.cups-pdf-spool\"\r\npdfdest=\"$readercard\/PDFs\/\"\r\n\r\ngrowl()\r\n{\r\n    message=\"$*\"\r\n    which growlnotify &gt; \/dev\/null\r\n    if [ $? -eq 0 ]; then\r\n        echo $message | growlnotify -t \"eReader\" -p -2 -a \/Applications\/Preview.app\r\n    fi\r\n}\r\n\r\nif [ -f \"\/tmp\/prs-busy\" ]; then\r\n    exit 0;\r\nfi\r\n\r\nif [ -d \"$readercard\" ]; then\r\n    touch \/tmp\/prs-busy\r\n    growl \"Device detetected.\";\r\n    for f in `ls $spool\/*.pdf`\r\n    do\r\n        cp $f \"$pdfdest\"\r\n        if [ $? -eq 0 ]; then\r\n            rm -f $f\r\n            growl \"Transferred `basename $f`.\"\r\n        fi\r\n    done\r\n    growl \"PDF transfer complete.\";\r\n    rm \/tmp\/prs-busy\r\nelse\r\n    rm \/tmp\/pre-busy 2&gt;&amp;1 \/dev\/null\r\nfi<\/pre>\n<pre>exit 0<\/pre>\n<p>The changes are pretty self-explanatory. In brief:<\/p>\n<ol>\n<li>Have use Preview&#8217;s icon, in case Calibre isn&#8217;t installed.<\/li>\n<li>Only look for the eReader&#8217;s card; there&#8217;s really no reason to look for both volumes.\u00c2\u00a0<\/li>\n<li>Use the lock file <tt>\/tmp\/prs-busy<\/tt> to ensure that the actual movement of the files doesn&#8217;t occur while it&#8217;s actually running.\u00c2\u00a0<\/li>\n<\/ol>\n<p>Of these changes, (3) was certainly the most important, because if you mounted another volume (say, a digital camera) while the script was doing things, weird things could happen. In practice, I never saw anything amiss, but this makes me sleep better at night.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Unfortunately, for a number of reasons, I&#8217;ve been far too busy to follow up my previous\u00c2\u00a0post\u00c2\u00a0to use Mac OS X&#8217;s launchd to detect when the Sony eReader connects. There&#8217;s a lot of good launchd stuff on the Web, though, and it promises to be pretty easy once I sit down and actually write a plist &hellip; <a href=\"https:\/\/www.lothlorien.com\/kf6gpe\/whither-thee-launchd\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Whither thee launchd?<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[16,17,18],"class_list":["post-98","post","type-post","status-publish","format-standard","hentry","category-programming","tag-ebook","tag-ereader","tag-mobile-wireless"],"_links":{"self":[{"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/posts\/98","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/comments?post=98"}],"version-history":[{"count":6,"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/posts\/98\/revisions"}],"predecessor-version":[{"id":104,"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/posts\/98\/revisions\/104"}],"wp:attachment":[{"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/media?parent=98"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/categories?post=98"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/tags?post=98"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}