diff options
| author | David Leadbeater | 2014-12-20 18:45:14 +0000 |
|---|---|---|
| committer | David Leadbeater | 2014-12-20 18:45:14 +0000 |
| commit | 484d3ffda26556a2a8a2b75eb5d686bd97047109 (patch) | |
| tree | 0933af4bf654f80400ffcc4e8e4001f715f6688a | |
| parent | c2d8c47a35d88c5deeee3338de5fc8ab16558259 (diff) | |
| parent | 5b9a4d686fb2905dd2463be309a0dc9a8d275d41 (diff) | |
| download | scripts.irssi.org-484d3ffda26556a2a8a2b75eb5d686bd97047109.tar.bz2 | |
Merge pull request #101 from aapa/screen_away.pl-styfix
screen_away.pl: $STY won't get changed if sessionname is changed during the session
| -rw-r--r-- | _data/scripts.yaml | 4 | ||||
| -rw-r--r-- | scripts/screen_away.pl | 11 |
2 files changed, 10 insertions, 5 deletions
diff --git a/_data/scripts.yaml b/_data/scripts.yaml index e8732fe..f40f798 100644 --- a/_data/scripts.yaml +++ b/_data/scripts.yaml @@ -3305,12 +3305,12 @@ - authors: "Andreas ads Scherbaum <ads@wars-nicht.de>" description: "set (un)away, if screen is attached/detached" filename: "screen_away.pl" - modified: "2008-05-22 01:28:25" + modified: "2014-12-20 20:30:00" license: "GPL v2" modules: "FileHandle" name: "screen_away" url: "none" - version: "0.9.7.1" + version: "0.9.8.1" - authors: "Stefan tommie Tomanek" commands: "scriptassist" diff --git a/scripts/screen_away.pl b/scripts/screen_away.pl index 86e3087..722ceed 100644 --- a/scripts/screen_away.pl +++ b/scripts/screen_away.pl @@ -4,7 +4,7 @@ use FileHandle; use vars qw($VERSION %IRSSI); -$VERSION = "0.9.7.1"; +$VERSION = "0.9.8.1"; %IRSSI = ( authors => 'Andreas \'ads\' Scherbaum <ads@wars-nicht.de>', name => 'screen_away', @@ -18,6 +18,7 @@ $VERSION = "0.9.7.1"; # written by Andreas 'ads' Scherbaum <ads@ufp.de> # # changes: +# 20.12.2014 fix the bug when screenname is changed during the session # 07.02.2004 fix error with away mode # thanks to Michael Schiansky for reporting and fixing this one # 07.08.2004 new function for changing nick on away @@ -83,7 +84,7 @@ if (!defined($ENV{STY})) { return; } -my ($socket_name, $socket_path); +my ($socket_pid, $socket_name, $socket_path); # search for socket # normal we could search the socket file, ... if we know the path @@ -99,9 +100,13 @@ my $running_in_screen = 0; # locale doesnt seems to be an problem (yet) if ($socket !~ /^No Sockets found/s) { # ok, should have only one socket - $socket_name = $ENV{'STY'}; + # $STY won't change if sessionname is changed during session + # therefore first find the pid and use that to find the actual sessionname + $socket_pid = substr($ENV{'STY'}, 0, index($ENV{'STY'}, '.')); $socket_path = $socket; $socket_path =~ s/^.+\d+ Sockets? in ([^\n]+)\.\n.+$/$1/s; + $socket_name = $socket; + $socket_name =~ s/^.+?($socket_pid\.\S+).+$/$1/s; if (length($socket_path) != length($socket)) { # only activate, if string length is different # (to make sure, we really got a dir name) |
