Re: how to determine from script if/where X is running
Hi, I am not sure if I understand the situation completely, but * like other Debian /etc/acpi scripts, you could run through /tmp/.X11-unix/X[0-9] which will point to locally running X servers, at least those that use UNIX sockets. * to directly reach the X server on the currently selected VT, you could create a key event with acpi_fakekey and have the window manager that is reading the local keyboard or xbindkeys handle the xrandr stuff. Of course, that again requires these programs to run. Alternatively, Xorg can natively bind resolution changes to hotkeys which should be configurable through XKB. * to find out about the VT for X servers (if they haven't been started with the 'vtxx' command line argument to begin with), you could grep the log files, they should contain something like '(++) using VT number 7'. If the location of the logfiles is unknown (which would indeed be a bit strange), lsof could help. * Another possibility for the latter is 'fuser /dev/tty*' which prints the TTY-owning PIDs, amongst them the X servers'. * The currently active VT can be determined with 'fgconsole'. HTH Raimund Martin Kraus wrote: On Wed, Mar 26, 2008 at 06:38:31PM +0100, Sven Joachim wrote: Hello Martin, On 2008-03-26 16:25 +0100, Martin Kraus wrote: Hello, is there a standard way in debian to determine on what VT and display is X running? Say I have a script that does something and I need to return output to the user, but the user can be in linux console or in X or X doesn't have to be running etc. So I need to determine if/where I should popup a window or if I just need to send text to the console. Most programs simply check for the DISPLAY environment variable. This is not totally reliable as it can be changed at will, but if the user messes around with that variable, it is considered his fault. And you're in good company. this doesn't help me when running programs from daemons of cron jobs. say we have a system like this: martin tty1 2008-03-26 12:47 martin tty2 2008-03-26 19:00 martin tty3 2008-03-26 20:10 martin pts/02008-03-26 12:47 (:0.0) martin pts/12008-03-26 12:47 (:0.0) martin pts/22008-03-26 12:51 (:0.0) martin pts/32008-03-26 12:54 (:0.0) martin pts/42008-03-26 13:23 (:0.0) martin pts/62008-03-26 20:09 (:2.0) martin pts/52008-03-26 18:52 (remote.server.example) kb pts/72008-03-26 20:11 (:2.0) and what I would like to do is through keyboard hotkey, that runs an acpi script, change a hardware display expansion on my thinkpad with widescreen. now if I do this in the 1280x768 resolution the system display screwes up. so I need to change the resolution do 1024x768. console with framebuffer is already running in 1024x768 so I don't need to touch it and just tell bios to trigger the display expansion. Xserver however needs to be resized. I can do this throught xrandr. So I need to know, if what the current selected VT is and to determine if there is an Xserver running on that VT. In the example above, there are three Xservers. :0 and :2 are standard Xservers, :1 is Xephyr(ala Xnest). Now I need to know if there is X running on the current VT and also, what display is that X bound to. I could run who and just parse the display numbers and change the resolutions on all Xservers, but if no user is using any applications bound to that Xserver, it will not display in the "who" output. This example is overcomplicated, but for the sake of argument, how would I go about finding binding between Xserver display number and VT console? If I parse output of ps I get this for Xserver with display :0: /usr/bin/X11/X -nolisten tcp which doesn't tell me the display number. I guess I would find hacks for finding the display number for all running Xservers and just change resolution on all of the, which is probably the best way, but is there a standard way to do this in debian? I've noticed, that for example powersaved tried to do something like this to decide where and how to output battery critical information but even the debian package didn't work for debian, because powersave assumed, that it can find display number in /proc/pid/cmdline but it's not there. So to sum it all, it's actually three questions. How to find display number for X server in a standard debian way, how to determine on what VT what X server is running and how to find out currently selected VT(since I assume, there can be only one currently selected VT at any given time) thanks mk -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: how to determine from script if/where X is running
On Wed, Mar 26, 2008 at 06:38:31PM +0100, Sven Joachim wrote: > Hello Martin, > > On 2008-03-26 16:25 +0100, Martin Kraus wrote: > > > Hello, > > is there a standard way in debian to determine on what VT and display is X > > running? Say I have a script that does something and I need to return output > > to the user, but the user can be in linux console or in X or X doesn't have > > to > > be running etc. So I need to determine if/where I should popup a window or > > if I just need to send text to the console. > > Most programs simply check for the DISPLAY environment variable. This > is not totally reliable as it can be changed at will, but if the user > messes around with that variable, it is considered his fault. And > you're in good company. this doesn't help me when running programs from daemons of cron jobs. say we have a system like this: martin tty1 2008-03-26 12:47 martin tty2 2008-03-26 19:00 martin tty3 2008-03-26 20:10 martin pts/02008-03-26 12:47 (:0.0) martin pts/12008-03-26 12:47 (:0.0) martin pts/22008-03-26 12:51 (:0.0) martin pts/32008-03-26 12:54 (:0.0) martin pts/42008-03-26 13:23 (:0.0) martin pts/62008-03-26 20:09 (:2.0) martin pts/52008-03-26 18:52 (remote.server.example) kb pts/72008-03-26 20:11 (:2.0) and what I would like to do is through keyboard hotkey, that runs an acpi script, change a hardware display expansion on my thinkpad with widescreen. now if I do this in the 1280x768 resolution the system display screwes up. so I need to change the resolution do 1024x768. console with framebuffer is already running in 1024x768 so I don't need to touch it and just tell bios to trigger the display expansion. Xserver however needs to be resized. I can do this throught xrandr. So I need to know, if what the current selected VT is and to determine if there is an Xserver running on that VT. In the example above, there are three Xservers. :0 and :2 are standard Xservers, :1 is Xephyr(ala Xnest). Now I need to know if there is X running on the current VT and also, what display is that X bound to. I could run who and just parse the display numbers and change the resolutions on all Xservers, but if no user is using any applications bound to that Xserver, it will not display in the "who" output. This example is overcomplicated, but for the sake of argument, how would I go about finding binding between Xserver display number and VT console? If I parse output of ps I get this for Xserver with display :0: /usr/bin/X11/X -nolisten tcp which doesn't tell me the display number. I guess I would find hacks for finding the display number for all running Xservers and just change resolution on all of the, which is probably the best way, but is there a standard way to do this in debian? I've noticed, that for example powersaved tried to do something like this to decide where and how to output battery critical information but even the debian package didn't work for debian, because powersave assumed, that it can find display number in /proc/pid/cmdline but it's not there. So to sum it all, it's actually three questions. How to find display number for X server in a standard debian way, how to determine on what VT what X server is running and how to find out currently selected VT(since I assume, there can be only one currently selected VT at any given time) thanks mk -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: how to determine from script if/where X is running
Martin Kraus wrote: Hello, is there a standard way in debian to determine on what VT and display is X running? Say I have a script that does something and I need to return output to the user, but the user can be in linux console or in X or X doesn't have to be running etc. So I need to determine if/where I should popup a window or if I just need to send text to the console. Thinking about it, is there any reliable way to find out how are different users logged into the box? ssh,console,running X. The 'who' command may be helpful. On my desktop system, logged in using 'kdm', running 'who -H' (-H prints headers), I get: NAME LINE TIME COMMENT rmcgowan :0 2008-03-26 08:09 Note the LINE column reports ':0', which is the display in use. On a Linux server, using 'ssh' to connect, the same command reports: NAME LINE TIME COMMENT rmcgowan pts/02008-03-26 10:49 (ramjr.veritas.com) Note two things here: the LINE value and the COMMENT. The COMMENT is the system from which I logged in. And, with a console login, you get: rmcgowan tty1 2008-03-26 10:55 added to the two lines from the first example. Again, not the second (LINE) column. In the case of pts/* and tty* values in the LINE column, you add '/dev/' as a prefix and you have the user's login device name, if needed. thanks for help mk If you need to know about processes, check out 'ps' (obviously;-) and 'pstree'. If you need to know which connection the user has most recently used, use 'who -uH', which prints an IDLE column. In the case of X, it prints a '?', otherwise a dot if active, or the idle time, or 'old' if more than 24 hours (IIRC) old. I hope this helps. -- Bob McGowan Symantec, Inc. smime.p7s Description: S/MIME Cryptographic Signature
Re: how to determine from script if/where X is running
On Wed, 26 Mar 2008 18:50:07 +0100, Sven Joachim wrote: > Most programs simply check for the DISPLAY environment variable. This > is not totally reliable as it can be changed at will, but if the user > messes around with that variable, it is considered his fault. And > you're in good company. Though DISPLAY is only set if your process is running from within X. If you need to find a running X from the console (though you won't be able to attach to it) try 'ps'. -- Stephen Patterson :: [EMAIL PROTECTED] :: http://patter.mine.nu/ GPG: B416F0DE :: Jabber: [EMAIL PROTECTED] "Don't be silly, Minnie. Who'd be walking round these cliffs with a gas oven?" -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: how to determine from script if/where X is running
Hello Martin, On 2008-03-26 16:25 +0100, Martin Kraus wrote: > Hello, > is there a standard way in debian to determine on what VT and display is X > running? Say I have a script that does something and I need to return output > to the user, but the user can be in linux console or in X or X doesn't have to > be running etc. So I need to determine if/where I should popup a window or > if I just need to send text to the console. Most programs simply check for the DISPLAY environment variable. This is not totally reliable as it can be changed at will, but if the user messes around with that variable, it is considered his fault. And you're in good company. > Thinking about it, is there any reliable way to find out how are different > users logged into the box? ssh,console,running X. The `who' command tells you on which terminal users are logged in. Though in most cases it will simply report /dev/pts/ as the terminal, and you cannot tell an xterm from an ssh login that way. But you can see who is logged in via a display manager and on the local consoles. Sven -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
how to determine from script if/where X is running
Hello, is there a standard way in debian to determine on what VT and display is X running? Say I have a script that does something and I need to return output to the user, but the user can be in linux console or in X or X doesn't have to be running etc. So I need to determine if/where I should popup a window or if I just need to send text to the console. Thinking about it, is there any reliable way to find out how are different users logged into the box? ssh,console,running X. thanks for help mk -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]