Skip to content

Instantly share code, notes, and snippets.

@xenogenesi
Created January 8, 2017 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xenogenesi/f16a07b366576327d62449e94c82f100 to your computer and use it in GitHub Desktop.
Save xenogenesi/f16a07b366576327d62449e94c82f100 to your computer and use it in GitHub Desktop.
fbpanel patch to enable terminal commands in system-menu plugin from .desktop files
--- a/plugins/menu/system_menu.c
+++ b/plugins/menu/system_menu.c
@@ -4,6 +4,10 @@
#include <glib/gstdio.h>
#include <string.h>
#include <time.h>
+#define PREPEND_TERMINAL
+#ifdef PREPEND_TERMINAL
+#include <stdlib.h>
+#endif
#include "panel.h"
#include "xconf.h"
@@ -86,6 +90,27 @@ do_app_file(GHashTable *ht, const gchar *file)
dot[0] = dot[1] = ' ';
}
DBG("action: %s\n", action);
+#ifdef PREPEND_TERMINAL
+ if ((dot = g_key_file_get_string(f, desktop_ent, "Terminal", NULL)))
+ {
+ if (!(g_ascii_strncasecmp(dot, "true", 4)))
+ {
+ const gchar *term_action, *term;
+
+ /* FIXME get the fallback from fbpanel/menu-plugin config */
+ if (!(term = getenv("TERMINAL")))
+ term = "x-terminal";
+
+ if ((term_action = g_strdup_printf("%s %s", term, action)))
+ {
+ g_free(action);
+ action = (gchar *)term_action;
+ DBG("xterm action: %s\n", action);
+ }
+ }
+ g_free(dot);
+ }
+#endif
/* if icon is NOT an absolute path but has an extention,
* e.g. firefox.png, then drop an extenstion to allow to load it
* as themable icon */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment