In short when you notice drowsiness don't just sit there developing that theme of anapanasati, metta, the noting of drowsiness and whatnot. See Capala Sutta for examples.
As soon as you notice that the hindrance of drowsiness is present in you then you should rouse yourself as to wake yourself up and give attention to the theme of arousal of energy or joy.
This you can do by contemplating stirring objects, something that makes ypu glad and even doing tiresome work and whatnot. Basically somehow you hype yourself up if you can.
On the other hand if restless then harness the excess energy to stick to a meditation object like it's glued. A calming theme is used here, something like the breath is good if the mind is racing because anapanasati is particularly good at preventing distracting thoughts.
Otherwise one could develop the themes or appreciation or recollection of nice things like one's virtue, the gems or devas. These can be both calming andor gladdening.
The theme you pick depends on your temperament and circumstances, you can use other themes like the asuba or metta as well if you want, anything that keeps you focused all the way into jhanas.
What then happens is that mind quickly gets secluded due to that non-distractedness on account of directing of aroused energy and keeping it focused.
I have studied this extensively and this is only a very brief practical abbreviation of how to train, not analyzing each theme nor each factor.
Here some texts i've read;
Dhamma Vicaya
He, dwelling mindful in the above manner, searches, investigates and reasons out thoroughly that same thing with wisdom. This is called truth investigation-awakening-factor. (2) Therein what is truth investigation-awakening-factor? That which is wisdom, understanding. absence of delusion, truth investigation, right view, truth investigation-awakening-factor, path constituent, included in the path. This is called truth investigation-awakening-factor.
“And how, bhikkhus, is a bhikkhu a triple investigator? Here, bhikkhus, a bhikkhu investigates by way of the elements, by way of the sense bases, and by way of dependent origination. It is in such a way that a bhikkhu is a triple investigator…
- Viriya
The energy of his searching, investigating and reasoning out thoroughly that same thing with wisdom, is strenuous, unshrinking. This is called energy-awakening-factor. (3)Therein what is energy-awakening-factor? That which is the arousing of mental energy. right effort, energy-awakening-factor, path constituent, included in the path. This is called energy-awakening-factor.
The mental inception of energy which there is on that occasion, the striving and the onward effort, the exertion and endeavour, the zeal and ardour, the vigour and fortitude, the state of unfaltering effort, the state of sustained desire, the state of unflinching endurance, the solid grip of the burden, energy, energy as faculty and as power, right endeavour—this is the energy that there then is.
- Piti
Therein what is rapture-awakening-factor? That which is rapture, gladness, rejoicing, rapture, mirth, merriment, felicity, elation, delight of consciousness, rapture-awakening-factor. This is called rapture-awakening-factor. (4)For him of strenuous energy there arises rapture that is not worldly. This is called rapture-awakening-factor. (4)
The joy which on that occasion is gladness, rejoicing at, rejoicing over, mirth and merriment, felicity, exultation, transport of mind—this is the joy that there then is.
- Passadhi
Therein what is calmness-awakening-factor? That which of the aggregate of feeling, of the aggregate of perception, of the aggregate of volitional activities, of the aggregate of consciousness is calmness, serenity, being calm, being serene, state of being serene, calmness-awakening-factor. This is called calmness-awakening-factor. (5)For him of raptureful mind the body (of mental aggregates) becomes calm, also consciousness becomes calm. This is called calmness-awakening-factor.
The serenity, the composure which there is on that occasion, the calming, the tranquillizing, the tranquillity of the aggregates
- Samadhi
Therein what is samādhi-awakening-factor? That which is stability of consciousness. right samādhi, samādhi-awakening-factor, path constituent, included in the path. This is called samādhi-awakening-factor. (6)For him of calm body (of mental aggregates) and mental pleasure, consciousness is in samādhi. This is called samādhi-awakening-factor.
The stability, solidity, absorbed steadfastness of thought which on that occasion is the absence of distraction, balance, imperturbed mental procedure, quiet, the faculty and the power of concentration, right concentration—this is same as composure [collectedness/self-collectedness/onepointedness]
- Upekkha
Therein what is equanimity-awakening-factor? That which is equanimity, having equanimity, supreme equanimity, state of balance of consciousness, equanimity-awakening-factor. This is called equanimity-awakening-factor. He, having consciousness in samādhi in the above manner, is well balanced. This is called equanimity-awakening-factor.
The mental [condition] neither pleasant nor unpleasant, which, on that occasion, is born of contact with the appropriate element of representative intellection; the sensation, born of contact with thought, which is neither easeful nor painful; the feeling, born of contact with thought, which is neither easeful nor painful—this is the feeling that there then is.
*Here end the Theravadin Abhidhamma & Sutta excerpts.
Also when the mind is sluggish or aroused, the theme you pick depends on why it is aroused, it might be due to remorse, worry, anger, sensual desire or due to giving of attention to the factor of Viriya as you can easily hype yourself up immensely once you get a grip on this.
Therefore one should be mindful of the hindrances at all times.
I won't post on these and picking themes but i have compiled commentary and sutta excerpts here;
https://docs.google.com/document/d/1qVz1XtntivxPRsxycsrH0_sgILcMbcghdpxoKuxlLYo/edit?usp=drivesdk
I think the least obvious development is that of upekkha factor and there are several ways of going about it.
Ie defining elements brings about a kind of equanimity, as do certain lines of contemplation and entering the 4th rupa jhana brings about a kind of equanimity.
In general equanimity that is good is brought about however you can get it imo.