Using your app works fine for me.
Also I will check your suggested code improvements although I have doubts this will ever work after so many tests I made.
Sometimes I got the message "Please do NOT call me on already selected SIM ($1) !" which I shouldn't, maybe the currentSIM file got messed when using the command in my script. I think maybe the file is not updated when sim-switcher is run inside a script or maybe other reason. ... The first switch went fine to SIM2, but then switch back to SIM1 failed and the phone remained with Operator2. This due to "Call not allowed" message when trying to make any call with SIM2. The same as before, I could switch back to SIM1 only after running killall csd. So it is quite clear that for some reason switching the SIM in any other way than from application icon will fail.
I would suggest an improvement in your application: - possibility to use your script silently without pop-up messages, e.g. if I want to switch by Alarmed I don't want success messages to be displayed.