#include "pnd_desktop.h"
#include "pnd_logger.h"
#include "pnd_dbusnotify.h"
+#include "pnd_pndfiles.h"
// this piece of code was simpler once; but need to grow it a bit and in a rush
// moving all these to globals rather than refactor the code a bit; tsk tsk..
char *menu_dotdesktoppath = NULL;
char *menu_iconpath = NULL;
char *menu_appspath = NULL;
+char *info_dotdesktoppath = NULL;
// pnd runscript
char *run_searchpath; // searchpath to find pnd_run.sh
char *run_script; // name of pnd_run.sh script from config
// notifier handle
pnd_notify_handle nh = 0;
pnd_dbusnotify_handle dbh = 0;
+unsigned char g_info_p = 0; // spit out info .desktops
// constants
#define PNDNOTIFYD_LOGLEVEL "pndnotifyd.loglevel"
}
} else {
- printf ( "%s [-d] [##]\n", argv [ 0 ] );
+ printf ( "%s [-d] [-l] [##]\n", argv [ 0 ] );
printf ( "-d\tDaemon mode; detach from terminal, chdir to /tmp, suppress output. Optional.\n" );
printf ( "-n\tDo not scan on launch; default is to run a scan for apps when %s is invoked.\n", argv [ 0 ] );
printf ( "-l#\tLog-it; -l is 0-and-up (or all), and -l2 means 2-and-up (not all); l[0-3] for now. Log goes to /tmp/pndnotifyd.log\n" );
// umask
umask ( 022 ); // emitted files can be rwxr-xr-x
-
+
} // set up daemon
// wait for a user to be logged in - we should probably get hupped when a user logs in, so we can handle
pnd_log ( pndn_rem, "Apps searchpath is '%s'\n", menu_appspath );
pnd_log ( pndn_rem, ".desktop files emit to '%s'\n", menu_dotdesktoppath );
pnd_log ( pndn_rem, ".desktop icon files emit to '%s'\n", menu_iconpath );
+ pnd_log ( pndn_rem, ".desktop info files emit to '%s'\n", info_dotdesktoppath ? info_dotdesktoppath : "n/a" );
/* set up signal handler
*/
desktop_dotdesktoppath = pnd_conf_get_as_char ( desktoph, PND_DESKTOP_DOTDESKTOP_PATH_KEY );
desktop_iconpath = pnd_conf_get_as_char ( desktoph, PND_DESKTOP_ICONS_PATH_KEY );
desktop_appspath = pnd_conf_get_as_char ( desktoph, PND_DESKTOP_SEARCH_KEY );
+ info_dotdesktoppath = pnd_conf_get_as_char ( desktoph, "info.dotdesktoppath" );
}
if ( ! desktop_dotdesktoppath ) {
menu_appspath = pnd_conf_get_as_char ( desktoph, PND_MENU_SEARCH_KEY );
}
+ // info
+ if ( desktoph ) {
+ g_info_p = pnd_conf_get_as_int_d ( desktoph, "info.emit_info", 0 );
+ }
+
/* try to locate a runscript and optional hupscript
*/
mkdir ( desktop_dotdesktoppath, 0777 );
mkdir ( desktop_iconpath, 0777 );
+ if ( info_dotdesktoppath ) {
+ info_dotdesktoppath = pnd_expand_tilde ( strdup ( info_dotdesktoppath ) );
+ mkdir ( info_dotdesktoppath, 0777 );
+ }
+
if ( menu_dotdesktoppath ) {
menu_dotdesktoppath = pnd_expand_tilde ( strdup ( menu_dotdesktoppath ) );
mkdir ( menu_dotdesktoppath, 0777 );
// 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", emiticonpath, d -> unique_id );
+ sprintf ( existingpath, "%s/%s.png", emiticonpath, d -> unique_id /*, d -> subapp_number */ );
struct stat dirs;
if ( stat ( existingpath, &dirs ) == 0 ) {
pnd_log ( pndn_debug, " Icon not already present, so trying to write it! %s\n", existingpath );
+ // handle same-path icon override for davec :)
+ char ovrfile [ PATH_MAX ];
+ char *fixpxml;
+ sprintf ( ovrfile, "%s/%s", d -> object_path, d -> object_filename );
+ fixpxml = strcasestr ( ovrfile, PND_PACKAGE_FILEEXT );
+ if ( fixpxml ) {
+ strcpy ( fixpxml, ".png" );
+ fixpxml = NULL;
+ struct stat statbuf;
+ if ( stat ( ovrfile, &statbuf ) == 0 ) {
+ d -> icon = strdup ( ovrfile );
+ fixpxml = ovrfile; // !NULL will be the trigger to skip emittinf desktop from .pnd
+ } // stat
+ } // ovr?
+
// 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 ( emiticonpath, d ) ) {
- // success; fix up icon path to new one..
- if ( d -> icon ) {
- free ( d -> icon );
+ if ( fixpxml == NULL ) {
+ // don't have an same-path override icon, so go fetch something from pnd file
+
+ if ( pnd_emit_icon ( emiticonpath, d ) ) {
+ // success; fix up icon path to new one..
+ if ( d -> icon ) {
+ free ( d -> icon );
+ }
+ d -> icon = strdup ( existingpath );
+ } else {
+ pnd_log ( pndn_debug, " WARN: Couldn't write out icon %s\n", existingpath );
}
- d -> icon = strdup ( existingpath );
- } else {
- pnd_log ( pndn_debug, " WARN: Couldn't write out icon %s\n", existingpath );
- }
+
+ } // got ovr icon already?
} // icon already exists?
pnd_log ( pndn_rem, "ERROR: Error creating .desktop file for app: %s\n", pnd_box_get_key ( d ) );
}
+ // info .desktop
+ if ( g_info_p && info_dotdesktoppath ) {
+ if ( pnd_emit_dotinfo ( info_dotdesktoppath, pndrun, d ) ) {
+ // nada
+ } else {
+ pnd_log ( pndn_rem, "ERROR: Error creating info .desktop file for app: %s\n", pnd_box_get_key ( d ) );
+ }
+ }
+
// does this object request any mkdir's?
if ( d -> mkdir_sp ) {