00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include <pwd.h>
00017 #include <sys/types.h>
00018 #include <fcntl.h>
00019 #include <unistd.h>
00020 #include <stdio.h>
00021 #include <string.h>
00022 #include <errno.h>
00023
00024 int main( int argc, char** argv )
00025 {
00026 printf( "\nPyQuicklaunch Launcher (numargs=%d, arg[0]='%s', arg[1]='%s')\n", argc, argv[0], argv[1] );
00027
00028 char fifoName[1024];
00029 sprintf( &fifoName[0], "/tmp/mickeys-quicklauncher-%s", ::getpwuid( ::getuid() )->pw_name );
00030
00031
00032 int fd = open( &fifoName[0], O_WRONLY | O_NONBLOCK );
00033 if ( fd == -1 )
00034 {
00035 perror( "Can't open fifo" );
00036 return -1;
00037 }
00038
00039 char wdPath[1024];
00040 getcwd( &wdPath[0], sizeof( wdPath ) );
00041
00042 char scriptPath[1024];
00043 if ( argv[1][0] == '/' )
00044 {
00045 strcpy( &scriptPath[0], argv[1] );
00046 }
00047 else
00048 {
00049 sprintf( &scriptPath[0], "%s/%s", wdPath, argv[1] );
00050 }
00051
00052 printf( "\nInstructing the Quicklauncher to launch '%s'...", &scriptPath[0] );
00053
00054 int res = write( fd, scriptPath, strlen( scriptPath ) );
00055 if ( res < 1 )
00056 {
00057 perror( "Can't write string to fifo" );
00058 return -1;
00059 }
00060
00061 close( fd );
00062
00063 return 0;
00064 }