Hi all!
I’ve already announced this at IRC, and now I’m posting here
I’ve written little perl script that makes dynamic menu with attached and/or deattached screen sessions. So, here we go. First, code you need to enter into your configs:
[code]AddToMenu MyMenu
- Popup SubMenuScreen
DestroyMenu recreate SubMenuScreen
AddToMenu SubMenuScreen
- DynamicPopupAction Function BuildScreenMenu
DestroyFunc BuildScreenMenu
AddToFunc BuildScreenMenu
- I DestroyMenu recreate SubMenuScreen
- I AddToMenu SubMenuScreen
- I Piperead ‘echo “
$HOME/.fvwm/bin/fvwm-screen-menu.pl
”’ [/code]
And now the script:
[code]#!/usr/bin/perl -w
#################################
fvwm-screen-menu.pl
by: jsosic
#################################
use Shell qw(screen grep hostname);
Get list of detached/attached screen sessions and hostname
$s_detached_sessions = screen(’-list | grep Detached’);
$s_attached_sessions = screen(’-list | grep Attached’);
$hostname = hostname(’’);
regexps rule
$hostname=~s/\s//g;
$s_detached_sessions=~s/()|(|Detached|$hostname|^\s+)//g;
$s_attached_sessions=~s/()|(|Attached|$hostname|^\s+)//g;
$s_detached_sessions=~s/…\n//g;
$s_attached_sessions=~s/…\n//g;
Finally, here’s what we came for.
@ls_detached_sessions = split /\s+/, $s_detached_sessions;
foreach my $session (@ls_detached_sessions){
print " + “$session” Exec exec urxvtc -n screen -e screen -r $session.$hostname \n";
}
put separator if there are detached screens…
if ($s_detached_sessions ne “”){
print " + “” NoP\n";
}
Add some general stuff…
print " + “New Session” Exec exec urxvtc -n screen -e screen \n";
print " + “Reattach first” Exec exec urxvtc -n screen -e screen -d -RR \n";
put separator if there are attached screens…
if ($s_attached_sessions ne “”){
print " + “” NoP\n";
}
Little last minute addition: Attached sessions
@ls_attached_sessions = split /\s+/, $s_attached_sessions;
foreach my $session (@ls_attached_sessions){
print " + “$session” Exec exec urxvtc -n screen -e screen -d $session.$hostname \n";
}
[/code]
Also, don’t forget to chmod +x the script, and pinpoint it correctly in your config.
Happy screen-ing!