Jump to content
learned

Getting at the Clipboard History

Recommended Posts

Is there any way to get at the clipboard history and manipulate it in workflows? I would like to clip a bunch of urls, then have an applescript download each one. Ideally I would like to have applescript copy the most recent clipboard to the system clipboard, then delete the most recent clipboard from history.

Share this post


Link to post

Is there any way to get at the clipboard history and manipulate it in workflows? I would like to clip a bunch of urls, then have an applescript download each one. Ideally I would like to have applescript copy the most recent clipboard to the system clipboard, then delete the most recent clipboard from history.

 

It's possible but not really something recommended. You could query Alfred's clipboard.alfdb in ~/Library/Application Support/Alfred 2/Databases

 

If you query the clipboard table you could grab the most recent clipboard items.

Share this post


Link to post

It's possible but not really something recommended.

 

Ahem, definitely don't go digging around in that folder or the Alfred databases. Alfred has these open most of the time and if you mess with these while he is using them, data could get corrupt.

Share this post


Link to post
Posted (edited)

I think you can solve that by issuing an exclusive lock on the db while modifying it:

PRAGMA locking_mode = EXCLUSIVE;
BEGIN EXCLUSIVE;

I plan on adding that to my alfred-clipboard.sh script in the future when I implement timstamp rewriting to make the history infinite:

BTW if anyone is looking for a full script example that can clone, read, merge, etc otherwise poke into the Alfred clipboard db, you can find the source for my implementation here:
https://gist.github.com/pirate/6551e1c00a7c4b0c607762930e22804c

Edited by theSquashSH

Share this post


Link to post
7 minutes ago, theSquashSH said:

I think you can solve that by issuing an exclusive lock on the db while modifying it

 

Please don't do that. If you're going to write to the database, quit Alfred while your script is running, then restart it, instead. (And back up the database first.)

 

If your script starts messing up people's clipboard history, the Alfred team will get the support requests. And Andrew will likely respond by changing Alfred to acquire an exclusive lock on its own databases.

 

It's not possible to run Alfred 3 & 4 at the same time, which is a bit of a pain for workflow developers, because the Node crowd were causing problems and didn't fix them.

 

So, please don't interfere with Alfred's functioning like that.

Share this post


Link to post
5 hours ago, theSquashSH said:

I think you can solve that by issuing an exclusive lock on the db while modifying it

 

Please do not exclusively lock Alfred's databases, as this will have a severe impact on Alfred's ability to operate normally.

 

Cheers,

Andrew

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...