Q. If someone is in the bathroom (see question above) and hears the shofar while he is there, is he yotze bediebed (comply after the fact), or does he have to repeat those tekios? Is one even allowed to have kavana (intention) to be yotze?
A. Biur Halacha (588: d’h Shoma), debates whether someone standing in an unclean space, such as a bathroom, while listening to the shofar complies with the mitzva or no. He argues that he should since some mitzvos like wearing tzitzis are permitted there and only when words or thoughts of kedusha are involved one does not. He quotes the Mateh Efraim who maintains that after the fact he complies but on the onset, he should repeat the tekios if possible, but without a brocho. He adds that since we rule that mitzvos require kavanah or intention to comply, that in itself is similar to Torah learning.
However, Shaarei Tzion (690) maintains that the kavanah is esential only at the beginning of the mitzva.
See Bekorei Shemo – (Mitzva 14), regarding fixing tzitzis inside an unclean place and Hilchos Ketanos (2: 57) concerning shechita done inside unclean sites. See also question 445 on observing the six constant mitzvos in unclean situations and questions 2227 and 2593 in regard to what aspects of Torah related educational material can be read in a bathroom.
Horav Shlomo Miller’s Shlit’a opinion is that bedieved one complies with the shofar heard while inside a bathroom.
Rabbi A. Bartfeld as advised by Horav Shlomo Miller and Horav Aharon Miller Shlit’a