LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 07-29-2009, 12:45 AM   #1
micxz
Senior Member
 
Registered: Sep 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
How do I get another users $DISPLAY


I'm trying to get my girlfriends DISPLAY via script but when I try in the terminal first:

Code:
home:~ # su - -c 'echo $DISPLAY' amber

home:~ # su - -c 'echo $USER' amber
amber
I know her DISPLAY is ":1.0" but why would I be able to get some env vars and not others?
 
Old 07-29-2009, 01:15 PM   #2
mackdav
Member
 
Registered: Feb 2005
Distribution: RHEL, CentOS
Posts: 113

Rep: Reputation: 16
Environment variables are set by the login context or the program being run (in this case, X). So just by su - ing to her you won't see what her session environment variables are, because when you su - to her, you are creating a new session, not duplicating an existing one.

What are you trying to accomplish?
 
Old 07-29-2009, 07:07 PM   #3
micxz
Senior Member
 
Registered: Sep 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Original Poster
Rep: Reputation: 75
I'm trying to get her display so I can send graphical notifications to her screen via "notify-send". It's really not that important I'm just playing around. I think I found a way around it by using su and then getting the xauth cookie list import the cookie and then set display to hers and send the popup or other to her screen. When you list xauth cookies they are in the format host:1 for user on host display :1.0 and so on. So I guess this works but it's a funky script I would like to be able to get display var alone but maybe it's not possible. I can see it in /proc/"kdeinit_procnumber"/environ but when I try to grep but it says "binary file matches".
 
Old 07-29-2009, 07:30 PM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
The "USER" and "DISPLAY" variables will be part of her environment.

You can grep out the PID of a process she will be using, and then
tr '\0' '\n' /proc/$pid/environ | grep DISPLAY=

I had just posted this, and other things, in your other semi-related post on cron, before reading this thread.

Look at the Xstartup script, if you have it. It does things like parse the DISPLAY variable to tell if it is a local or remote connection.
Code:
# Find out if this is a local or remote connection
#
LOCATION=${DISPLAY%:*}
LINE=:${DISPLAY#*:}
if test -z "$LOCATION" ; then
    # local connection
    case "$LINE" in
        :0|:0.0) LOCATION=console   ;;
        *)       LOCATION=localhost ;;
    esac
else
    # TCP/IP connection (remote or local)
    NAME=${LOCATION%%.*}
    if test -z "${NAME%%*[0-9]}" ; then
        LINE=${LINE}/${LOCATION}
    else
        LINE=${LINE}/${NAME}
    fi
fi

Last edited by jschiwal; 07-29-2009 at 07:35 PM.
 
Old 07-29-2009, 08:10 PM   #5
micxz
Senior Member
 
Registered: Sep 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Original Poster
Rep: Reputation: 75
Thank You I'm going to look at this a bit closer.
 
  


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
Locking down display for users (RHEL4) abti Red Hat 8 10-15-2008 11:30 AM
Display Linux users boybawang Linux - Newbie 3 09-26-2006 03:20 AM
display all users on system jkassemi Linux - Newbie 2 02-19-2005 11:12 AM
[FC2]Why does the users command display multiple users? Harkov Fedora 1 07-10-2004 09:24 PM
Display Last Login message for users smile_laguna Linux - Newbie 4 02-28-2004 01:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 05:34 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