conky
conky copied to clipboard
avoid multiple running instances
Avoid multiple running instances
- I like to use saved session on kde and it happens, that on startup multiple instances of conky will be created. I don't know, whether this behaviour is related to my number of virtual desktops or whatever, so I changed conky to not start, if it is already running.
- Standard behaviour is not changed. Changed app just refuses to start if there is an instance already running
- Tested: from terminal start one instance with "conky -d" and then start conky without -d switch. conky will respond, that it is already running and quits.
I also have been bothered by KDE restarting Conky while I had it in my startup settings. But I can see at least two problems here:
- ps -e won't work on all OSes Conky can run on. Not on Haiku where ps does not conform to POSIX and XSI extension. Maybe not even on OSX where "-e" means "Display the environment as well".
- Some people might actually want to start two Conky instances, with different config files, on different parts of the screens. This would prevent it.
My desktop has 5 instances of conky running, each with a different config file. I hope that this change will not affect my normal usage. Perhaps the check needs to be enhanced to include the entire command line and only fail if multiple instances would be running with identical command line arguments
Yes, maybe some PID file named after the command line args (or a hash of them)? Check if there is one, and if the PID still runs…
what about adding a commandline option which prevents start of other instances? Then both use cases could be supported
That won't work for the case where you run more than one instance but also want to use KDE's session restoring feature. Unless it also handles finding the existing instance for the same args.
Yeah for now I also run 7-8 instances each with different configs, I don't think many people would want to run 2 instances with identical configs so maybe thats an approach you could look at.