This is a script that was supposed to be very basic, just running a command with my scripts arguments attached. I didn't realize that if user 'cj' opens firefox, when user 'root' does 'firefox -new-tab' it doesn't work. Firefox will just open a new window, and thats exactly what I didn't want to happen. The whole point was to open in a new-tab. So finding the user that logged onto the desktop, when the script was ran by root became the challenge. You can find out who ran the script alot of ways, but thats not what I wanted. Sometimes i'm doing things in my terminal as root and I want to just "gsearch Something" and have it open in a new tab, not a new window. The 'commands' module came in handy here, but if there is a breaking point for this script, it will be in using the 'users' command to get the logged in desktop user.
Another thing about this is it uses 'urllib' to make the search terms compatible URLS. Like:
google.com/search?q="This Is My Search" becomes
Anyway, once again, this is my second week with Python and I'm loving it, there may be better ways to do some of this stuff, but I am still learning. It's part of the process. Part of the reason I'm posting this code is so maybe someone might find something in it and say "hey, you could've just did this in 2 lines", or maybe someone new like me can use it for good. After all, I had to do alot of searching myself to figure some of this stuff out.