Some fixes for startdir in .desktop
authorskeezix <skeezix@flotsam-vm.(none)>
Tue, 24 Feb 2009 05:15:52 +0000 (00:15 -0500)
committerskeezix <skeezix@flotsam-vm.(none)>
Tue, 24 Feb 2009 05:15:52 +0000 (00:15 -0500)
include/pnd_apps.h
lib/pnd_discovery.c
testdata/pndsample/x86_echo.pnd
testdata/pndsample/x86_ls.pnd

index ff2bb06..10f07a4 100644 (file)
@@ -24,7 +24,7 @@ extern "C" {
 #define PND_DOTDESKTOP_DEFAULT "/usr/share/applications"
 
 // apps
-#define PND_DEFAULT_WORKDIR "/tmp"
+#define PND_DEFAULT_WORKDIR "./"
 
 /* pnd_apps_exec() is used to blindly launch an app, be it a .pnd file bundle or a plain executable
  * (shell, bin, whatever.) pndrun specifies the full path to the pnd_run sh script, which should be
index cb09703..1822c0f 100644 (file)
@@ -290,7 +290,7 @@ unsigned char pnd_emit_dotdesktop ( char *targetpath, char *pndrun, pnd_disco_t
   }
 #endif
 
-#if 0
+#if 0 // we let pnd_run.sh handle this
   if ( p -> startdir ) {
     snprintf ( buffer, 1020, "Path=%s\n", p -> startdir );
     fprintf ( f, "%s", buffer );
@@ -300,11 +300,24 @@ unsigned char pnd_emit_dotdesktop ( char *targetpath, char *pndrun, pnd_disco_t
 #endif
 
   if ( p -> exec ) {
+
+    // basics
     if ( p -> object_type == pnd_object_type_directory ) {
-      snprintf ( buffer, 1020, "Exec=%s -p %s -e %s -u\n", pndrun, p -> object_path, p -> exec );
+      snprintf ( buffer, 1020, "Exec=%s -p %s -e %s -u", pndrun, p -> object_path, p -> exec );
     } else if ( p -> object_type == pnd_object_type_pnd ) {
-      snprintf ( buffer, 1020, "Exec=%s -p %s/%s -e %s -u\n", pndrun, p -> object_path, p -> object_filename, p -> exec );
+      snprintf ( buffer, 1020, "Exec=%s -p %s/%s -e %s -u", pndrun, p -> object_path, p -> object_filename, p -> exec );
+    }
+
+    // start dir
+    if ( p -> startdir ) {
+      strncat ( buffer, " -s ", 1020 );
+      strncat ( buffer, p -> startdir, 1020 );
     }
+
+    // newline
+    strncat ( buffer, "\n", 1020 );
+
+    // emit
     fprintf ( f, "%s", buffer );
   }
 
index 5437373..b645c49 100644 (file)
Binary files a/testdata/pndsample/x86_echo.pnd and b/testdata/pndsample/x86_echo.pnd differ
index 994b6b0..6e308e0 100644 (file)
Binary files a/testdata/pndsample/x86_ls.pnd and b/testdata/pndsample/x86_ls.pnd differ