LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-12-2007, 02:31 AM   #1
michal017
Member
 
Registered: Jan 2004
Location: EU
Distribution: Debian
Posts: 90

Rep: Reputation: 15
determine active terminal


Is it possible to determine which terminal is active at present?
In fact, it would be sufficient to determine whether a user is working in X or using tty console.
I need this to set up my instant messaging notifications (visual vs. audio) and my instant messaging online presenece (this is done using xscreensaver now, but when I'm working using console, it does not work as expected).
Thanks
 
Old 06-12-2007, 08:10 AM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
You'll probably be writing a shell script to set up the instant messaging notifications, right?

Try putting this fragment in your shell script:

Code:
tty | grep dev.tt > /dev/null

if [ "$?" = "0" ]
then
  echo this guy is at a non-X console
else
  echo this guy is using X
fi
Hope this helps.
 
Old 06-12-2007, 08:28 AM   #3
michal017
Member
 
Registered: Jan 2004
Location: EU
Distribution: Debian
Posts: 90

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by wjevans_7d1@yahoo.co
You'll probably be writing a shell script to set up the instant messaging notifications, right?
Yes

Quote:
Originally Posted by wjevans_7d1@yahoo.co
Try putting this fragment in your shell script:

Code:
tty | grep dev.tt > /dev/null

if [ "$?" = "0" ]
then
  echo this guy is at a non-X console
else
  echo this guy is using X
fi
Hope this helps.
Yes, but the script is running periodically from cron, so tty will report the terminal that the cron owns (if any), right?
 
Old 06-13-2007, 11:02 AM   #4
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
I'm having difficulty making sense of this.

If this is being run from cron, just what do you want it to do? The cron daemon (crond) isn't being run from any screen or terminal or tty or anything. How do you want it to behave? Count the number of bash interactive shells being run from non-X consoles, and the number being run from xterm, and then take a majority vote or something? Or is there a cron job being run for every user shell window? What?
 
Old 06-14-2007, 12:11 AM   #5
michal017
Member
 
Registered: Jan 2004
Location: EU
Distribution: Debian
Posts: 90

Original Poster
Rep: Reputation: 15
See, for instance, the command w.
It shows a column called IDLE, which (most of the time) shows value of 0.00s for the terminal where you run the 'w' command. So the command 'w' knows which terminal is idle and for how long.
Now I'd like to have funcitionality similar to this.
The trick is this does not work if I run a 'screen' inside X and reattach it console.
 
  


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
making a script that opens terminal and enter commands into that terminal Cinematography Linux - General 8 12-16-2008 10:34 AM
Switching back to the Mandrake 9.1 desktop from terminal rdesktop terminal session marc218 Linux - General 6 02-08-2007 02:45 PM
How do i determine my IP address? How do i determine my host name? jwymore Linux - Networking 5 02-07-2007 09:57 AM
Finding the active terminal in linux levr Programming 8 06-14-2006 12:16 AM
active desktop from terminal giovannym Linux - Newbie 4 04-15-2005 12:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:36 PM.

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