[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how to tell which key was pressed to execute a script?



* Andrej Hocevar (drejcica@volja.net) [030606 14:10]:
> On Fri, Jun 06, 2003 at 12:05:10PM -0400, David Z Maze wrote:
> > So use command-line arguments, or write a separate script for each
> > key.  They're cheap.  :-)

> So I thought I'd map more keys to that function, which always
> executes one script -- and the script would know how it was called,
> so that it could execute a different function for each key. 
> 
> Does anyone know how this could be accomplished?

I don't understand why David's idea was no good.  If you want different
keys to do different things, why not use different scripts for each?
The typical ways for a program to react differently based on how it was
invoked include command-line arguments (indlucing $0, the program name
itself) and the environment.  If the way it's run doesn't get something
like HOTKEY=F1 in its environment, you're probably only left with
command-line-arguments.  You could use many links to the same script
which checks $0, but I don't see why this is preferable over multiple
independent scripts (unless there's a lot of shared code).

good times,
Vineet
-- 
http://www.doorstop.net/
-- 
"Great spirits have always found violent opposition from mediocre minds. The
latter cannot understand it when a man does not thoughtlessly submit to
hereditary prejudices but honestly and courageously uses his intelligence."
-- Albert Einstein

Attachment: signature.asc
Description: Digital signature


Reply to: