Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Open GUI programs as a fast-switched-out user System
I figured out a method for opening a GUI program as a user who is not the "switched in" user, i.e. a user who is logged in, but someone else has fast user switched to another account. This also works for opening a GUI program over ssh, which is not possible for non-console users. Assume the user's name is "foo." Fast Switch to user "foo" and open Terminal.app. Then type screen and hit Enter.

This starts a unix shell that is independent from the Terminal.app window, and can be attached to any other logged in shell, even over ssh. Then Fast Switch to another user, and ssh into your computer mycomputer as user foo:
ssh foo@mycomputer
Note that if you are doing this on mycomputer that you should use ssh not su, since screen cannot write to the tty if it is owned by another user. Now you can reattach to the screen:
screen -x
The same shell that you saw after typing the initial screen shows up. But since we started that screen as the GUI logged in user, it has the same privileges as being a GUI user typing in Terminal.app. Thus we can open, say, TextEdit.app:
open /Applications/TextEdit.app
I haven't tested this out much, but one particular use is it makes it easy to start up iTunes as a specific user, and access the shared music, without worrying if that user is Switched in.

[robg adds: I'm not sure if there are any ramifications of this, but it's somewhat interesting!]
    •    
  • Currently 2.67 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)
 
[11,668 views]  

Open GUI programs as a fast-switched-out user | 14 comments | Create New Account
Click here to return to the 'Open GUI programs as a fast-switched-out user' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Open GUI programs as a fast-switched-out user
Authored by: jammjamm on Apr 07, '04 12:41:42PM

This could be used to create a TEST user and to run untrusted apps as that user to make sure they don't wipe your HOME dir. Wouldn't work if a program made you enter a root password.



