tags:

views:

999

answers:

4

Hi there;

I'd like to be able to run my aliases from my .bashrc in the "Run Application" dialog that comes up when you hit Alt+F2 in Ubuntu/Gnome.

Does anyone know how to do this?

+1  A: 

http://www.freedesktop.org/wiki/Specifications is probably a good place to start. I find these quite hard to follow most of the time, but sometimes you can figure it out. Specifically, the "Desktop Entry Specification".

Also, I don't think you'll be able to use any aliases from .bashrc, at least not without writing some kind of wrapper script. I think it needs to be an executable file. Of course, you could just use the good old symlinks- to- same + what's- my- name trick...

(Which, for reference, goes like this:

  1. Make a script which uses its own name as a parameter.
  2. Make symlinks to said script using the parameter values as the link names.)


Investigating...

Some casual investigation reveals that creating these is fairly simple if you use Nautilus, (at least the version I have):

  1. Bring up the context menu for some random file, and use "Open With"->"Open with Other Application".
  2. Unfold the "Use a custom command" and type in something like:
    1. xterm -e 'bash -c "unzip -l %f; sleep 5"'
  3. This results in
    1. the command being run (so don't type rm -rf)
    2. a file in ~/.local/share/applications/ called xterm-usercreated.desktop

Here at least, I get the follow file:

[Desktop Entry]
Encoding=UTF-8
Name=xterm
MimeType=application/zip;
Exec=xterm -e 'bash -c "unzip -l %f; sleep 5"' %f
Type=Application
Terminal=false
NoDisplay=true

4: Looking at the system xterm .desktop I find this:

[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=XTerm
GenericName=
Comment=XTerm: terminal emulator for X
Icon=/usr/share/pixmaps/xterm-color_32x32.xpm
Exec=xterm
Terminal=false
Categories=X-Debian-Applications-Terminal-Emulators;

5: Editing the .usercreated.desktop file to this:

[Desktop Entry]                                                                 
Type=Application                                                                
Encoding=UTF-8                                                                  
Name=xtermz                                                                     
Exec=xterm -e 'bash -c "unzip -l %f; sleep 5"' %f                               
Terminal=false                                                                  
Categories=X-Local-WTF

6: Run xdg-desktop-menu forceupdate --mode user

7: "xtermz" now shows up in the list... Success!

8: Yuck! This also makes it appear in the main menu, under "Other". Weird!


Some notes:

  • In my Debian/testing, xdg-desktop-menu and friends (notably xdg-icon-resource) live in the xdg-utils package.
  • You should be able to create a .desktop file from scratch.
  • You should be able to install the .desktop file using xdg-desktop-menu install blah blah
Anders Eurenius
A: 

Thanks for the great post.... I'd been doing the script that calls an alias named after itself trick, but this is great to know too!

Thanks again for the help...

Brad.

Brad Parks
A: 

I couldn't get the aliases working, so I did this instead:

  • Created a shell script to do what I want and put it in my home dir

  • Put a link to my shell script in /usr/bin:

    • e.g sudo ln -s ~/bin/MyShellScript.sh /usr/bin/MyShortcutName

It works!

Brad Parks
A: 

I couldn't get the aliases working, so I did this instead:

Created a shell script to do what I want and put it in my home dir

Put a link to my shell script in /usr/bin:

e.g sudo ln -s ~/bin/MyShellScript.sh /usr/bin/MyShortcutName It works!

It works because /usr/bin is in your path variable. a better alternative would be to create a hidden directory in your home, like ~/.scripts/

and then add this directory to your path. you can now put all your scripts in that dir.

Nostoc