I am using a script which is basically identical to the first one in https://stackoverflow.com/a/4783182/7238575. It works perfectly when run in the terminal or using the option "Run in terminal" (when setting the preference to asking what to do when double clicking a script in Nautilus). However, when I just "Run" it (or when the preference is set to run) it does not work.
What is the difference and what is going on? How can I make the script work with the default "Run" (I would prefer to keep the preference to always use "Run" so that I can just double click to run the script without any dialogs.)
I tried to source bashrc by adding source ~/.bashrc
to get the same environment but that made the script fail even from the terminal so I must have done something wrong. (I commented out the lines in bashrc that preven it from running in interactive mode).