Bash: get name of selected item of the desktop

Sounds like a perfect use case for TrackerScript, a TrackerAddon that will run a customized script on the selected items.
It use attribute to specify the script command.

See the recent discussion about Font Install traker add-on: