Re: Auto shutdown
Lorenzo Sutton <[email protected]>
| Newsgroups | gmane.comp.audio.rosegarden.user |
|---|---|
| Message-ID | <[email protected]> |
On 03/09/2022 14:25, Will Godfrey wrote: > On Fri, 2 Sep 2022 17:06:03 +0200 > Lorenzo Sutton <[email protected]> wrote: > >> On 02/09/2022 16:30, Lorenzo Sutton wrote: >>> On 02/09/2022 11:43, Will Godfrey wrote: >> ... >>>>> On 7/25/22 4:00 PM, Will Godfrey wrote: >>>>>> Is there any way to externally tell Rosegarden to close files and >>>>>> cleanly shut >>>>>> down? >> ... >>>> >>>> pidof rosegarden >>>> followed by >>>> kill nnnn >>>> seems to give a clean shutdown, even of a running instance. So all I >>>> need to do >>>> now is write a small program to combine those into a single command - >>>> might be >>>> able to do that in python. >>>> >>> >>> In bash you should be able to just do: >>> >>> kill $(pidof rosegarden) >>> >> >> Or... with Python (including some fancy output in case the pid is not >> found, e.g. because rosegarden isn't actually running) - something like >> this: >> >> https://gitlab.com/-/snippets/2401192 > > Yes that worked fine, but I need to make a correction. > > While it quietly shuts down Rosegarden, it still leaves the dot file claiming > another copy of your project is running, next time you start. > > When Rosegarden shuts itself down, this file is removed, but not when told to > shutdown externally. Can this be made to happen? > > My project is particularly targeting people unfamiliar with Linux, who would > have no idea what to do under these circumstances. > It seems this hackery with xdotool [1] works, essentially doing the equivalent of focusing the rosegaden window and simulating a CTRL+Q keypress: xdotool windowactivate $(xdotool search --all --onlyvisible --pid $(pidof rosegarden)) key --clearmodifiers ctrl+q But, if the open file is unsaved, like with a 'normal' quit rosegarden will prompt to save. Not sure if this still works for you. Maybe you could concatenate with and && two similar commands first simulating ctrl+s and then ctrl+q, but that might or might not be desired depending on the use case. Otherwise I guess that some (Unix) signal catching code should be added within rosegarden, but I'll leave that to Ted et al. to answer :-) Lorenzo [1] https://www.semicomplete.com/projects/xdotool/