Results 1 to 7 of 7
So, I need a way to have screen (or dbus, whatever) to spit out a list of windows (title and number) that are active in a screen session.
I'm writing ...
- 05-21-2011 #1Just Joined!
- Join Date
- May 2011
- Posts
- 3
Screen listing of windows in a session
So, I need a way to have screen (or dbus, whatever) to spit out a list of windows (title and number) that are active in a screen session.
I'm writing a wrapper for common work tasks. Part of the functionality will check if a certain window exists, and if so let me know. The idea here is to prevent accessing the same machine twice. (although, and override option would probably be needed, just in case, but I digress...)
I've searched through the screen man page and don't see anything that'll work. I'm not beyond forking screen and ending up with a custom version. However, I'd like to avoid that if I can.
Thoughts?
Edit: Ideally, I'd like to see something like "screen -S screen_name -window-list" or similar.
- 05-22-2011 #2Just Joined!
- Join Date
- May 2011
- Posts
- 44
What's wrong with screen -ls
You could potentially (untested):
Code:#!/usr/bin/perl use strict; use warnings; my @screens = split/\n/ `screen -list`; shift @screens; pop @screens; print "$_ \n" foreach @screens;
- 05-22-2011 #3Just Joined!
- Join Date
- May 2011
- Posts
- 44
ok, it works, but I missed a comma, also, you need to pop screens twice as the output ends with two new lines:
as a one liner:
expanded:Code:perl -e 'my @screens = split/\n/[b],[\b] `screen -ls`; pop @screens for (1 ..2); shift @screens; print "$_ \n" foreach @screens;'
Code:#!/usr/bin/perl use strict; use warnings; my @screens = split/\n/, `screen -ls`; pop @screens for (1 ..2); shift @screens; print "$_ \n" foreach @screens;'
- 05-22-2011 #4Just Joined!
- Join Date
- May 2011
- Posts
- 3
That's the same as 'screen -list', sans parsing.
In that screen, are 9 or 10 _windows_. The same output as 'windowlist -b' or C-a " in screen. I need that to be blasted to a shell so I can manipulate as needed.Code:[shellbox.xen][~] ag-> perl test.pl 2828.ag (Attached) [shellbox.xen.andrewglenn.net][~] ag-> cat test.pl #!/usr/bin/perl use strict; use warnings; my @screens = split/\n/, `screen -ls`; pop @screens for (1 ..2); shift @screens; print "$_ \n" foreach @screens; [shellbox.xen][~] ag-> screen -list There is a screen on: 2828.ag (Attached) 1 Socket in /var/run/screen/S-ag.
Edit: Grammatical Errors.
- 05-22-2011 #5Just Joined!
- Join Date
- May 2011
- Posts
- 44
Yes, I believe that screen -ls is an alias for screen -list.
sorry can't help here. What utility has the windowlist command? Unrecognized in my system (and my brain...)
Still not clear on what you are looking for. Are you using Screen to manage an X Window session and that x window session has multiple windows?
- 05-22-2011 #6Just Joined!
- Join Date
- May 2011
- Posts
- 3
As per goo.gl/RoNko
Example screenshot: i52.tinypic.com/35iujqq.pngCode:C-a " (windowlist -b) Present a list of all windows for selection. See Selecting.
I need that to be tossed to STDOUT so I can parse it...
- 05-26-2011 #7Just Joined!
- Join Date
- May 2011
- Posts
- 44
Ok, I see now. I can get the C-a " to work but I am still unsure of how `windowlist -b` works. (I imagine it is a command instead of a shortcut that calls the same procedure...) My thinking is that understanding this function call is the key to understanding how screen outputs its message.


Reply With Quote
