pndnotifyd is almost ready to spit out .desktops after changes in app searchpath!
pnd_notify_handle nh;
char *configpath;
char *appspath;
- char *searchpath;
+ char *searchpath = NULL;
+ char *dotdesktoppath = NULL;
int i;
unsigned int interval_secs = 60;
appspath = PND_APPS_SEARCHPATH;
}
+ // attempt to figure out where to drop dotfiles
+ pnd_conf_handle desktoph;
+
+ desktoph = pnd_conf_fetch_by_id ( pnd_conf_desktop, configpath );
+
+ if ( desktoph ) {
+ dotdesktoppath = pnd_conf_get_as_char ( desktoph, PND_DOTDESKTOP_KEY );
+
+ if ( ! dotdesktoppath ) {
+ dotdesktoppath = PND_DOTDESKTOP_DEFAULT;
+ }
+
+ } else {
+ dotdesktoppath = PND_DOTDESKTOP_DEFAULT;
+ }
+
+ /* startup
+ */
+
if ( ! g_daemon_mode ) {
printf ( "Apps searchpath is '%s'\n", appspath );
+ printf ( ".desktop files emit to '%s'\n", dotdesktoppath );
}
/* set up notifies
// has occurred; we should be clever, but we're not, so just re-brute force the
// discovery and spit out .desktop files..
if ( ! g_daemon_mode ) {
- printf ( "Time to re-discover!\n" );
+ printf ( "Changes within watched paths .. performing re-discover!\n" );
+ printf ( "Path to emit .desktop files to: '%s'\n", dotdesktoppath );
}
// lets not eat up all the CPU
#define PND_MOUNT_PATH "/mnt/apps/" /* all mounted PND images should be here.. /mnt/apps/myapp/... */
+// .desktop support
+#define PND_DOTDESKTOP_KEY "dotfiles.dotdesktoppath"
+#define PND_DOTDESKTOP_DEFAULT "/usr/share/applications"
+
+// apps
+#define PND_DEFAULT_WORKDIR "/tmp"
+
/* 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
* found using searchpaths and locates.. see locatetest.c for a sample
pnd_conf_conf, // provides settings for the config system
pnd_conf_apps, // provides application search-path, pxml override location, etc.
pnd_conf_startup, // provides list of startup applications, basic shell application, etc.
+ pnd_conf_desktop, // provides settings for the launchers
} pnd_conf_filename_e;
typedef struct {
* confusion.. it is not displayed. So no big deal.
*/
-typedef struct\r
+// another struct? Have always intended discovery_t to have minimal members.. just enough to lead to an
+// application (PXML, xecutable, name); if the apps want more details, they can use the pnd_pxml code to
+// fetch the full PXML and get all the details. But I think we got out of control here :)
+typedef struct
{
char *title_en;
char *title_de;
char *clockspeed;
char *background;
char *startdir;
-\r
+
} pnd_disco_t;
void pnd_disco_destroy ( pnd_disco_t *p ); // a function name that simply could not be avoided
+// emit_dotdesktop() will determine a filename and create a FILENAME.desktop file in the targetpath
+// TODO: Copy the icon into this directory as well, if its source is a .pnd or info is in the dico struct
+unsigned char pnd_emit_dotdesktop ( char *targetpath, pnd_disco_t *p );
+
+// TODO: A way to release the disco-lists and reclaim RAM :)
+// TODO: A way to determine the list of excess .desktop files and remove them (ie: after poo.pnd is removed, ditch the .desktop)
+
#ifdef __cplusplus
} /* "C" */
#endif
*/
unsigned char pnd_is_pxml_valid_app ( pnd_pxml_handle h ); // returns 1 when pxml seems like a valid application
-typedef struct\r
+typedef struct
{
char *title_en;
char *title_de;
char *clockspeed;
char *background;
char *startdir;
-\r
+
} pnd_pxml_t;
#ifdef __cplusplus
{ pnd_conf_conf, PND_CONF_FILE },
{ pnd_conf_apps, "apps" },
{ pnd_conf_startup, "startup" },
+ { pnd_conf_desktop, "desktop" },
{ pnd_conf_nil, NULL },
};
return ( NULL ); // must be getting bloody tight!
}
+ memset ( n, '\0', sizeof(pnd_box_node_t) + size );
+
if ( key ) {
n -> key = strdup ( key );
} else {
#include "pnd_pxml.h"
#include "pnd_discovery.h"
#include "pnd_pathiter.h"
+#include "pnd_apps.h"
#warning "PND/PNZ support is not included yet; scripts need writing"
#warning " /usr/pandora/bin/pnd_valid.sh"
return ( disco_box );
}
+
+unsigned char pnd_emit_dotdesktop ( char *targetpath, pnd_disco_t *p ) {
+ char filename [ FILENAME_MAX ];
+ char buffer [ 1024 ];
+ FILE *f;
+
+ // specification
+ // http://standards.freedesktop.org/desktop-entry-spec
+
+ // validation
+
+ if ( ! p -> unique_id ) {
+ return ( 0 );
+ }
+
+ if ( ! p -> exec ) {
+ return ( 0 );
+ }
+
+ // set up
+
+ sprintf ( filename, "%s/%s.desktop", targetpath, p -> unique_id );
+
+ // emit
+
+ f = fopen ( filename, "w" );
+
+ if ( ! f ) {
+ return ( 0 );
+ }
+
+ if ( p -> title_en ) {
+ snprintf ( buffer, 1020, "Name=%s\n", p -> title_en );
+ fprintf ( f, "%s", buffer );
+ }
+
+ fprintf ( f, "Type=Application\n" );
+ fprintf ( f, "Version=1.0\n" );
+
+ if ( p -> icon ) {
+ snprintf ( buffer, 1020, "Icon=%s\n", p -> icon );
+ fprintf ( f, "%s", buffer );
+ }
+
+ if ( p -> description_en ) {
+ snprintf ( buffer, 1020, "Comment=%s\n", p -> description_en );
+ fprintf ( f, "%s", buffer );
+ }
+
+ if ( p -> startdir ) {
+ snprintf ( buffer, 1020, "Path=%s\n", p -> startdir );
+ fprintf ( f, "%s", buffer );
+ } else {
+ fprintf ( f, "Path=%s\n", PND_DEFAULT_WORKDIR );
+ }
+
+ if ( p -> exec ) {
+ snprintf ( buffer, 1020, "Exec=%s\n", p -> exec );
+ fprintf ( f, "%s", buffer );
+ }
+
+ fclose ( f );
+
+ return ( 1 );
+}
printf ( " Clockspeed: %s\n", d -> clockspeed );
}
+ pnd_emit_dotdesktop ( "/tmp", d );
+
// next!
d = pnd_box_get_next ( d );
[autodiscovery]
searchpath /mnt/sd1/pandora/apps:/mnt/sd2/pandora/apps:./testdata/apps # path to depth-search for PXMLs
+# PXMLs may be overridden .. ie: overrides are a subset of PXML, where the values are copied over the full PXML
[overrides]
searchpath ~/pxml-overrides:./testdata/apps-override
+# [pnd] defines where to locate the pnd support scripts, so the user may override pnd_run.sh without clobbering built in
[pnd]
searchpath /mnt/sd1/pandora/scripts:/mnt/sd2/pandora/scripts:./testdata/scripts
default pndrun.sh
--- /dev/null
+
+# Open Pandora
+# Desktop configuration
+
+[dotfiles]
+dotdesktoppath ./testdata/dotdesktop # path for pndnotifyd to spit .desktop files into