Call Launchbar Actions from Terminal

General discussions about LaunchBar
bilke
Posts: 1
Joined: Sat Nov 26, 2016 2:48 pm

Call Launchbar Actions from Terminal

Postby bilke » Sat Nov 26, 2016 2:50 pm

Is it possible to call a Launchbar action from Bash (Terminal) or Applescript?

What I would like to do is calling a Launchbar action when a Hazel rule is triggered.

Thanks!

JimmyTheSaint
Rank 1
Rank 1
Posts: 32
Joined: Sat May 07, 2016 9:06 am

Re: Call Launchbar Actions from Terminal

Postby JimmyTheSaint » Wed Dec 06, 2017 10:05 am

+1

marco
Objective Development
Objective Development
Posts: 64
Joined: Mon Jul 28, 2014 3:00 pm
Location: Vienna, Austria

Re: Call Launchbar Actions from Terminal

Postby marco » Mon Dec 18, 2017 1:39 pm

It’s possible to do this using the Action URL Script Type of LaunchBar Actions. It’s documented here:
https://developer.obdev.at/launchbar-de ... ript-types

Assuming your LaunchBar Action is set up correctly (see the documentation or ask here, if you have any questions), you would then place a line like the following in your shell script that is called from Hazel. As you can see, you could also pass parameters that your script can evaluate:

Code: Select all

open "x-launchbar:action/com.example.MyAction/hazelCallback?parameter1=value1&parameter2=value2"

JimmyTheSaint
Rank 1
Rank 1
Posts: 32
Joined: Sat May 07, 2016 9:06 am

Re: Call Launchbar Actions from Terminal

Postby JimmyTheSaint » Mon Dec 18, 2017 3:46 pm

Will this work with the built-in actions?

marco
Objective Development
Objective Development
Posts: 64
Joined: Mon Jul 28, 2014 3:00 pm
Location: Vienna, Austria

Re: Call Launchbar Actions from Terminal

Postby marco » Mon Dec 18, 2017 3:49 pm

No, none of the built-in actions implement this. What is it that you’re trying to do exactly?

JimmyTheSaint
Rank 1
Rank 1
Posts: 32
Joined: Sat May 07, 2016 9:06 am

Re: Call Launchbar Actions from Terminal

Postby JimmyTheSaint » Mon Dec 18, 2017 3:59 pm

I'm making a keyboard interface using Karabiner-Elements. Currently, I have to make Alfred Workflows because it's easy to trigger them externally via key sequences programmed into Karabiner-Elements. But I'd prefer to go all-LaunchBar because I only use Alfred for its externally triggered Workflows.

marco
Objective Development
Objective Development
Posts: 64
Joined: Mon Jul 28, 2014 3:00 pm
Location: Vienna, Austria

Re: Call Launchbar Actions from Terminal

Postby marco » Mon Dec 18, 2017 4:10 pm

You can run built-in actions or any other action using AppleScript. You can optionally also pass in a string argument:

Code: Select all

tell application "LaunchBar" to perform action "Display in Large Type" with string "Hello World"

Running actions using arbitrary keyboard shortcuts is currently not possible in LaunchBar, though.

JimmyTheSaint
Rank 1
Rank 1
Posts: 32
Joined: Sat May 07, 2016 9:06 am

Re: Call Launchbar Actions from Terminal

Postby JimmyTheSaint » Mon Dec 18, 2017 6:15 pm

marco wrote:Running actions using arbitrary keyboard shortcuts is currently not possible in LaunchBar, though.

I just programmed Karabiner-Elements so that when I type the sequence "x,m" LaunchBar outputs "Hello World" in large type, no problem. That means I can trigger any LaunchBar from an arbitrary sequence by using K-E.
thanks

JimmyTheSaint
Rank 1
Rank 1
Posts: 32
Joined: Sat May 07, 2016 9:06 am

Re: Call Launchbar Actions from Terminal

Postby JimmyTheSaint » Mon Dec 18, 2017 6:31 pm

Is there a way to trigger other LaunchBar things externally? For example, the search templates?

marco
Objective Development
Objective Development
Posts: 64
Joined: Mon Jul 28, 2014 3:00 pm
Location: Vienna, Austria

Re: Call Launchbar Actions from Terminal

Postby marco » Tue Dec 19, 2017 10:38 am

Unfortunately, you can’t use search templates using this mechanism directly. But some searches, like Google, DuckDuckGo, or Wikipedia are actually implemented as Actions. You can call these just like in the previous example:

Code: Select all

tell application "LaunchBar" to perform action "DuckDuckGo" with string "Hello World"

Similarly to “perform action”, you can also use “perform service” if there’s some functionality available as a service by an application. You can see the full list of LaunchBar’s AppleScript support by opening Script Editor and selecting File > Open Dictionary… and selecting LaunchBar in the list of applications.

Hales Kin
Posts: 1
Joined: Sun Sep 02, 2018 10:14 am
Location: United States
Contact:

Re: Call Launchbar Actions from Terminal

Postby Hales Kin » Sun Sep 02, 2018 10:17 am

marco wrote:It’s possible to do this using the Action URL Script Type of LaunchBar Actions. It’s documented here:
https://developer.obdev.at/launchbar-de ... ript-types

Assuming your LaunchBar Action is set up correctly (see the documentation or ask here, if you have any questions), you would then place a line like the following in your shell script that is called from Hazel. As you can see, you could also pass parameters that your script can evaluate:

Code: Select all

open "x-launchbar:action/com.example.MyAction/hazelCallback?parameter1=value1&parameter2=value2"

Thanks for sharing! It was helpful

soloism
Posts: 2
Joined: Sat Sep 08, 2018 7:32 pm
Contact:

Re: Call Launchbar Actions from Terminal

Postby soloism » Sun Sep 09, 2018 10:43 am

HELLO,
What do you think about it ?


Return to “LaunchBar General”

Who is online

Users browsing this forum: No registered users and 2 guests