~ubuntu-branches/debian/wheezy/byobu/wheezy

« back to all changes in this revision

Viewing changes to usr/lib/byobu/include/notify_osd

  • Committer: Package Import Robot
  • Author(s): Alexander Chernyakhovsky
  • Date: 2012-01-11 19:37:34 UTC
  • mfrom: (0.5.3) (0.1.162 precise)
  • Revision ID: package-import@ubuntu.com-20120111193734-89083z97py39gj05
Tags: 5.2-1
* Syncing from Ubuntu. Remaining changes:
  - Switch to dh short syntax
  - Added a substvar ${perl:Depends} dependency into debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
#
 
3
#    notify_osd: perform some string manipulation on notify-osd messages
 
4
#                 and then send to the screen message window
 
5
#    Copyright (C) 2010 Canonical Ltd.
 
6
#
 
7
#    Authors: Dustin Kirkland <kirkland@ubuntu.com>
 
8
#             with help from Mathias Gug <mathias.gug@canonical.com>
 
9
#
 
10
#    This program is free software: you can redistribute it and/or modify
 
11
#    it under the terms of the GNU General Public License as published by
 
12
#    the Free Software Foundation, version 3 of the License.
 
13
#
 
14
#    This program is distributed in the hope that it will be useful,
 
15
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
#    GNU General Public License for more details.
 
18
#
 
19
#    You should have received a copy of the GNU General Public License
 
20
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
21
 
 
22
$/ = "\n\n";
 
23
$PKG = "byobu";
 
24
$sleep = 5;
 
25
while (<STDIN>) {
 
26
        # Ensure that the notify_osd indicator is enabled
 
27
        my $skip = 0;
 
28
        open(F, "<$ENV{BYOBU_CONFIG_DIR}/status");
 
29
        foreach my $i (<F>) {
 
30
                if ($i =~ /notify_osd=0/) {
 
31
                        $skip = 1;
 
32
                }
 
33
        }
 
34
        close(F);
 
35
        if ($skip == 1) {
 
36
                next;
 
37
        }
 
38
        $msg = $_;
 
39
        $msg =~ s/\[[^,]*, //;          # strip the leading "[timestamp, "
 
40
        $msg =~ s/\] /: /;              # replace the " ] " following the indicator name, with ":"
 
41
        $msg =~ s/\s+/ /g;              # collapse multi-whitespace into one
 
42
        $msg =~ s/\s+$//g;              # strip trailing whitespace
 
43
        $msg =~ s/^\s+//g;              # strip leading whitespace
 
44
        system("/usr/bin/screen", "-X", "-S", "$ARGV[0]", "at", "*", "msgwait", "$sleep");
 
45
        system("/usr/bin/screen", "-X", "-S", "$ARGV[0]", "at", "*", "echo", "[$msg]");
 
46
        sleep($sleep);
 
47
        system("/usr/bin/screen", "-X", "-S", "$ARGV[0]", "at", "*", "msgwait", "0");
 
48
}