diff --git a/Makefile b/Makefile index 2822c09..26a3bf9 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ all: - gcc -o texec texec.c -lX11 -lpng + gcc -Wall -o texec texec.c -lX11 -lpng clean: rm -rf texec diff --git a/texec.c b/texec.c index d88f4e4..bae70d8 100644 --- a/texec.c +++ b/texec.c @@ -1,30 +1,29 @@ /* + * texec.c - Minimal X11 tray applet with mandatory PNG icon (32x32) + * * Copyright 2025 Johannes Findeisen * Licensed under the terms of the Apache-2.0 license. * https://opensource.org/license/apache-2-0 * - * .c - Minimal X11 tray applet with mandatory PNG icon (32x32) - * * Compile: - * gcc -o gexec_xembed gexec_xembed.c -lX11 -lXrender -lpng + * gcc -o texec.c -lX11 -lpng * * Usage: - * ./gexec_xembed "" + * ./texec "" * * Left-click: execute command * Right-click: quit applet */ -#include -#include -#include -//#include #include #include #include #include #include #include +#include +#include +#include #define WIDTH 24 #define HEIGHT 24 @@ -32,14 +31,14 @@ static Display *dpy; static int screen; static Window icon_win; -static char *g_command; +static char *x_command; void execute_command() { - if (!g_command) return; + if (!x_command) return; pid_t pid = fork(); if (pid == 0) { setsid(); - execl("/bin/sh", "sh", "-c", g_command, (char *)NULL); + execl("/bin/sh", "sh", "-c", x_command, (char *)NULL); _exit(127); } } @@ -112,7 +111,7 @@ int main(int argc, char *argv[]) { fprintf(stderr,"Usage: %s \n",argv[0]); return 1; } - g_command = argv[1]; + x_command = argv[1]; char *icon_path = argv[2]; signal(SIGCHLD, SIG_IGN); @@ -158,8 +157,11 @@ int main(int argc, char *argv[]) { if (xev.xany.window == icon_win) { if (xev.type == Expose) draw_icon(icon_win, icon_path); else if (xev.type == ButtonPress) { - if (xev.xbutton.button == 1) execute_command(); // left-click - else if (xev.xbutton.button == 3) break; // right-click: quit + if (xev.xbutton.button == 1) { + execute_command(); // left-click + } else if (xev.xbutton.button == 3) { + break; // right-click: quit + } } } }