Jump to content
HotHead

[SOLVED] Alfred placeholders evaluated within custom code

Recommended Posts

Hi All

Apologies if this has already been dealt with (I have searched and not found any conclusive answer on the forum).

Is there a way to have curly bracket placeholders other than {query} - specifically {clipboard:0}, {clipboard:1}, {clipboard:2}, ... - evaluated within a php script?

It appears that {clipboard:7} does not get evaluated upon initialisation like {query} does, but rather remains a placeholder right up to the moment where it is passed to some Alfred output such as Large Type, and only then is the clipboard value retrieved from the DB. Code example:

$query = "{query}";

// $query has been assigned the value passed to the script


$i = 7;
$history_item = "{clipboard:$i}";

// $history_item has not been assigned any value from the clipboad stack - it holds the literal string value '{clipboard:7}'


That means I can't access, search, and manipulate the clipboard history items within my code. Will I need to query clipboard.alfdb manually, or is there a simpler solution?

All help appreciated :)

Edited by vitor
Marked as solved

Share this post


Link to post
2 hours ago, HotHead said:

Is there a way to have curly bracket placeholders other than {query} - specifically {clipboard:0}, {clipboard:1}, {clipboard:2}, ... - evaluated within a php script?

 

Not directly.

 

Only the {query} macro is expanded in Script boxes (it's a legacy feature for compatibility with Alfred 2 workflows—you should use ARGV in Alfred 3).


{var:…} and {clipboard:…} macros do work in other elements, however, so you can use an Args and Vars utility to set workflow variables using {clipboard:…} and read the variables from the environment in your PHP script.

 

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...