OK, I have a program in which I would like to control hiding/showing of the main form with a global hotkey. Global hotkeys on Linux are problematic, if not downright impossible. So, I'm thinking of a workaround in which I include with my program a Help or README file which describes how to set a hotkey in the major Desktop Environments (Gnome, KDE, Xfce, Lxde/Openbox). My problem is, what is the best way to have the hotkey signal the running program that something needs to happen?
There are two ways I can see:
1- Have the hotkey launch a smaller program whose only purpose is to send a signal to the currently-running program and quit. This would involve some sort of socket sending/listening I assume? (reading up on sockets unit now).
2- Have the hotkey launch a second instance of the program, but with a parameter which will tell it to run a procedure to check for an already-running instance, and if found, send the appropriate signal to it. Again, I assume this would mean additional code for sending and listening to sockets.
Which method is better? Is there another/better alternative? Am I correct that sending/listening over sockets is the way to go? Which sockets would be best for this purpose? Would I put the code in the project (the .lpr file), or in a separate unit? (in the interest of code cleanliness, I'd like to keep it out of the main form unit.)
Links to sample code is appreciated, thank you. I'm not asking anybody to write my homework for me...