LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-18-2010, 10:13 AM   #1
bwilhite
LQ Newbie
 
Registered: Feb 2010
Posts: 9

Rep: Reputation: 0
Run a script on switch-user event Ubuntu 9.10


How to do so? For starters, I'm not sure there is such an event. Maybe it has something to do with the OS moving through certain run-levels? A nudge in the right direction would be appreciated.

Thanks,
BW
 
Old 02-18-2010, 03:14 PM   #2
jf.argentino
Member
 
Registered: Apr 2008
Location: Toulon (France)
Distribution: FEDORA CORE
Posts: 493

Rep: Reputation: 50
I'm not sure there's such an user-switch event since linux is a multi-users system (many users can be logged in the same system at a while), but for sure you've got a log-off and a log-on event, and you can add actions by editing .bashrc and .bash_logout file in your home directory...
 
1 members found this post helpful.
Old 02-19-2010, 05:47 AM   #3
bwilhite
LQ Newbie
 
Registered: Feb 2010
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jf.argentino View Post
I'm not sure there's such an user-switch event since linux is a multi-users system (many users can be logged in the same system at a while), but for sure you've got a log-off and a log-on event, and you can add actions by editing .bashrc and .bash_logout file in your home directory...
Thanks for the suggestion. Working off of login/logout was my next option. What about Gnome, does it have some kind of hook I can use when switch user occurs? I'll start looking into it, but maybe someone out there knows already...
 
Old 02-19-2010, 06:12 AM   #4
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by bwilhite View Post
...
What about Gnome, does it have some kind of hook I can use when switch user occurs? I'll start looking into it, but maybe someone out there knows already...
I don't think you've clearly explained what you really need.

For example, under your desktop environment of choice (say, Gnome) in a terminal window you type

Code:
su UserOtherThanYou
and then the password.

Do you consider this to be switching users ?
 
Old 02-20-2010, 07:26 AM   #5
bwilhite
LQ Newbie
 
Registered: Feb 2010
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Sergei Steshenko View Post
I don't think you've clearly explained what you really need.

For example, under your desktop environment of choice (say, Gnome) in a terminal window you type

Code:
su UserOtherThanYou
and then the password.

Do you consider this to be switching users ?
When I use Gnome to switch users, which will bring up a new desktop, I want to have a script automatically run at that point. To be even more explicit, in ubuntu there is a default applet in the upper-right hand corner of the screen which which has a drop down menu that says "Switch User..." When I (or anyone else) clicks on that option and uses it to switch users, I want to automatically run a script. I'm sure there are a sequence of events that occur when the user chooses this option, and there is probably some way to hook my script into this process...So the question is how to do so?
 
Old 02-20-2010, 07:33 AM   #6
bwilhite
LQ Newbie
 
Registered: Feb 2010
Posts: 9

Original Poster
Rep: Reputation: 0
Attached is a screenshot...when I click on this menu option, I want my own script to be automatically run at some point (I don't think at the moment it matters exactly when).
Attached Thumbnails
Click image for larger version

Name:	SwitchUser.jpg
Views:	21
Size:	130.3 KB
ID:	2789  
 
Old 02-20-2010, 07:44 AM   #7
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Do you use gnome?
Take a look at
Code:
/etc/gdm/PostSession/Default
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to switch user via shell script cool_anupam Linux - General 7 05-29-2008 10:01 PM
How to make the right mouse button run a script (event trigger) xmrkite Linux - Hardware 5 10-17-2006 01:29 PM
run script at hotplug event AAnarchYY Linux - Hardware 1 07-21-2006 09:19 AM
Switch to another user, get his env and run a command 'under his name' ganninu Linux - General 2 05-25-2004 02:26 PM
how to run script on event ppp0 interface going down ? qwijibow Linux - Networking 4 02-24-2004 06:08 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration