From f1dc1e4cfea8a9ad25011e3024ee2438f3d525c7 Mon Sep 17 00:00:00 2001 From: skeezix Date: Wed, 10 Mar 2010 10:28:47 -0500 Subject: [PATCH] Changed PXML so 'no_x' option is now 'x11', with option req/stop/ignore Changed mmenu to suppress apps that require x11, when x11 is not running --- include/pnd_pxml.h | 7 +++ include/pnd_pxml_names.h | 2 +- lib/pnd_apps.c | 2 +- lib/pnd_desktop.c | 2 +- lib/pnd_pxml.c | 15 +++++++ minimenu/TODO.txt | 6 +++ minimenu/mmenu.c | 94 ++++++++++++++++++++++++++-------------- minimenu/mmenu.conf | 1 + minimenu/mmui.c | 9 ++-- 9 files changed, 99 insertions(+), 39 deletions(-) diff --git a/include/pnd_pxml.h b/include/pnd_pxml.h index f381dde..623d527 100644 --- a/include/pnd_pxml.h +++ b/include/pnd_pxml.h @@ -93,6 +93,13 @@ void pnd_pxml_set_app_name ( pnd_pxml_handle h, char *v ); /* utilities */ +typedef enum { + pnd_pxml_x11_error = 0, + pnd_pxml_x11_required, + pnd_pxml_x11_ignored, + pnd_pxml_x11_stop +} pnd_pxml_x11_req_e; +pnd_pxml_x11_req_e pnd_pxml_get_x11 ( char *pxmlvalue ); // returns error, required, ignored, stop hint unsigned char pnd_is_pxml_valid_app ( pnd_pxml_handle h ); // returns 1 when pxml seems like a valid application unsigned char pnd_pxml_is_affirmative ( char *v ); // return 1 for 'Y' or '!' diff --git a/include/pnd_pxml_names.h b/include/pnd_pxml_names.h index 9432314..edf7a53 100644 --- a/include/pnd_pxml_names.h +++ b/include/pnd_pxml_names.h @@ -26,7 +26,7 @@ extern "C" { #define PND_PXML_ATTRNAME_EXECCMD "command" #define PND_PXML_ATTRNAME_EXECARGS "arguments" #define PND_PXML_ATTRNAME_EXECWD "startdir" -#define PND_PXML_ATTRNAME_EXECNOX11 "no_x11" +#define PND_PXML_ATTRNAME_EXECNOX11 "x11" /* */ #define PND_PXML_ENAME_ICON "icon" diff --git a/lib/pnd_apps.c b/lib/pnd_apps.c index eed07f3..33b72c8 100644 --- a/lib/pnd_apps.c +++ b/lib/pnd_apps.c @@ -85,7 +85,7 @@ unsigned char pnd_apps_exec ( char *pndrun, char *fullpath, char *unique_id, } if ( options & PND_EXEC_OPTION_NOX11 ) { - argv [ f++ ] = "-x"; // no union for now + argv [ f++ ] = "-x"; // shut down X! } // finish diff --git a/lib/pnd_desktop.c b/lib/pnd_desktop.c index 427622a..a222b8f 100644 --- a/lib/pnd_desktop.c +++ b/lib/pnd_desktop.c @@ -129,7 +129,7 @@ unsigned char pnd_emit_dotdesktop ( char *targetpath, char *pndrun, pnd_disco_t } // exec options - if ( pnd_pxml_is_affirmative ( p -> option_no_x11 ) ) { + if ( pnd_pxml_get_x11 ( p -> option_no_x11 ) == pnd_pxml_x11_stop ) { strncat ( buffer, " -x ", 1020 ); } diff --git a/lib/pnd_pxml.c b/lib/pnd_pxml.c index 2cde635..0e06987 100644 --- a/lib/pnd_pxml.c +++ b/lib/pnd_pxml.c @@ -554,3 +554,18 @@ unsigned char pnd_pxml_is_affirmative ( char *v ) { return ( 0 ); } + +pnd_pxml_x11_req_e pnd_pxml_get_x11 ( char *pxmlvalue ) { + + if ( ! pxmlvalue ) { + return ( pnd_pxml_x11_ignored ); + } else if ( strcasecmp ( pxmlvalue, "req" ) == 0 ) { + return ( pnd_pxml_x11_required ); + } else if ( strcasecmp ( pxmlvalue, "stop" ) == 0 ) { + return ( pnd_pxml_x11_stop ); + } else if ( strcasecmp ( pxmlvalue, "ignore" ) == 0 ) { + return ( pnd_pxml_x11_ignored ); + } + + return ( pnd_pxml_x11_ignored ); // default +} diff --git a/minimenu/TODO.txt b/minimenu/TODO.txt index baca038..fe2eb54 100644 --- a/minimenu/TODO.txt +++ b/minimenu/TODO.txt @@ -5,10 +5,16 @@ - libpnd: appdata-dir-name +- libpnd pxml change for no-X + - wrapper black screen? - manual app rescan +- conf: use real app searchpaths + +- About screen + - deploy.. - .desktop for deply - tell ED how to launch it diff --git a/minimenu/mmenu.c b/minimenu/mmenu.c index 6ff5bab..f7fa63c 100644 --- a/minimenu/mmenu.c +++ b/minimenu/mmenu.c @@ -57,6 +57,7 @@ pnd_conf_handle g_conf = 0; char *pnd_run_script = NULL; char *g_skinpath = NULL; +unsigned char g_x11_present = 1; // >0 if X is present int main ( int argc, char *argv[] ) { int logall = -1; // -1 means normal logging rules; >=0 means log all! @@ -160,6 +161,27 @@ int main ( int argc, char *argv[] ) { /* setup */ + // X11? + if ( pnd_conf_get_as_char ( g_conf, "minimenu.x11_present_sh" ) ) { + FILE *fx = popen ( pnd_conf_get_as_char ( g_conf, "minimenu.x11_present_sh" ), "r" ); + char buffer [ 100 ]; + if ( fx ) { + if ( fgets ( buffer, 100, fx ) ) { + if ( atoi ( buffer ) ) { + g_x11_present = 1; + pnd_log ( pndn_rem, "X11 seems to be present [pid %u]\n", atoi(buffer) ); + } else { + g_x11_present = 0; + pnd_log ( pndn_rem, "X11 seems NOT to be present\n" ); + } + } else { + g_x11_present = 0; + pnd_log ( pndn_rem, "X11 seems NOT to be present\n" ); + } + pclose ( fx ); + } + } // x11? + // pnd_run.sh pnd_run_script = pnd_locate_filename ( pnd_conf_get_as_char ( g_conf, "minimenu.pndrun" ), "pnd_run.sh" ); @@ -253,52 +275,58 @@ int main ( int argc, char *argv[] ) { } } // preview now? - // push to All category - // we do this first, so first category is always All - if ( ! category_push ( CATEGORY_ALL, iter ) ) { - pnd_log ( pndn_warning, " Couldn't categorize to All: '%s'\n", IFNULL(iter -> title_en, "No Name") ); - } - - // push the categories + // push the categories .. or suppress application // + if ( ( pnd_pxml_get_x11 ( iter -> option_no_x11 ) != pnd_pxml_x11_required ) || + ( pnd_pxml_get_x11 ( iter -> option_no_x11 ) == pnd_pxml_x11_required && g_x11_present == 1 ) + ) + { - // main categories - if ( iter -> main_category && pnd_conf_get_as_int_d ( g_conf, "tabs.top_maincat", 1 ) ) { - if ( ! category_push ( iter -> main_category, iter ) ) { - pnd_log ( pndn_warning, " Couldn't categorize to %s: '%s'\n", iter -> main_category, IFNULL(iter -> title_en, "No Name") ); + // push to All category + // we do this first, so first category is always All + if ( ! category_push ( g_x11_present ? CATEGORY_ALL " (X11)" : CATEGORY_ALL " (No X11)", iter ) ) { + pnd_log ( pndn_warning, " Couldn't categorize to All: '%s'\n", IFNULL(iter -> title_en, "No Name") ); } - } - if ( iter -> main_category1 && pnd_conf_get_as_int_d ( g_conf, "tabs.top_maincat1", 0 ) ) { - if ( ! category_push ( iter -> main_category1, iter ) ) { - pnd_log ( pndn_warning, " Couldn't categorize to %s: '%s'\n", iter -> main_category1, IFNULL(iter -> title_en, "No Name") ); + // main categories + if ( iter -> main_category && pnd_conf_get_as_int_d ( g_conf, "tabs.top_maincat", 1 ) ) { + if ( ! category_push ( iter -> main_category, iter ) ) { + pnd_log ( pndn_warning, " Couldn't categorize to %s: '%s'\n", iter -> main_category, IFNULL(iter -> title_en, "No Name") ); + } } - } - if ( iter -> main_category2 && pnd_conf_get_as_int_d ( g_conf, "tabs.top_maincat2", 0 ) ) { - if ( ! category_push ( iter -> main_category2, iter ) ) { - pnd_log ( pndn_warning, " Couldn't categorize to %s: '%s'\n", iter -> main_category2, IFNULL(iter -> title_en, "No Name") ); + if ( iter -> main_category1 && pnd_conf_get_as_int_d ( g_conf, "tabs.top_maincat1", 0 ) ) { + if ( ! category_push ( iter -> main_category1, iter ) ) { + pnd_log ( pndn_warning, " Couldn't categorize to %s: '%s'\n", iter -> main_category1, IFNULL(iter -> title_en, "No Name") ); + } } - } - // alt categories - if ( iter -> alt_category && pnd_conf_get_as_int_d ( g_conf, "tabs.top_altcat", 0 ) ) { - if ( ! category_push ( iter -> alt_category, iter ) ) { - pnd_log ( pndn_warning, " Couldn't categorize to %s: '%s'\n", iter -> alt_category, IFNULL(iter -> title_en, "No Name") ); + if ( iter -> main_category2 && pnd_conf_get_as_int_d ( g_conf, "tabs.top_maincat2", 0 ) ) { + if ( ! category_push ( iter -> main_category2, iter ) ) { + pnd_log ( pndn_warning, " Couldn't categorize to %s: '%s'\n", iter -> main_category2, IFNULL(iter -> title_en, "No Name") ); + } } - } - if ( iter -> alt_category1 && pnd_conf_get_as_int_d ( g_conf, "tabs.top_altcat1", 0 ) ) { - if ( ! category_push ( iter -> alt_category1, iter ) ) { - pnd_log ( pndn_warning, " Couldn't categorize to %s: '%s'\n", iter -> alt_category1, IFNULL(iter -> title_en, "No Name") ); + // alt categories + if ( iter -> alt_category && pnd_conf_get_as_int_d ( g_conf, "tabs.top_altcat", 0 ) ) { + if ( ! category_push ( iter -> alt_category, iter ) ) { + pnd_log ( pndn_warning, " Couldn't categorize to %s: '%s'\n", iter -> alt_category, IFNULL(iter -> title_en, "No Name") ); + } } - } - if ( iter -> alt_category2 && pnd_conf_get_as_int_d ( g_conf, "tabs.top_altcat2", 0 ) ) { - if ( ! category_push ( iter -> alt_category2, iter ) ) { - pnd_log ( pndn_warning, " Couldn't categorize to %s: '%s'\n", iter -> alt_category2, IFNULL(iter -> title_en, "No Name") ); + if ( iter -> alt_category1 && pnd_conf_get_as_int_d ( g_conf, "tabs.top_altcat1", 0 ) ) { + if ( ! category_push ( iter -> alt_category1, iter ) ) { + pnd_log ( pndn_warning, " Couldn't categorize to %s: '%s'\n", iter -> alt_category1, IFNULL(iter -> title_en, "No Name") ); + } } - } + + if ( iter -> alt_category2 && pnd_conf_get_as_int_d ( g_conf, "tabs.top_altcat2", 0 ) ) { + if ( ! category_push ( iter -> alt_category2, iter ) ) { + pnd_log ( pndn_warning, " Couldn't categorize to %s: '%s'\n", iter -> alt_category2, IFNULL(iter -> title_en, "No Name") ); + } + } + + } // register with categories or filter out // next iter = pnd_box_get_next ( iter ); diff --git a/minimenu/mmenu.conf b/minimenu/mmenu.conf index 77571b7..f8546d2 100644 --- a/minimenu/mmenu.conf +++ b/minimenu/mmenu.conf @@ -9,6 +9,7 @@ pndrun /usr/pandora/scripts:./testdata/scripts # searchpath to locate "pnd_run load_previews_now 0 # if >0, will try to load preview pics from pnds at boot time, not defer till later load_previews_later 0 # if >0, will try to load preview pics sometime (see defer_timer_ms as well) loglevel 0 # 0 is debug, lots of crap; 3 is better, means 'errors only'. Output may screw up the wrapper! +x11_present_sh /bin/pidof X # command to invoke to determine if X11 is running or not; expects a number on X is present. [apps] searchpath ./testdata/app2:./testdata/app3:/media/*/pandora/desktop diff --git a/minimenu/mmui.c b/minimenu/mmui.c index eecef61..e069647 100644 --- a/minimenu/mmui.c +++ b/minimenu/mmui.c @@ -847,13 +847,14 @@ void ui_process_input ( unsigned char block_p ) { "Rescan for Applications", "Set to full desktop and reboot", "Set to pmenu and reboot", - "Quit (<- beware)" + "Quit (<- beware)", + "About Minimenu" }; - int sel = ui_modal_single_menu ( opts, 6, "Minimenu", "Enter to select; other to return." ); + int sel = ui_modal_single_menu ( opts, 7, "Minimenu", "Enter to select; other to return." ); char buffer [ 100 ]; if ( sel == 0 ) { - return ( -1 ); // return + // do nothing } else if ( sel == 1 ) { sprintf ( buffer, "sudo poweroff" ); system ( buffer ); @@ -873,6 +874,8 @@ void ui_process_input ( unsigned char block_p ) { system ( buffer ); } else if ( sel == 5 ) { emit_and_quit ( MM_QUIT ); + } else if ( sel == 6 ) { + // about } ui_event++; -- 2.39.2