Numerous fixes and changes
authorskeezix <skeezix@flotsam-vm.(none)>
Sat, 10 Oct 2009 15:45:38 +0000 (11:45 -0400)
committerskeezix <skeezix@flotsam-vm.(none)>
Sat, 10 Oct 2009 15:45:38 +0000 (11:45 -0400)
- a fix to invokers of the pnd_locate_filename function; you must strdup() the result .. otherwise multiple invocations will
  return the same buffer, and thus all references will change simultaneously
- nohup is only put into Exec= line .desktop if it is also a no-x11 app (most apps should be x11 I imagine, using SDL?)
- Icons for .desktops can be placed anywhere; path is configured .. 'iconpath' key; nolonger assumed to be same location
  as .desktop's go to
- updated config files to include iconpath (test goes to testdata/dotdesktop for now); production goes to /tmp for now
- updated config files so .desktop goes to ~/Desktop for production
- updated config files to comment out pnd_hup script, as xfce appears not to need it. (it may be re-enabled should we switch WMs)

apps/pndnotifyd.c
deployment/etc/pandora/conf/desktop
include/pnd_apps.h
lib/pnd_desktop.c
testdata/conf/desktop

index b1afc4c..70ab5ac 100644 (file)
@@ -44,6 +44,7 @@ char *overridespath;
 // daemon stuff
 char *searchpath = NULL;
 char *dotdesktoppath = NULL;
+char *iconpath = NULL;
 char *notifypath = NULL;
 // pnd runscript
 char *run_searchpath; // searchpath to find pnd_run.sh
@@ -127,6 +128,7 @@ int main ( int argc, char *argv[] ) {
     printf ( "Apps searchpath is '%s'\n", appspath );
     printf ( "PXML overrides searchpath is '%s'\n", overridespath );
     printf ( ".desktop files emit to '%s'\n", dotdesktoppath );
+    printf ( ".desktop icon files emit to '%s'\n", iconpath );
     printf ( "Notify searchpath is '%s'\n", notifypath );
   }
 
