Closed hasgar-aot closed 2 years ago
The open
command can open a URL, but it needs to have a fully-formed URL.
So this works:
open https://www.google.com
But this does not work:
open www.google.com
@mckenfra i tried with https:// only. system() not throwing any error and give result 1(success). But it doesn’t open browser.. I don’t know is it because any permission limitation of printer module or not. i tried exec functions also to run shell script. Same result. Any thoughts?
Printer drivers are run as the cupsd user. So its just not going to work - the wrong user is trying to open the browser.
This is the same issue that prevents me from being able to choose where the print file gets put, as the cupsd user has very limited privileges.
Rod
On 26 Jun 2021, at 3:17 pm, Hasgar D @.**@.>> wrote:
@mckenfrahttps://github.com/mckenfra i tried with https:// only. system() not throwing any error and give result 1(success). But it doesn’t open browser.. I don’t know is it because any permission limitation of printer module or not. i tried exec functions also to run shell script. Same result. Any thoughts?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/rodyager/RWTS-PDFwriter/issues/14#issuecomment-868949958, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAKSADIJ6OLR7H5TEPUO5T3TUVPGVANCNFSM47JMQPVQ.
@rodyager Yes I wanted the PDFs to appear in ~/Downloads
rather than /var/spool/pdfwriter/
.
I got it working using Folder Actions. I modified RWTS-PDFwriter
so that it automatically adds a Folder Action to /var/spool/pdfwriter
as part of the installation process of the driver.
Then, whenever a user subfolder is created under /var/spool/pdfwriter
, my Folder Action automatically creates another Folder Action on that user subfolder such that anything that appears in the user subfolder (i.e. any PDF printed using RWTS-PDFwriter
) is automatically moved to the user's Downloads
directory.
It works pretty well!
If you like I could create a pull request to merge it into your project, but it does add more complexity, so I understand if you'd prefer to keep your driver simple 👍
That certainly would work.
Note that what my installer does is make /Users/Shared/PDFwriter a symbolic link to /var/spool/pdfwriter.
I then drag the “myusername” folder that gets created there when I print to my Dock.
Please do create a pull request. Your solution looks like a good idea.
Rod
On 26 Jun 2021, at 4:36 pm, Francis McKenzie @.**@.>> wrote:
@rodyagerhttps://github.com/rodyager Yes I wanted the PDFs to appear in ~/Downloads rather than /var/spool/pdfwriter/.
I got it working using Folder Actionshttps://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_folder_actions.html. I modified RWTS-PDFwriter so that it automatically adds a Folder Action to /var/spool/pdfwriter as part of the installation process of the driver.
Then, whenever a user subfolder is created under /var/spool/pdfwriter, my Folder Action automatically creates another Folder Action on that user subfolder such that anything that appears in the user subfolder (i.e. any PDF printed using RWTS-PDFwriter) is automatically moved to the user's Downloads directory.
It works pretty well!
If you like I could create a pull request to merge it into your project, but it does add more complexity, so I understand if you'd prefer to keep your driver simple 👍
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/rodyager/RWTS-PDFwriter/issues/14#issuecomment-868957056, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAKSADLDH5NBWH2Z7PKQZ5TTUVYPRANCNFSM47JMQPVQ.
Ok I'll create a pull request.
Only problem is that the "Folder Actions" functionality is implemented using AppleScript, and I've checked these scripts into my branch as .scpt
files. But git treats .scpt
files as opaque binary files, which prevents you from viewing the underlying source code on Github. To see the Applescript source code, you have to clone the project to your Mac computer and open the .scpt
files using macOS Applescript Editor.
Ideally the plain-text applescript source would be checked-in to git, and then this would be compiled to .scpt
files during the build process. So I'll need to get this extra build step working before doing the pull request.
@mckenfra how did you triggered folder actions from pdfwriter? May be using apple script i can open browser too. Could you please share that code snippet(apple script trigger) here? Or pull request will also work :)
@hasgar-aot Yes you can look at the code once I've done the pull request. The tricky part is making it work automatically for any user - you need a Folder Action on the parent /var/spool/pdfwriter
folder that automatically detects when a user subfolder is created. This parent Folder Action then needs to add another Folder Action to the new user subfolder to do the actual automatic moving of the printed PDFs to that user's ~/Downloads
folder.
But in your case, all you would need to do is create your own Folder Action on your ~/Downloads
folder. Your Folder Action would detect whenever a file named job_*
appears and then would call open https://my-url
.
@mckenfra How will that Apple script be created in the /Downloads folder with limited permissions? I need this to be done by the printer module itself without any manual effort. Will we write that in a post-installation script?
@hasgar-aot Your Folder Action would be created on the user's ~/Downloads
folder, which the user has permissions to access, so there would be no problem with permissions. In fact, I'm thinking we should allow the user to change the destination folder as part of the installation process.
Also unfortunately I think Folder Actions are installed for the current-user-only, not system-wide. So after one user installs the RWTS-PDFwriter
driver on a Mac computer, any other users who then log-in will need to run the Change PDFwriter Output Dir
script, to configure where they want their PDFs to end up (otherwise they'll stay in their original location of /var/spool/pdfwriter/<user>
). I don't think (sadly) a Folder Action can be enabled by default system-wide for all users, i.e. to always move printouts to the current user's ~/Downloads
folder by default.
So for your situation, maybe you could create another script that the user needs to run after the RWTS-PDFwriter
driver is installed, to setup your open-url Folder Action? You could also do a custom build of RWTS-PDFwriter
to add you custom setup script to /Library/Printers/RWTS/PDFwriter/Folder Actions/
, which is where my scripts are going, and then have the post-installation run your custom script as part of installation. But again, each new user who logs-in to the same Mac computer will need to run your script again (once) to install your Folder Action in their login environment.
@mckenfra thank you very much. i'll try. it would be nice if you can do a pull request :)
@rodyager @n1313 @mckenfra I know this is not within the scope of this project. Do you know any way to open browser to a specific link after printing done. i tried system("open url), exec and all. no luck. thank you