[ Reply to This | # ]
Open GUI programs as a fast-switched-out user
Authored by: Faux Plastic on Apr 07, '04 01:31:17PM

I can tell you one use for this, if I understand it correctly. It would allow you to have two copies of the same app open, each with their own set of preferences. You could create a second, "dummy" user, and then login to your own account and open a second copy of, say, Safari, the preferences for which are saved in Dummy's library.

I needed this a couple weeks ago. I was working on a project where I had to take a lot of screenshots of web pages. I wanted to to do it in Safari because I like it's GUI. But I had to turn off my bookmark bar, the Google search box, and some of the buttons to get a cleaner look.

But that made using Safari for my own personal browsing--while I was working on the project--a PITA. I wound up copying all my bookmarks over to Firefox and doing my personal browsing in Firefox. But this would have been much better.



[ Reply to This | # ]
Open GUI programs as a fast-switched-out user
Authored by: digitalone on Apr 07, '04 03:56:36PM

Does this work? So, I could run a Mac program- let's use Mac Mail as an example- on a remote machine using the "target" user's preferences? I could see this being very helpful to troubleshoot client issues in a technical support capacity. Have you tried this yet? I haven't, but I will later tonight.


---
- 7h4 d!917@l0|V3



[ Reply to This | # ]
Open GUI programs as a fast-switched-out user
Authored by: niloc132 on Apr 07, '04 04:23:26PM
From my testing and understanding of this, tht would not work - when it launches the app, it does so in the other user's screen, even though that is not active.

OTOH, what you are looking for can also be done - if you sudo a task as another suer, it will run more than one copy of a program. I have an alias in my .bash_login for suTextEdit to have root run TextEdit with a given document, which opens another copy of the program, except with root permissions. (I believe the line is
alias "suTextEdit"="sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit";
) - I think this bit of code was taken off this site...

I'm sure that can be modified to your liking.

(Extra thought:) What about launching another dock...say on the side instead of the bottom...

[ Reply to This | # ]
Open GUI programs as a fast-switched-out user
Authored by: digitalone on Apr 07, '04 03:49:09PM

You guys are missing a much better use of this program. Set the terminal to open when the user logs in, and have the terminal run the "screen" command when it starts. Hide the terminal from the user in thier preferences. Then have fun opening programs on your unwitting wife or loved one and laugh your a55 off for a good 5 minutes.

j/k


---
- 7h4 d!917@l0|V3



[ Reply to This | # ]
Open GUI programs as a fast-switched-out user
Authored by: niloc132 on Apr 07, '04 04:13:13PM

The snag to that plan is that you need to have their password.
Sadly, I thought about that one too - if only this had come a few days ago in time for April Fools day...



[ Reply to This | # ]
Open GUI programs as a fast-switched-out user
Authored by: CoolerQ on Apr 07, '04 07:37:31PM

Well, that's not entirely true. If you have access to their account/machine when they're not looking, you can set up SSH public key authentication so that you can login to their account without a password. Check the manpages for the details.
--Quentin



[ Reply to This | # ]
Open GUI programs as a fast-switched-out user
Authored by: fivefifty on Apr 07, '04 08:46:34PM

Thought I should clarify. The app that's opened opens in the switched-out screen, not the screen of the current displayed user. Thus when you switch back, the program is open. This won't work without screen over ssh if the target user is not console. If you just type "open" after "su"ing in to a switched out user it will open the program as the switched in user.



[ Reply to This | # ]
Open GUI programs as a fast-switched-out user
Authored by: frankxiv on Apr 07, '04 10:31:52PM

I am really curious. What is the point of opening a GUI app that you can't see???

I mean if it opens under another user what is the point? Why wouldn't you simply open that app when you are switched to that user??? Please let me know if I am missing something.

Later, Frank



[ Reply to This | # ]
Open GUI programs as a fast-switched-out user
Authored by: lamon on Apr 08, '04 04:44:49AM

I see a couple of reasons for doing this (provided they work)

1/ Open scriptable applications and run commands through applescripts

2/ Run VNC on the switched-out display and access your mac remotely while somebody else is working on it.



[ Reply to This | # ]
Open GUI programs as a fast-switched-out user
Authored by: rsnyder on Apr 08, '04 10:19:34AM

Has anyone tried this yet? It would FINALLY give OSX the ability to have multiple users logged in to the windowing environment--one of the few persistant issues OS X that Apple needs to address, especially on the server version of OS X.

I will try to test it out, myself, but am in meetings all day.



[ Reply to This | # ]
Open GUI programs as a fast-switched-out user
Authored by: Krioni on Apr 09, '04 06:19:02PM

I think your #1 is correct: you could use this to run apps and scripts. I do not think, though, that you are correct about #2. If I remember correctly VNC and Timbuktu return the actual display active on the computer, not of the user logged in. Look up security issues regarding Timbuktu (and thus probably VNC) about how it sees the _current_ user, so this would allow someone with an Admin account to install Timbuktu and then watch other users on the machine when they are the "switched-in" user.



[ Reply to This | # ]
Open GUI programs as a fast-switched-out user
Authored by: viscaria on Apr 08, '04 10:27:29AM

I don't see how this could be usefull locally, but I do use the open command and ssh to remotely open random apps and creep out my sister.



[ Reply to This | # ]
Open GUI programs as a fast-switched-out user
Authored by: SPOOF on Apr 19, '04 09:37:45AM

Even with just ssh into a box, you can do this.
Rather than ./Applications/iTunes.app
you just have to do:
./Applications/iTunes.app/Contents/MacOS/iTunes
This will run iTunes on that system until you control-c...I use this when I forget to start up iTunes on my server, and I want to access my library from the other room.

You can, alternately, also abuse this same ability to have applications running on YOUR screen as a different user.
Open up the terminal and simply type "su user -" where user is the short name of the user you want running the application. The - means to use their directory structures and prefs, rather than yours, so make sure that's there if you want, for example, to run iTunes with a library of somebody else on your machine. It will ask for the password of that user. Then simply follow the above instructions and it'll launch iTunes as that user.

As a side note, different applications behave differently. Some will detach immediately and only allow one instance, your own. Others will run multiple versions from multiple users on your screen, but any time you try to drag and drop to the doc, you will always get your OWN user variant of it, you'll have to use the open command inside the application in order to use that one (for example, to run VLC multiple times as different users). Some Applications can be run with multiple instances like this as well. Your mileage will vary based on the application.

---
-----------------------------------------------------------
Signature? You don't want that. I can't even read it.



[ Reply to This | # ]