Code to make an existing Nyquist plugin for Audacity not need any audio to be selected?

I’m trying to improve both examples of Nyquist code already on Rosetta Code (Hello world/Graphical and Hello world/Text) by making it so no audio has to be selected to allow them to be activated.

A selection is not required for “tool” type effects.
See also my previous post: https://forum.audacityteam.org/t/coding-a-nyquist-plugin-that-simply-just-brings-up-the-debug-output-and-outputs-only-a-set-piece-of-text-to-it/53123/4

Changing those plugins to the type “Tools” did work for me. But are there any ways to modify existing Audacity plugins to not need any audio to be selected to be activated without the plugin type being set to “Tools”?

See: https://wiki.audacityteam.org/wiki/Nyquist_Plug-in_Headers

in particular, this section: https://wiki.audacityteam.org/wiki/Nyquist_Plug-in_Headers#type

Why would you want to? An “effect” (;type process), by definition, requires a selection, otherwise there is no audio to process. Similarly for “analyze” type plug-ins.

To answer your question directly, “tool” and “generate” are the two types that do not require a selection. “generate” type should be used for plug-ins that generate audio.

Changing those plugins to the type “Generate” also work for me. But are there any ways to modify existing Audacity plugins to not need any audio to be selected to be activated with the plugin type being set to “Effect” or “Analyze”?

All of the shipped “Effect” and “Analyze” plug-ins require an audio selection and cannot work without audio selected.

What about user-made plugins?

What about them? What is the purpose of your enquiry?
You are free to modify any plug-in any way that you want.