-1

https://github.com/pilotmoon/PopClip-Extensions#types-of-actions

I noticed that the popclip extension can directly call the macos service menu. (found in System Preferences -> Keyboard -> Keyboard Shortcuts ->Services)

So, is it possible to call in other ways or scripts? because i want to call them in alfred workflow.

omigrl
  • 1
  • 1

1 Answers1

0
#!/usr/bin/osascript -l JavaScript
ObjC.import('Cocoa')
ObjC.import('stdlib');

function run(argv) {
    let service = $.getenv('service');  //variable set via args utility
    let text = $.getenv('input');       //variable set via args utility

    $.NSPasteboard.generalPasteboard.clearContents;
    $.NSPasteboard.generalPasteboard.writeObjects([text]);

    console.log("performing service %s", service)
    console.log("performing on text %s", $.NSPasteboard.generalPasteboard.pasteboardItems[0])

    let ret = $.NSPerformService(service, $.NSPasteboard.generalPasteboard)
    if (!ret) return `Service “${service}” failed`
}
omigrl
  • 1
  • 1