author | mickeyl <mickeyl> | 2004-06-03 12:02:43 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-06-03 12:02:43 (UTC) |
commit | ad0b84ba1cba85e7dfb0fb12fedfde8d45b068dc (patch) (side-by-side diff) | |
tree | 13abdbcb868717f82e668646a05c788c5f1e61cb /noncore/tools/pyquicklauncher/main.cpp | |
parent | 9499e1d1b46c1b5e0e6f8ce94aea4d8bd67f8f90 (diff) | |
download | opie-ad0b84ba1cba85e7dfb0fb12fedfde8d45b068dc.zip opie-ad0b84ba1cba85e7dfb0fb12fedfde8d45b068dc.tar.gz opie-ad0b84ba1cba85e7dfb0fb12fedfde8d45b068dc.tar.bz2 |
add the python quicklaunch launcher
Diffstat (limited to 'noncore/tools/pyquicklauncher/main.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/tools/pyquicklauncher/main.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/noncore/tools/pyquicklauncher/main.cpp b/noncore/tools/pyquicklauncher/main.cpp new file mode 100644 index 0000000..30fbd0a --- a/dev/null +++ b/noncore/tools/pyquicklauncher/main.cpp @@ -0,0 +1,64 @@ +/********************************************************************** +** Copyright (C) 2004 Michael 'Mickey' Lauer <mickey@vanille.de> +** All rights reserved. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +**********************************************************************/ + +/* STD */ +#include <pwd.h> +#include <sys/types.h> +#include <fcntl.h> +#include <unistd.h> +#include <stdio.h> +#include <string.h> +#include <errno.h> + +int main( int argc, char** argv ) +{ + printf( "\nPyQuicklaunch Launcher (numargs=%d, arg[0]='%s', arg[1]='%s')\n", argc, argv[0], argv[1] ); + + char fifoName[1024]; + sprintf( &fifoName[0], "/tmp/mickeys-quicklauncher-%s", ::getpwuid( ::getuid() )->pw_name ); + + + int fd = open( &fifoName[0], O_WRONLY | O_NONBLOCK ); + if ( fd == -1 ) + { + perror( "Can't open fifo" ); + return -1; + } + + char wdPath[1024]; + getcwd( &wdPath[0], sizeof( wdPath ) ); + + char scriptPath[1024]; + if ( argv[1][0] == '/' ) + { + strcpy( &scriptPath[0], argv[1] ); + } + else + { + sprintf( &scriptPath[0], "%s/%s", wdPath, argv[1] ); + } + + printf( "\nInstructing the Quicklauncher to launch '%s'...", &scriptPath[0] ); + + int res = write( fd, scriptPath, strlen( scriptPath ) ); + if ( res < 1 ) + { + perror( "Can't write string to fifo" ); + return -1; + } + + close( fd ); + + return 0; +} |