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 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2004 Michael 'Mickey' Lauer <mickey@vanille.de> | ||
3 | ** All rights reserved. | ||
4 | ** | ||
5 | ** This file may be distributed and/or modified under the terms of the | ||
6 | ** GNU General Public License version 2 as published by the Free Software | ||
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
8 | ** packaging of this file. | ||
9 | ** | ||
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
12 | ** | ||
13 | **********************************************************************/ | ||
14 | |||
15 | /* STD */ | ||
16 | #include <pwd.h> | ||
17 | #include <sys/types.h> | ||
18 | #include <fcntl.h> | ||
19 | #include <unistd.h> | ||
20 | #include <stdio.h> | ||
21 | #include <string.h> | ||
22 | #include <errno.h> | ||
23 | |||
24 | int main( int argc, char** argv ) | ||
25 | { | ||
26 | printf( "\nPyQuicklaunch Launcher (numargs=%d, arg[0]='%s', arg[1]='%s')\n", argc, argv[0], argv[1] ); | ||
27 | |||
28 | char fifoName[1024]; | ||
29 | sprintf( &fifoName[0], "/tmp/mickeys-quicklauncher-%s", ::getpwuid( ::getuid() )->pw_name ); | ||
30 | |||
31 | |||
32 | int fd = open( &fifoName[0], O_WRONLY | O_NONBLOCK ); | ||
33 | if ( fd == -1 ) | ||
34 | { | ||
35 | perror( "Can't open fifo" ); | ||
36 | return -1; | ||
37 | } | ||
38 | |||
39 | char wdPath[1024]; | ||
40 | getcwd( &wdPath[0], sizeof( wdPath ) ); | ||
41 | |||
42 | char scriptPath[1024]; | ||
43 | if ( argv[1][0] == '/' ) | ||
44 | { | ||
45 | strcpy( &scriptPath[0], argv[1] ); | ||
46 | } | ||
47 | else | ||
48 | { | ||
49 | sprintf( &scriptPath[0], "%s/%s", wdPath, argv[1] ); | ||
50 | } | ||
51 | |||
52 | printf( "\nInstructing the Quicklauncher to launch '%s'...", &scriptPath[0] ); | ||
53 | |||
54 | int res = write( fd, scriptPath, strlen( scriptPath ) ); | ||
55 | if ( res < 1 ) | ||
56 | { | ||
57 | perror( "Can't write string to fifo" ); | ||
58 | return -1; | ||
59 | } | ||
60 | |||
61 | close( fd ); | ||
62 | |||
63 | return 0; | ||
64 | } | ||