1

I know I can add custom shortcuts or even url links to the launcher.

Can I create custom launcher shortcuts that accept or process arguments?

For example, can I set a launcher link to open http://google.com/#q=%s, so that when I type google cat videos in launcher, it will open the link replacing %s with cat videos?

  • No, that's not possible on Unity. The closest thing would be the remote scopes (in the example you give), but not the same in the general case. – edwin Jul 16 '14 at 03:02

1 Answers1

1
  1. How about making new command google:

    sudo nano /usr/bin/google

    #!/bin/sh
    for w in $@ ; do query=$query+$w; done
    xdg-open http://google.com/#q=$query
    

    Add executing permission:

    sudo chmod +x /usr/bin/google
    
  2. To use it, Alt+F2 to open command launcher:

    google ...
    
user.dz
  • 48,105
  • Thanks; this suits my needs too. Two suggestions: it should be query="$query $w", and it's best to surround the argument with quotes i.e. xdg-open "http://google.com/#q=$query" – congusbongus Jul 16 '14 at 06:50
  • @congusbongus, I tried that before and retried after you mentioned it. I couldn't get it to work, xdg-open keep spliting it on multiple calls. May be we have different versions (1.1.0~rc1-2u on Ubuntu 14.04). BTW, manual make it clear the parameter should be a File or URL. So It should be encoded. – user.dz Jul 16 '14 at 07:09
  • @congusbongus, if that way (ie with space) works for you, then you call simply xdg-open "http://google.com/#q=$@" no need for that loop/variable indeed I added them basically to fix that behavior (splitting call commands at space) in my case. – user.dz Jul 17 '14 at 03:59