diff options
Diffstat (limited to 'abs/mv-core/ghosd')
-rwxr-xr-x | abs/mv-core/ghosd/PKGBUILD | 33 | ||||
-rw-r--r-- | abs/mv-core/ghosd/blue800.png | bin | 0 -> 2609 bytes | |||
-rwxr-xr-x | abs/mv-core/ghosd/gh800.png | bin | 0 -> 2559 bytes | |||
-rw-r--r-- | abs/mv-core/ghosd/green-800.png | bin | 0 -> 2448 bytes | |||
-rw-r--r-- | abs/mv-core/ghosd/green800.png | bin | 0 -> 2559 bytes | |||
-rw-r--r-- | abs/mv-core/ghosd/grey800.png | bin | 0 -> 870 bytes | |||
-rw-r--r-- | abs/mv-core/ghosd/image.c | 97 | ||||
-rwxr-xr-x | abs/mv-core/ghosd/osdClient.pl | 25 | ||||
-rw-r--r-- | abs/mv-core/ghosd/osdServer.config | 6 | ||||
-rwxr-xr-x | abs/mv-core/ghosd/osdServer.pl | 189 | ||||
-rw-r--r-- | abs/mv-core/ghosd/red800.png | bin | 0 -> 2546 bytes | |||
-rw-r--r-- | abs/mv-core/ghosd/yellow800.png | bin | 0 -> 2559 bytes |
12 files changed, 350 insertions, 0 deletions
diff --git a/abs/mv-core/ghosd/PKGBUILD b/abs/mv-core/ghosd/PKGBUILD new file mode 100755 index 0000000..e954ef9 --- /dev/null +++ b/abs/mv-core/ghosd/PKGBUILD @@ -0,0 +1,33 @@ +pkgname=ghosd +pkgver=0.0.1 +pkgrel=18 +pkgdesc="notification program like xosd" +depends=('cairo' 'perl' 'pango') +makedepends=('pkgconfig') +arch=('i686') +source=(osdClient.pl osdServer.config osdServer.pl green800.png red800.png blue800.png yellow800.png 'grey800.png') + + +build() { + cd $startdir/src + cp -rp $startdir/$pkgname-$pkgver . + cd $startdir/src/$pkgname-$pkgver + make distclean + make clean + ./configure --prefix=/usr --disable-shared + make || return 1 + make prefix=$startdir/pkg/usr install + #install -D -m755 ./examples/.libs/image $startdir/pkg/usr/bin/imageGhosd + install -D -m755 ./examples/image $startdir/pkg/usr/bin/imageGhosd + + cd $startdir/src + install -D -m755 osdClient.pl $startdir/pkg/usr/bin/osdClient.pl + install -D -m755 osdServer.pl $startdir/pkg/usr/bin/osdServer.pl + install -D -m755 osdServer.config $startdir/pkg/etc/osdServer.config + install -D -m755 green800.png $startdir/pkg/usr/share/green800.png + install -D -m755 red800.png $startdir/pkg/usr/share/red800.png + install -D -m755 blue800.png $startdir/pkg/usr/share/blue800.png + install -D -m755 yellow800.png $startdir/pkg/usr/share/yellow800.png + install -D -m755 grey800.png $startdir/pkg/usr/share/grey800.png +} + diff --git a/abs/mv-core/ghosd/blue800.png b/abs/mv-core/ghosd/blue800.png Binary files differnew file mode 100644 index 0000000..7b1b914 --- /dev/null +++ b/abs/mv-core/ghosd/blue800.png diff --git a/abs/mv-core/ghosd/gh800.png b/abs/mv-core/ghosd/gh800.png Binary files differnew file mode 100755 index 0000000..b0750d0 --- /dev/null +++ b/abs/mv-core/ghosd/gh800.png diff --git a/abs/mv-core/ghosd/green-800.png b/abs/mv-core/ghosd/green-800.png Binary files differnew file mode 100644 index 0000000..b1cd057 --- /dev/null +++ b/abs/mv-core/ghosd/green-800.png diff --git a/abs/mv-core/ghosd/green800.png b/abs/mv-core/ghosd/green800.png Binary files differnew file mode 100644 index 0000000..b0750d0 --- /dev/null +++ b/abs/mv-core/ghosd/green800.png diff --git a/abs/mv-core/ghosd/grey800.png b/abs/mv-core/ghosd/grey800.png Binary files differnew file mode 100644 index 0000000..141c203 --- /dev/null +++ b/abs/mv-core/ghosd/grey800.png diff --git a/abs/mv-core/ghosd/image.c b/abs/mv-core/ghosd/image.c new file mode 100644 index 0000000..cd5dadd --- /dev/null +++ b/abs/mv-core/ghosd/image.c @@ -0,0 +1,97 @@ +/* ghosd -- OSD with fake transparency, cairo, and pango. + * Copyright (C) 2006 Evan Martin <martine@danga.com> + */ + +#include <stdio.h> +#include <math.h> +#include <cairo/cairo.h> +#include <unistd.h> +#include <ghosd/ghosd.h> + +#include "example-shared.h" + +#define MARGIN 10 +#define RADIUS 20 +#define WIDTH 185 +#define HEIGHT 220 +char displayText[200] = "default message"; + +static void +render(Ghosd *ghosd, cairo_t *cr, void* data) { + cairo_surface_t* image = data; + const int width = cairo_image_surface_get_width(image); + const int height = cairo_image_surface_get_height(image); + + cairo_set_source_rgba(cr, 0, 0, 0, 0.5); + cairo_new_path(cr); + example_round_rect(cr, 0, 0, width+(2*MARGIN), height+(2*MARGIN), RADIUS); + cairo_fill(cr); + + cairo_save(cr); + cairo_set_source_surface(cr, image, MARGIN, MARGIN); + + + + + cairo_paint_with_alpha(cr, 0.9); + cairo_restore(cr); +cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL, + CAIRO_FONT_WEIGHT_BOLD); +cairo_set_font_size (cr, 90.0); + +// cairo_move_to (cr, 10.0, 135.0); +// cairo_show_text (cr, "Hello"); + +cairo_move_to (cr, 70.0, 165.0); +cairo_text_path (cr, displayText); +cairo_set_source_rgb (cr, 1.5, 1.5, 1); +cairo_fill_preserve (cr); +cairo_set_source_rgb (cr, 0, 0, 0); +cairo_set_line_width (cr, 2.56); +cairo_stroke (cr); +} + +int main(int argc, char* argv[]) { + //g_type_init(); + + char *filename = NULL; + GOptionEntry options[] = { + { "image", 'i', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING, + (gpointer)&filename, "image to display", "PATH" }, + { NULL } + }; + GOptionGroup *group = g_option_group_new("image", "Image Options", "image help", + NULL, NULL); + g_option_group_add_entries(group, options); + example_options_parse(&argc, &argv, group, NULL); + + if (filename == NULL) { + printf("must specify image with -i flag.\n" + "try e.g. /usr/share/pixmaps/gnome-logo-large.png\n"); + return 1; + } + + if( argc == 2 ) + { + sprintf(displayText, argv[1]); + + } + + + Ghosd *ghosd; + cairo_surface_t* image = cairo_image_surface_create_from_png(filename); + const int width = cairo_image_surface_get_width(image); + const int height = cairo_image_surface_get_height(image); + + ghosd = ghosd_new(); + ghosd_set_transparent(ghosd, opts.transparent); + ghosd_set_position(ghosd, opts.x, opts.y, + width+(2*MARGIN), height+(2*MARGIN)); + ghosd_set_render(ghosd, render, image); + + ghosd_flash(ghosd, 1300, 6500); + + return 0; +} + +/* vim: set ts=2 sw=2 et cino=(0 : */ diff --git a/abs/mv-core/ghosd/osdClient.pl b/abs/mv-core/ghosd/osdClient.pl new file mode 100755 index 0000000..06fc381 --- /dev/null +++ b/abs/mv-core/ghosd/osdClient.pl @@ -0,0 +1,25 @@ +#!/usr/bin/perl -w +# osdClient.pl - send simple client text to server + +use strict; +use IO::Socket::INET; +use POSIX qw(F_GETFL F_SETFL O_NONBLOCK); +my $sock = ""; + +if( $#ARGV != 2 ){ die "specify a ip, port, text string" } + +eval +{ + $sock = IO::Socket::INET->new( + PeerAddr => $ARGV[0], + PeerPort => $ARGV[1]) || die "can't set it up $!"; + + $sock->blocking(0) +}; + +if( $@ =~ /socket/i ) +{ + print "die in record retrieval socket setup with $@"; +} + +print $sock "$ARGV[2] \n"; diff --git a/abs/mv-core/ghosd/osdServer.config b/abs/mv-core/ghosd/osdServer.config new file mode 100644 index 0000000..915cef9 --- /dev/null +++ b/abs/mv-core/ghosd/osdServer.config @@ -0,0 +1,6 @@ +image _#_ ALT _#_ /usr/share/red800.png -x -0 -y -450 75 90 1 1 1 50 900 6000 +image _#_ SYS _#_ /usr/share/blue800.png -x -0 -y -450 75 90 1 1 1 50 900 6000 +image _#_ PHN _#_ /usr/share/yellow800.png -x -0 -y -450 75 90 1 1 1 50 900 6000 +image _#_ PH2 _#_ /usr/share/yellow800.png -x -0 -y 450 75 90 1 1 1 50 900 6000 +image _#_ OTH _#_ /usr/share/grey800.png -x -0 -y -450 75 90 1 1 1 50 900 6000 +image _#_ NFO _#_ /usr/share/green800.png -x -0 -y -450 75 90 1 1 1 50 900 6000 diff --git a/abs/mv-core/ghosd/osdServer.pl b/abs/mv-core/ghosd/osdServer.pl new file mode 100755 index 0000000..8cd62b7 --- /dev/null +++ b/abs/mv-core/ghosd/osdServer.pl @@ -0,0 +1,189 @@ +#!/usr/bin/perl -w +# osdServer.pl - process incoming text events based on keyword matching and +# display using Ghosd +use strict; +use FileHandle; +use Socket; +use Thread; +use Config; +use Thread qw(async); + +if( @ARGV != 1 ){ die "specify a port to listen on " } +my %osdHash = (); +my $proto = ""; +my $port = ""; +my $port1 = ""; +my $sockAddr = ""; +my $sockAddr1= ""; +my $fullCmd = ""; +my $fullCmd1 = ""; + +# readKeyWordFile reads type, keywords, (text/image) parameters +# text parameters: +# X coordinate, Y coordinate, red, green, blue, font size, fade In, fade Out +# image parameters: +# image filename, X coordinate, Y coordinate +# osdServer.confg format is: type _#_ keywords _#_ osd parameters +sub readOsdFile +{ + open(OSDFILE,"/etc/osdServer.config") or die "no osdServer.config file: $!"; + + while(<OSDFILE>){ + + # ignore comment lines + if( !/^#/ ){ + chomp($_); + my @arrLine = split "_#_"; + $arrLine[0] =~ s/ //g; + $osdHash{ lc($arrLine[0]) }{ $arrLine[1] } = $arrLine[2]; + }#if not a comment line + + }#for each line in file + + close(OSDFILE); + +}#readOsdFile + +sub matchWords +{ + my $msgString = $_[0]; + my $type = $_[1]; +# print "msgstring $msgString \n"; + + # print "type $type\n " ; + # for the type specified + for my $kwList ( keys %{ $osdHash{$type} } ) + { + # for each word + for my $checkWord ( split " ", $kwList ) + { + $checkWord =~ s/ //g; + if( $msgString =~ /$checkWord/i ) + { + if( $type eq "text" ) + { + $fullCmd .= qq{./text '$msgString' $osdHash{text}{$kwList} &}; + + #print "$fullCmd\n"; + }else + { + my @realstring = split(/:::/, $msgString); + print "$realstring[0] \n"; + $fullCmd .= qq{/usr/bin/imageGhosd -i $osdHash{image}{$kwList} '$realstring[0]' &}; +# print "full $fullCmd\n"; + #print "msgstring- $msgString \n"; + } + }#if matching word + }#for each check word + }#for each key word list + +}#checkText + +sub matchWords1 +{ + my $msgString = $_[0]; + my $type = $_[1]; +# print "msgstring $msgString \n"; + print "Here ia m" ; + # print "type $type\n " ; + # for the type specified + for my $kwList ( keys %{ $osdHash{$type} } ) + { + # for each word + for my $checkWord ( split " ", $kwList ) + { + $checkWord =~ s/ //g; + if( $msgString =~ /$checkWord/i ) + { + if( $type eq "text" ) + { + $fullCmd1 .= qq{./text '$msgString' $osdHash{text}{$kwList} &}; + + #print "$fullCmd\n"; + }else + { + my @realstring = split(/:::/, $msgString); + print "$realstring[0] \n"; + $fullCmd1 .= qq{/usr/bin/imageGhosd -i $osdHash{image}{$kwList} '$realstring[0]' &}; + print "full $fullCmd1\n"; + #print "msgstring- $msgString \n"; + } + }#if matching word + }#for each check word + }#for each key word list +} + +sub sub1 { + while( 1 ) + { + my $acceptSock1 = accept(HANDLER, SERVER1) or die "accept: $!\n"; + my($acceptPort1, $acceptIpAddr) = sockaddr_in($acceptSock1); + + autoflush HANDLER 1; + while(my $msgString1 = <HANDLER>) + { + chomp($msgString1); + matchWords1($msgString1,"text"); + matchWords1($msgString1,"image"); + + $fullCmd1 = `$fullCmd1` unless $fullCmd1 eq ""; + $fullCmd1 = ""; + }#while handler + + close HANDLER or die "close HANDLER: $!\n"; + }#while forever +} + +# begin main program + +readOsdFile(); + +$proto = getprotobyname('tcp'); +socket(SERVER, PF_INET, SOCK_STREAM, $proto) or die "socket: $!\n"; +socket(SERVER1, PF_INET, SOCK_STREAM, $proto) or die "socket: $!\n"; + +$port = $ARGV[0]; +$port1 = $port + 1; +$port1 = 5001; + +$sockAddr = sockaddr_in($port, INADDR_ANY); +$sockAddr1 = sockaddr_in($port1, INADDR_ANY); + +bind(SERVER, $sockAddr) or die "bind: $!\n"; +bind(SERVER1, $sockAddr1) or die "bind: $!\n"; + +listen(SERVER, SOMAXCONN) or die "listen: $!\n"; +listen(SERVER1, SOMAXCONN) or die "listen: $!\n"; + + + +$Config{usethreads} or die "Recompile Perl with threads to run this program."; + +my $thr = threads->new(\&sub1); + + + + +#listen foreve + +while( 1 ) +{ + my $acceptSock = accept(HANDLER, SERVER) or die "accept: $!\n"; + my($acceptPort, $acceptIpAddr) = sockaddr_in($acceptSock); + + autoflush HANDLER 1; + while(my $msgString = <HANDLER>) + { + chomp($msgString); + + matchWords($msgString,"text"); + matchWords($msgString,"image"); + + $fullCmd = `$fullCmd` unless $fullCmd eq ""; + $fullCmd = ""; + }#while handler + + close HANDLER or die "close HANDLER: $!\n"; + +}#while forever + diff --git a/abs/mv-core/ghosd/red800.png b/abs/mv-core/ghosd/red800.png Binary files differnew file mode 100644 index 0000000..7c7ae5c --- /dev/null +++ b/abs/mv-core/ghosd/red800.png diff --git a/abs/mv-core/ghosd/yellow800.png b/abs/mv-core/ghosd/yellow800.png Binary files differnew file mode 100644 index 0000000..f6bfae1 --- /dev/null +++ b/abs/mv-core/ghosd/yellow800.png |