@@ -191,7 +193,7 @@ int main ( int argc, char *argv[] ) {
          // check if icon already exists (from a previous extraction say); if so, we needn't
          // do it again
          char existingpath [ FILENAME_MAX ];
-         sprintf ( existingpath, "%s/%s.png", dotdesktoppath, d -> unique_id );
+         sprintf ( existingpath, "%s/%s.png", iconpath, d -> unique_id );
 
          struct stat dirs;
          if ( stat ( existingpath, &dirs ) == 0 ) {
@@ -215,12 +217,16 @@ int main ( int argc, char *argv[] ) {
 
            // attempt to create icon files; if successful, alter the disco struct to contain new
            // path, otherwise leave it alone (since it could be a generic icon reference..)
-           if ( pnd_emit_icon ( dotdesktoppath, d ) ) {
+           if ( pnd_emit_icon ( iconpath, d ) ) {
              // success; fix up icon path to new one..
              if ( d -> icon ) {
                free ( d -> icon );
              }
              d -> icon = strdup ( existingpath );
+           } else {
+             if ( ! g_daemon_mode ) {
+               printf ( "  WARN: Couldn't write out icon %s\n", existingpath );
+             }
            }
 
          } // icon already exists?
@@ -415,8 +421,14 @@ void consume_configuration ( void ) {
       dotdesktoppath = PND_DOTDESKTOP_DEFAULT;
     }
 
+    iconpath = pnd_conf_get_as_char ( desktoph, PND_DOTDESKTOPICONS_KEY );
+
+    if ( ! iconpath ) {
+      iconpath = PND_DOTDESKTOPICONS_DEFAULT;
+    }
+
   } else {
-    dotdesktoppath = PND_DOTDESKTOP_DEFAULT;
+    dotdesktoppath = PND_DOTDESKTOPICONS_DEFAULT;
   }
 
   // try to locate a runscript and optional hupscript
@@ -440,7 +452,9 @@ void consume_configuration ( void ) {
   if ( ! pndrun ) {
     pndrun = pnd_locate_filename ( run_searchpath, run_script );
 
-    if ( ! pndrun ) {
+    if ( pndrun ) {
+      pndrun = strdup ( pndrun ); // so we don't just use the built in buffer; next locate will overwrite it
+    } else {
       pndrun = PND_PNDRUN_DEFAULT;
     }
 
@@ -451,6 +465,11 @@ void consume_configuration ( void ) {
 
     if ( ( t = pnd_conf_get_as_char ( desktoph, PND_PNDHUP_KEY ) ) ) {
       pndhup = pnd_locate_filename ( run_searchpath, t );
+
+      if ( pndhup ) {
+       pndhup = strdup ( pndhup ); // so we don't just use the built in buffer; next locate will overwrite it
+      }
+
 #if 0 // don't enable this; if no key in config, we don't want to bother hupping
     } else {
       pndhup = pnd_locate_filename ( run_searchpath, PND_PNDHUP_FILENAME );
@@ -474,10 +493,12 @@ void consume_configuration ( void ) {
   /* handle globbing or variable substitution
    */
   dotdesktoppath = pnd_expand_tilde ( strdup ( dotdesktoppath ) );
+  iconpath = pnd_expand_tilde ( strdup ( iconpath ) );
 
   /* validate paths
    */
   mkdir ( dotdesktoppath, 0777 );
+  mkdir ( iconpath, 0777 );
 
   // done
   return;
index a1f6d04..b45fccf 100644 (file)
@@ -3,8 +3,12 @@
 # Desktop configuration
 
 [dotfiles]
-dotdesktoppath /usr/share/applications/        # path for pndnotifyd to spit .desktop files into (run as root)
-#dotdesktoppath        ~/.applications/        # path for pndnotifyd to spit .desktop files into (run as a user)
+#(~/Desktop for xfce, /usr/share/applications for WMs that actually follow spec)
+dotdesktoppath ~/Desktop/      # path for pndnotifyd to spit .desktop files into (run as root)
+iconpath       /tmp    # path for pndnotifyd to drop icons into (can be same as .desktop if WM permits)
 
 [launcher]
-hupscript      pnd_hup.sh
+# if hupscript is commented out entirely, pndnotifyd will not try to find/run the hup
+# if it is uncommented, pndnotifyd will attempt to invoke the hupscript after emitting .desktop files
+# (the hupscript exists to hup the WMs to redisplay .desktop apps)
+#hupscript     pnd_hup.sh
index 13dc07a..719622a 100644 (file)
@@ -26,7 +26,9 @@ extern "C" {
 
 // .desktop support
 #define PND_DOTDESKTOP_KEY "dotfiles.dotdesktoppath"
+#define PND_DOTDESKTOPICONS_KEY "dotfiles.iconpath"
 #define PND_DOTDESKTOP_DEFAULT "~/.applications"
+#define PND_DOTDESKTOPICONS_DEFAULT "~/.applications"
 
 // apps
 #define PND_DEFAULT_WORKDIR "./"
index b5b9a40..3bb3066 100644 (file)
@@ -84,14 +84,21 @@ unsigned char pnd_emit_dotdesktop ( char *targetpath, char *pndrun, pnd_disco_t
 #endif
 
   if ( p -> exec ) {
+    char *nohup;
+
+    if ( p -> option_no_x11 ) {
+      nohup = "/usr/bin/nohup ";
+    } else {
+      nohup = "";
+    }
 
     // basics
     if ( p -> object_type == pnd_object_type_directory ) {
-      snprintf ( buffer, 1020, "Exec=/usr/bin/nohup %s -p %s -e %s -b %s",
-                pndrun, p -> object_path, p -> exec, p -> unique_id );
+      snprintf ( buffer, 1020, "Exec=%s%s -p %s -e %s -b %s",
+                nohup, pndrun, p -> object_path, p -> exec, p -> unique_id );
     } else if ( p -> object_type == pnd_object_type_pnd ) {
-      snprintf ( buffer, 1020, "Exec=/usr/bin/nohup %s -p %s/%s -e %s -b %s",
-                pndrun, p -> object_path, p -> object_filename, p -> exec, p -> unique_id );
+      snprintf ( buffer, 1020, "Exec=%s%s -p %s/%s -e %s -b %s",
+                nohup, pndrun, p -> object_path, p -> object_filename, p -> exec, p -> unique_id );
     }
 
     // start dir
index befc4e1..4b1e994 100644 (file)
@@ -5,6 +5,7 @@
 [dotfiles]
 #dotdesktoppath        ./testdata/dotdesktop   # path for pndnotifyd to spit .desktop files into
 dotdesktoppath ~/.applications         # path for pndnotifyd to spit .desktop files into
+iconpath       ./testdata/dotdesktop   # path for pndnotifyd to drop icons into (can be same as .desktop if WM permits)
 
 [launcher]
 hupscript      pnd_hup.sh