Mutate icon indicating copy to clipboard operation
Mutate copied to clipboard

Switch to application if it's already running

Open ghost opened this issue 10 years ago • 14 comments

Currently invoking an application from mutate launches a new instance every time. But I would prefer if it switched to a running instance if there is one like in Spotlight search in OS X.

Any plans to add this feature or some pointers how this functionality could be scripted?

ghost avatar Dec 19 '15 07:12 ghost

@ikhthiandor I would checkout out wmctrl. This is what I use to switch to applications that are already running. It provides functionality to list applications that are running and it allows you to bring forward a Xwindow application that is running. Here is the script I put together for myself: https://github.com/benfalk/dotfiles/blob/master/config/Mutate/scripts/goto/goto.sh

If you have any more questions feel free to ask :smile:

benfalk avatar Dec 19 '15 14:12 benfalk

Hey @benfalk thanks for your response, wmctrl is cool :smile: . However, I didn't have success in switching windows with your script. Could you share a demo if it works on your end?

ghost avatar Dec 21 '15 14:12 ghost

switcher

Here is a little screen-cast of it. I should point out that it only switches between running windows, it won't start them. It would need to be changed up to start a task if it's not running. I'd be happy to help debug if you want to go down the wmctl route

benfalk avatar Dec 21 '15 19:12 benfalk

@benfalk I would like to control via wmctrl because it's fast. But my cpu gets hogged by mutate when I try to use this script. May be this is related to #89.

Here is a link to my $HOME/.config/Muate folder. Let me know if you would like any more debug info. https://drive.google.com/folderview?id=0B7n6kz1LnnAiTHNxblVjQUJTb1k&usp=sharing

ghost avatar Dec 21 '15 21:12 ghost

Ya, there is a bug where if the script isn't found or doesn't execute correctly Mutate goes off into what I think is an infinite loop. Is your goto.sh set to execute?

chmod 775 /home/ikhthiandor/.config/Mutate/scripts/goto/goto.sh

If so you should be able to produce output with it from the command line, here is an example of me using it with an e

./goto.sh e

Also, copy the following into your shell and run it. Post back what output you get

wmctrl -l | grep -i . | sed "s/.*$(hostname) //g" | sort | xargs -n 1 -I LINE   echo -e "[LINE]\ncommand=wmctrl -a LINE\nicon=\nsubtext="

benfalk avatar Dec 22 '15 17:12 benfalk

Silly me, grrr. The script wasn't set executable. I also chmod'ed to 775 now. Not sure if that was necessary. Anyway, it works now :smile: Thanks so much for your help :+1:

ghost avatar Dec 22 '15 18:12 ghost

Btw, the script doesn't list firefox window if the selected tab has this url for example. https://github.com/qdore/Mutate/issues/108

This is the output in that case.

[cairo-dock] command=wmctrl -a cairo-dock icon= subtext= xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option [emacs@acer5742] command=wmctrl -a emacs@acer5742 icon= subtext=

It works for most other urls though. An example output without the xargs error.

[cairo-dock] command=wmctrl -a cairo-dock icon= subtext= [emacs@acer5742] command=wmctrl -a emacs@acer5742 icon= subtext= [Emacs: Org Mode Markup Cheatsheet - Mozilla Firefox] command=wmctrl -a Emacs: Org Mode Markup Cheatsheet - Mozilla Firefox icon= subtext= [wmctrl -l | grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn} -i . | ] command=wmctrl -a wmctrl -l | grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn} -i . |
icon= subtext=

ghost avatar Dec 22 '15 18:12 ghost

Oh right on, I bet I can fix that :smile:

benfalk avatar Dec 22 '15 19:12 benfalk

:point_up: @ikhthiandor I have updated my script to work with windows that have single quotes in them :smile:

benfalk avatar Dec 23 '15 15:12 benfalk

Awesome! I pulled in your changes. You migh consider sending a pull request to include the script in master.

ghost avatar Dec 24 '15 07:12 ghost

I thought about it; however the script seems pretty specialized and I'm not sure how much people would use it.

benfalk avatar Dec 28 '15 14:12 benfalk

@benfalk Your solution is perfect. but there is one problem the icons are same for all applications. this not very much helpful. can you suggest how can we handle this or tell mutate to pick targeted app's icon.

azeemhassni avatar Oct 15 '16 19:10 azeemhassni

:thinking: Let me ponder that for a bit @azeemhassni

benfalk avatar Oct 17 '16 12:10 benfalk

@benfalk would you show the steps for using this script ubuntu 16.04 ??

fedaa-mahmoud avatar Jun 17 '17 03:06 fedaa-mahmoud