From ab90c65551d4a1cfe0c13f5f394c6e8736eb5b14 Mon Sep 17 00:00:00 2001 From: skeezix Date: Wed, 17 Mar 2010 21:03:05 -0400 Subject: [PATCH] Added option to invoke a terminal from within mm --- deployment/etc/pandora/conf/mmenu.conf | 3 ++ minimenu/mmenu.conf | 3 ++ minimenu/mmui.c | 40 ++++++++++++++++++++++---- minimenu/mmui.h | 3 ++ 4 files changed, 44 insertions(+), 5 deletions(-) diff --git a/deployment/etc/pandora/conf/mmenu.conf b/deployment/etc/pandora/conf/mmenu.conf index c0886f5..9a5291e 100644 --- a/deployment/etc/pandora/conf/mmenu.conf +++ b/deployment/etc/pandora/conf/mmenu.conf @@ -14,6 +14,9 @@ desktop_apps 1 # search the pnd standard desktop searchpath for apps menu_apps 1 # search the pnd standard menu searchpath for apps aux_searchpath /media/*/pandora/mmenu # if something here, also search this path; can be used for mmenu-only apps? +[utility] +terminal /usr/bin/Terminal # could also be /usr/bin/xterm, or a sh-script, or whatever + [display] fullscreen 1 # 0 for windowed, >0 for fullscreen screen_width 800 # for some calculations diff --git a/minimenu/mmenu.conf b/minimenu/mmenu.conf index a48bec0..4291d86 100644 --- a/minimenu/mmenu.conf +++ b/minimenu/mmenu.conf @@ -14,6 +14,9 @@ desktop_apps 1 # search the pnd standard desktop searchpath for apps menu_apps 1 # search the pnd standard menu searchpath for apps aux_searchpath /media/*/pandora/mmenu # if something here, also search this path; can be used for mmenu-only apps? +[utility] +terminal /usr/bin/Terminal # could also be /usr/bin/xterm, or a sh-script, or whatever + [display] fullscreen 0 # 0 for windowed, >0 for fullscreen screen_width 800 # for some calculations diff --git a/minimenu/mmui.c b/minimenu/mmui.c index ad51e39..445ad2c 100644 --- a/minimenu/mmui.c +++ b/minimenu/mmui.c @@ -673,7 +673,7 @@ void ui_render ( unsigned int render_mask ) { // battery if ( 1 ) { - static last_battlevel = 0; + static int last_battlevel = 0; static unsigned char batterylevel = 0; char buffer [ 100 ]; @@ -902,12 +902,13 @@ void ui_process_input ( unsigned char block_p ) { "Shutdown Pandora", "Rescan for Applications", "Run xfce4 from Minimenu", + "Run a terminal/console", "Exit and run xfce4", "Exit and run pmenu", "Quit (<- beware)", "About Minimenu" }; - int sel = ui_modal_single_menu ( opts, 8, "Minimenu", "Enter to select; other to return." ); + int sel = ui_modal_single_menu ( opts, 9, "Minimenu", "Enter to select; other to return." ); char buffer [ 100 ]; if ( sel == 0 ) { @@ -931,22 +932,32 @@ void ui_process_input ( unsigned char block_p ) { sprintf ( buffer, "%s %s\n", MM_RUN, "/usr/bin/startxfce4" ); emit_and_quit ( buffer ); } else if ( sel == 4 ) { + // run terminal + char *argv[5]; + argv [ 0 ] = pnd_conf_get_as_char ( g_conf, "utility.terminal" ); + argv [ 1 ] = NULL; + + if ( argv [ 0 ] ) { + ui_forkexec ( argv ); + } + + } else if ( sel == 5 ) { // set env to xfce sprintf ( buffer, "echo startxfce4 > /tmp/gui.load" ); system ( buffer ); //sprintf ( buffer, "sudo poweroff" ); //system ( buffer ); exit ( 0 ); - } else if ( sel == 5 ) { + } else if ( sel == 6 ) { // set env to pmenu sprintf ( buffer, "echo pmenu > /tmp/gui.load" ); system ( buffer ); //sprintf ( buffer, "sudo poweroff" ); //system ( buffer ); exit ( 0 ); - } else if ( sel == 6 ) { - emit_and_quit ( MM_QUIT ); } else if ( sel == 7 ) { + emit_and_quit ( MM_QUIT ); + } else if ( sel == 8 ) { // about } @@ -1798,3 +1809,22 @@ void ui_touch_act ( unsigned int x, unsigned int y ) { return; } + +unsigned char ui_forkexec ( char *argv[] ) { + char *fooby = argv[0]; + int x; + + if ( ( x = fork() ) < 0 ) { + pnd_log ( pndn_error, "ERROR: Couldn't fork() for '%s'\n", fooby ); + return ( 0 ); + } + + if ( x == 0 ) { // child + execv ( fooby, argv ); + pnd_log ( pndn_error, "ERROR: Couldn't exec(%s)\n", fooby ); + return ( 0 ); + } + + // parent, success + return ( 1 ); +} diff --git a/minimenu/mmui.h b/minimenu/mmui.h index 0ac17ff..886d557 100644 --- a/minimenu/mmui.h +++ b/minimenu/mmui.h @@ -68,6 +68,9 @@ void ui_cachescreen ( unsigned char clearscreen, char *filename ); // while cach // show a menu, return when selection made; -1 means no selection. Enter is pick. int ui_modal_single_menu ( char *argv[], unsigned int argc, char *title, char *footer ); +// run a forked app (ie: not wait for it to return) +unsigned char ui_forkexec ( char *argv[] ); // argv[0] is proggy to exec; argv last entry must be NULLptr + /* internal functions follow */ -- 2.39.2