cerebro icon indicating copy to clipboard operation
cerebro copied to clipboard

Redirect to opened app instead opening new one

Open pkajaba opened this issue 8 years ago • 13 comments

I believe that some people prefer to always open new apps, but for those would don't this would be great.

Example: I have opened one instance of google-chrome. When I use short-cut to initialize cerebro and type google-chrome, I would expect that previous instance would pop up instead of creating new one.

pkajaba avatar Feb 22 '17 19:02 pkajaba

But don't you think it's the app that should decide this, not the launcher? For example the messenger I use doesn't open the second instance of itself, same for email client -- the apps themselves take care of that. The app developers can better tell whether it makes sense to be able to run two instances simultaneously (it makes sense for two calculators or two text editors) or only one instance should be allowed.

maximbaz avatar Feb 22 '17 21:02 maximbaz

I'm using Cerebro on a Mac and I can confirm that Chrome uses this behaviour - it switches to the already open instance instead of creating a new one. I haven't yet tried it on my Linux laptop though.

matmunn avatar Feb 22 '17 23:02 matmunn

@pkajaba what operation system do you use?

KELiON avatar Feb 23 '17 09:02 KELiON

Fedora 25

pkajaba avatar Feb 23 '17 12:02 pkajaba

I think the best way to approach this feature request is by creating a completely new plugin. The current plugin is doing one job (opening new apps) and it's doing it well, let's keep it simple.

The new plugin would:

  • search currently opened windows (not apps!)
  • let you fuzzy-filter them
  • and on Enter would bring it on top and focus it.

The main benefits are:

  • it keeps code clean and separated, eliminates all funny bugs
  • allows to choose which of the multiple windows you want to focus.

Examples:

Suppose you have two documents opened in LibreOffice Writer, the two windows have titles Fun - LibreOffice Writer and Work - LibreOffice Writer.

  • Opening Cerebro and typing writer gives you 3 results:
    • Fun - LibreOffice Writer // Enter would focus on this specific document
    • Work - LibreOffice Writer // Enter would focus on this specific document
    • LibreOffice Writer // Enter would open a new instance of Writer
  • Opening Cerebro and typing w writer gives you only one result, because nothing else matches:
    • Work - LibreOffice Writer

maximbaz avatar Mar 27 '17 18:03 maximbaz

Hey'ya all - I'm excited at the prospect of this feature. I'm no programmer but I 'dug around' & stumbled upon some interesting info, IMO. Note this is for GNU/Linux systems as it relies on wmctrl:

#!/bin/bash

PROGRAM=$1
WINID=$(wmctrl -lx | grep -i $PROGRAM | awk 'NR==1{print $1}')

if [ $WINID ]; then
    wmctrl -ia $WINID &
 #  exit 0  
else
    $PROGRAM &
 #  exit 0 
fi

(Source: Albert Launcher's Github, Issue 123, Switch to application if it's already running, mintystark, 2016-02-10)

xlsclients was another Linux-specific command I saw mentioned, too.

Anyone have an idea how this could be implemented for us Linux users until an OS agnostic solution comes along?

amsheppard avatar Apr 21 '17 02:04 amsheppard

This the the most anticipated plugin for me! Developers, please create it! Or maybe it is even better to have it inside the app as a setting that maybe changed. I switched from OS X, where Spotlight has this feature as a default behaviour when typing an app that is already opened. With such feature on OS X, I've never used Alt+Tab or Dock to switch between opened apps.

AlexeyKot avatar Apr 07 '18 20:04 AlexeyKot

I am very excited to test this feature in the future if released. :1st_place_medal:

caiocutrim avatar Oct 02 '18 17:10 caiocutrim

This is the soul reason I wanted something like cerebro!

Any news on a plugin with this functionality?

ldiebold avatar Oct 25 '18 01:10 ldiebold

Any news on this plugin?

am-shb avatar Mar 30 '19 00:03 am-shb

OK, I have decided to write this plugin myself because it was one of the main reasons why I installed cerebro in the first place you can check it out at its repo or install it directly from cerebro by typing plugins manager try it out and let me know what you think PS: only tested on ubuntu 18.04 but should work on other distros too

am-shb avatar Mar 31 '19 00:03 am-shb

OK, I have decided to write this plugin myself because it was one of the main reasons why I installed cerebro in the first place you can check it out at its repo or install it directly from cerebro by typing plugins manager try it out and let me know what you think PS: only tested on ubuntu 18.04 but should work on other distros too

Not working in debian 10

rifat-h avatar Aug 05 '19 09:08 rifat-h

OK, I have decided to write this plugin myself because it was one of the main reasons why I installed cerebro in the first place you can check it out at its repo or install it directly from cerebro by typing plugins manager try it out and let me know what you think PS: only tested on ubuntu 18.04 but should work on other distros too

Unfortunately doesnt work on windows as well :c

roflbofl322 avatar May 11 '22 19:05 roflbofl322