From: skeezix Date: Sat, 10 Oct 2009 15:45:38 +0000 (-0400) Subject: Numerous fixes and changes X-Git-Tag: Release-2010-05/1~167 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=34cfb7a0f610339aa22aeee522325123cf821796;p=pandora-libraries.git Numerous fixes and changes - 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) --- diff --git a/apps/pndnotifyd.c b/apps/pndnotifyd.c index b1afc4c..70ab5ac 100644 --- a/apps/pndnotifyd.c +++ b/apps/pndnotifyd.c @@ -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; diff --git a/deployment/etc/pandora/conf/desktop b/deployment/etc/pandora/conf/desktop index a1f6d04..b45fccf 100644 --- a/deployment/etc/pandora/conf/desktop +++ b/deployment/etc/pandora/conf/desktop @@ -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 diff --git a/include/pnd_apps.h b/include/pnd_apps.h index 13dc07a..719622a 100644 --- a/include/pnd_apps.h +++ b/include/pnd_apps.h @@ -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 "./" diff --git a/lib/pnd_desktop.c b/lib/pnd_desktop.c index b5b9a40..3bb3066 100644 --- a/lib/pnd_desktop.c +++ b/lib/pnd_desktop.c @@ -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 diff --git a/testdata/conf/desktop b/testdata/conf/desktop index befc4e1..4b1e994 100644 --- a/testdata/conf/desktop +++ b/testdata/conf/desktop @@ -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