From 344c3b8431b75133a05f992edf80263490c8a80d Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Fri, 3 Nov 2023 17:59:24 -0400 Subject: [PATCH] Initial commit --- .editorconfig | 9 ++ .gitignore | 3 + INSTALL.md | 34 ++++ README.md | 3 + libXmd/XmdIcon.c | 14 ++ libXmd/build.sh | 26 +++ libXmd/include/Xmd/Icon.h | 13 ++ libXmd/include/Xmd/Launcher.h | 13 ++ scripts/buildapp.sh | 27 ++++ scripts/flags.sh | 5 + xmbattery/..o | Bin 0 -> 10824 bytes xmbattery/.o | Bin 0 -> 10208 bytes xmbattery/build.sh | 2 + xmbattery/src/icons/charging.xbm | 15 ++ xmbattery/src/icons/error.xbm | 15 ++ xmbattery/src/icons/level0.xbm | 15 ++ xmbattery/src/icons/level1.xbm | 15 ++ xmbattery/src/icons/level2.xbm | 15 ++ xmbattery/src/icons/level3.xbm | 15 ++ xmbattery/src/icons/level4.xbm | 15 ++ xmbattery/src/icons/not.xbm | 15 ++ xmbattery/src/main.c | 242 ++++++++++++++++++++++++++++ xmbrightness/build.sh | 2 + xmbrightness/src/main.c | 86 ++++++++++ xmpanel/build.sh | 2 + xmpanel/src/icons/appCalculator.xbm | 27 ++++ xmpanel/src/icons/appEditor.xbm | 27 ++++ xmpanel/src/icons/appFiles.xbm | 27 ++++ xmpanel/src/icons/appMail.xbm | 27 ++++ xmpanel/src/icons/appTerminal.xbm | 27 ++++ xmpanel/src/icons/appWebBrowser.xbm | 27 ++++ xmpanel/src/main.c | 75 +++++++++ 32 files changed, 838 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 INSTALL.md create mode 100644 README.md create mode 100644 libXmd/XmdIcon.c create mode 100755 libXmd/build.sh create mode 100644 libXmd/include/Xmd/Icon.h create mode 100644 libXmd/include/Xmd/Launcher.h create mode 100755 scripts/buildapp.sh create mode 100644 scripts/flags.sh create mode 100644 xmbattery/..o create mode 100644 xmbattery/.o create mode 100755 xmbattery/build.sh create mode 100644 xmbattery/src/icons/charging.xbm create mode 100644 xmbattery/src/icons/error.xbm create mode 100644 xmbattery/src/icons/level0.xbm create mode 100644 xmbattery/src/icons/level1.xbm create mode 100644 xmbattery/src/icons/level2.xbm create mode 100644 xmbattery/src/icons/level3.xbm create mode 100644 xmbattery/src/icons/level4.xbm create mode 100644 xmbattery/src/icons/not.xbm create mode 100644 xmbattery/src/main.c create mode 100755 xmbrightness/build.sh create mode 100644 xmbrightness/src/main.c create mode 100755 xmpanel/build.sh create mode 100644 xmpanel/src/icons/appCalculator.xbm create mode 100644 xmpanel/src/icons/appEditor.xbm create mode 100644 xmpanel/src/icons/appFiles.xbm create mode 100644 xmpanel/src/icons/appMail.xbm create mode 100644 xmpanel/src/icons/appTerminal.xbm create mode 100644 xmpanel/src/icons/appWebBrowser.xbm create mode 100644 xmpanel/src/main.c diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..6f436ae --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = tab +indent_size = 8 +charset = utf-8 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..86b34b2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +bin/ +lib/ +~* diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000..4ce85c1 --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,34 @@ +# Installing + +## Dependencies + +- Xlib +- Xt +- Motif +- A C compiler + +Installing via APK: + +```sh +# apk add libx11 libx11-dev libxt libxt-dev motif motif-dev clang +``` + +## libXmd + +Before building any of the applications you will need to build libXmd, which +contains code common to most of them: + +``` +# cd libXmd +# ./build.sh install +``` + +## Individual applications + +Individual applications can be installed using `./build.sh` in their respective +subdirectories: + +``` +# cd +# ./build.sh install +``` diff --git a/README.md b/README.md new file mode 100644 index 0000000..ef07731 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Xmd + +A collection of X11 Motif desktop utilities written in C99. diff --git a/libXmd/XmdIcon.c b/libXmd/XmdIcon.c new file mode 100644 index 0000000..9b8d633 --- /dev/null +++ b/libXmd/XmdIcon.c @@ -0,0 +1,14 @@ +#include + +Pixmap _XmdLoadBitmapIcon (Widget widget, unsigned char *bits, int width, int height) { + Pixel fg, bg; + XtVaGetValues (widget, + XmNforeground, &fg, + XmNbackground, &bg, + NULL); + return XCreatePixmapFromBitmapData ( + XtDisplay (widget), + RootWindowOfScreen(XtScreen(widget)), + (char *)(bits), width, height, + fg, bg, DefaultDepthOfScreen(XtScreen(widget))); +} diff --git a/libXmd/build.sh b/libXmd/build.sh new file mode 100755 index 0000000..6f85513 --- /dev/null +++ b/libXmd/build.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +. ../scripts/flags.sh + +function build() { + cc $CFLAGS -shared -o "lib/libXmd.so" *.c || \ + echo "XXX FAIL!" +} + +function clean() { + rm -f lib/* +} + +case "$1" in +install) + clean; build + cp lib/*.so "$PREFIX/lib" + cp include/Xmd/*.h "$PREFIX/include/Xmd" + clean + ;; +clean) + clean + ;; +*) + build +esac diff --git a/libXmd/include/Xmd/Icon.h b/libXmd/include/Xmd/Icon.h new file mode 100644 index 0000000..b709e7b --- /dev/null +++ b/libXmd/include/Xmd/Icon.h @@ -0,0 +1,13 @@ +#ifndef _XmdIcon_h +#define _XmdIcon_h + +#include +#include +#include + +/* XmdLoadBitmapIcon is a macro that loads an icon with the specified name. That Icon must + be #include'd in your code somewhere. The name parameter must be a token, not a string. */ +#define XmdLoadBitmapIcon(widget, name) _XmdLoadBitmapIcon(widget, name##_bits, name##_width, name##_height) +Pixmap _XmdLoadBitmapIcon (Widget widget, unsigned char *bits, int width, int height); + +#endif diff --git a/libXmd/include/Xmd/Launcher.h b/libXmd/include/Xmd/Launcher.h new file mode 100644 index 0000000..e24ec80 --- /dev/null +++ b/libXmd/include/Xmd/Launcher.h @@ -0,0 +1,13 @@ +#ifndef _XmdLauncher_h +#define _XmdLauncher_h + +#include +#include +#include + +typedef struct { + Pixmap icon; + const char *command; +} XmdLauncher; + +#endif diff --git a/scripts/buildapp.sh b/scripts/buildapp.sh new file mode 100755 index 0000000..e93fecf --- /dev/null +++ b/scripts/buildapp.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +. `dirname $0`/flags.sh + +function build() { + mkdir -p bin + cc $CFLAGS -c -o "bin/$1.o" src/*.c && \ + cc -o "bin/$1" "bin/$1.o" $APP_LIBS || \ + echo "XXX FAIL!" +} + +function clean() { + rm -f bin/* +} + +case "$2" in +install) + clean; build "$1" + cp "bin/$1" "$PREFIX/bin" + clean + ;; +clean) + clean + ;; +*) + build "$1" +esac diff --git a/scripts/flags.sh b/scripts/flags.sh new file mode 100644 index 0000000..38d9d40 --- /dev/null +++ b/scripts/flags.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +CFLAGS="-std=c99 -Wall -Wextra -Werror -fPIC" +PREFIX="/usr/local" +APP_LIBS="-lXmd -lXm -lXt -lX11" diff --git a/xmbattery/..o b/xmbattery/..o new file mode 100644 index 0000000000000000000000000000000000000000..6774986715a87611927bbcae6a97118c2c3dc0e6 GIT binary patch literal 10824 zcmds7eQ;FO6~9SV5qVrfr_GqtjUI#X`&GbrXw0Qn@zH^n_YL`3UNTd zOq{;1TVY0O{%|TzXDVZ7)ONIuTIr%zaI_u7cE(nx6KzE+nGwgSO*;(f`Q4A*lSdwE zOaJK^-hKD}?m54E?zx|D!}efHQ)x+wFj68`ieky2LRbrn`FfeH7nNeRXt$gXtids# zvu(_BGNV?uebmYY$L?lY#V??g{%~69jg?cJxo;_V zrfSLf{UsWi6oKz*l{@TlW@HSe`wtd}Jc3M?6QDG2j z^F6aa$`X8|_)gE+S9h{ILrugQ;|E4rMSl$7X6L zcgZ$&sD|=(xyC)6C;jnm>nas6d%BK(aGwfkHaK@EpE*m<XLIRf;fkhIiF9P!sk>jUk9b!%x?vM{k}TiWZiKjO3w^C^C)788!1_7Mu&KDG3kokM0*m};Vto>@=X z`f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A9YpZP1K}FMbd@7AuQ{n@d$33vi}rhly62ku4vHzR9w!T z!dSG0Qjva`v?Y?6B(@3Rm#Lt8mk_h)IYA#B5ObaZpUvUN4SEcZ!}QN%_%088SmWTC$Mhfd(Eka;FJSsV zWB7%X-+YMzl=z%Ql8=wHEbK8}kSj=o~dAS*PEc6omTOrN)F zG5j*JG40;Qa2aRauL#4@?tFS6DUG|^9bo!%NYC(pkLmju{vgxmem>0f=QI5uGyHOf zKf!qTI{G=&zk=zHGkx@HAw7^%3<%!z0Ix=Y@|Gj{7~N-h~^UTU8IG)J_i>G*y>Bx7Nv4l}8U2?Tj;#6Cd)DPx0NA?Ci-k*5ze9rX2 zW8yGN6C(alc~|p%P2=u%&evZ7uaO|I*`keaMg`0EjAB=wq z<1g3uZ17|MG3WgS8b=%uV-p`A)93qbHPf$U`pXzz$M97iJU25O{o17awSn<)|N9ue zl<_AR5BGC3)1S}uw=x`is_E};hVya!5##6k{}T-NF`i#C9{d&1@Q*W`&xdq5DUq0Q z`K~I8A&tAof%9@iITq+U^`Q<0GzZ;)p{x13u_NNl6AZwBJQ_dg5SC{aI6Y)4ck^KD$JL0Dwq!-JN zMP2Ug&-jxm`ld|T14IP+NMC19Din_>@BaJLM-=F)UhW0LdY#Mad15MbSWHpgwK1pb z3y8{$<0FVUP^e&cw&^$l@#nr`x_BhciisdKFS% zA*V7p6W|x0i>NX7@1VfM_-~+QsoVbFtwO@k literal 0 HcmV?d00001 diff --git a/xmbattery/.o b/xmbattery/.o new file mode 100644 index 0000000000000000000000000000000000000000..3f52db439e897499bda0f1c90137ebb8410b8670 GIT binary patch literal 10208 zcmd^FYiu0V6~1eS*d!)4h_)`z4Z$HPWN{oyO3K5=Su++1HAx&&737TVvAtwp-JOL5 z5#n^^is@ouDy7X2q<|{5?n5Z82sN*CNmCLkwF=OxNJZ5`OG>e&CTeM|DvEo)``A66 zcmlNPuO4~sJ@>okbXXU5D z-p(n@%ayD`cgY%!PTeo=7oFbgonG;I2)}^B8a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LlZPvgatz>dx2VaMe80fxiQWhjX90d^i^^00HYlosM? zhQq{5+Rifpc7Dp_VaKeu_n7?EgqwL>px^hK;!=nu6>!GM|%sb}g z%k+TWVDfxkPWj{?P~u`yjbh-J%P-Y9?BhQL%>1rrIQ%|A52z==&OV0o`8~w!U>?7P z%aiEu42OMlUY!cCb7iemE5AQ{PhaE?!(r!#N=zg)j`6n8W5$(dIA15<48WgeIA16G z8NQ0yf0^O9(~RFY7`}|*#7e^Pi1=Sr&GPRZ20yHE?0t~IUsFx_4#{!zJ{Q*gm|r}G zS~X*E^Bum`hnw%@VIOXO*Lcc@o8JqHKHPlAmVCJR{X#^tI})zlOSPL(^^oB*PTY>j zPs2#R?b;&JOCNlZOiDFmFW3likvP6gM5Hg3NZ>Ofl1#ZygnsB;AwP5EZb|<+*^7*m=4Ht!aFI}ZYu|gAJXf-v_N%W z&qCLj!?y%zDLugT^#n*#SpTrw1>=muj0cM|0yh2n!*EEnMOEc8T;>#mvkm_FnnRD# z|2-OvO#BAAm6*BW--=6=C@jlL;cwqWU32Bnx=QJ6Rh2yRFh|C}$=_Xs!9VT*PQ%*& zjT|H%vLI96!+6=Di|4dH$G{ssgAWpeqtKtf39avs%fxT=cM$`de*O2g{ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "icons/level0.xbm" +#include "icons/level1.xbm" +#include "icons/level2.xbm" +#include "icons/level3.xbm" +#include "icons/level4.xbm" +#include "icons/charging.xbm" +#include "icons/error.xbm" +#include "icons/not.xbm" + +typedef enum { + BatteryStateCharging, + BatteryStateNotCharging, + BatteryStateFull, + BatteryStateDischarging, + BatteryStateError +} BatteryState; + +typedef struct { + int level; + BatteryState state; + int hours; + int minutes; + int seconds; +} BatteryInfo; + +BatteryInfo getBatteryInfo (void); +Pixmap selectBatteryIcon (BatteryInfo); +void loadAllPixmaps (Widget); +void batteryPoll (XtPointer, XtIntervalId *); +void resetBatteryPollTimeout(void); +void batteryInfoDialog (Widget, XtPointer, XtPointer); + +Pixmap levels[8] = { 0 }; +XtAppContext application; +Widget icon; +Widget text; +Widget layout; +Widget window; + +int main (int argc, char *argv[]) { + window = XtVaAppInitialize ( + &application, "Battery", + NULL, 0, + &argc, argv, + NULL, + XmNtitle, "Battery", + NULL); + + layout = XtVaCreateWidget ( + "layout", xmRowColumnWidgetClass, window, + XmNorientation, XmHORIZONTAL, + NULL); + + loadAllPixmaps(layout); + icon = XtVaCreateManagedWidget ( + "batteryIcon", xmPushButtonWidgetClass, layout, + XmNleftAttachment, XmATTACH_FORM, + XmNlabelType, XmPIXMAP, + NULL); + XtAddCallback(icon, XmNactivateCallback, batteryInfoDialog, NULL); + + XtVaCreateManagedWidget ( + "separator", xmSeparatorWidgetClass, layout, + XmNorientation, XmVERTICAL, + NULL); + + text = XtVaCreateManagedWidget ( + "text", xmLabelGadgetClass, layout, + XmNalignment, XmALIGNMENT_CENTER, + NULL); + + batteryPoll(NULL, NULL); + + XtManageChild(layout); + XtRealizeWidget(window); + XtAppMainLoop(application); +} + +BatteryInfo getBatteryInfo (void) { + BatteryInfo result = { 0 }; + char charging[16] = { 0 }; + int battery; + + FILE *stream = popen("acpi -b", "r"); + if (stream == NULL) { + result.state = BatteryStateError; + return result; + } + fscanf ( + stream, "Battery %d: %16s %d%%, %d:%d:%d", + &battery, charging, &result.level, + &result.hours, &result.minutes, &result.seconds); + + switch (charging[0]) { + case 'C': result.state = BatteryStateCharging; break; + case 'N': result.state = BatteryStateNotCharging; break; + case 'D': result.state = BatteryStateDischarging; break; + case 'F': result.state = BatteryStateFull; break; + default: result.state = BatteryStateError; break; + } + if (pclose(stream) != 0) { + result.state = BatteryStateError; + } + return result; +} + +Pixmap selectBatteryIcon (BatteryInfo info) { + if (info.state == BatteryStateCharging) { + return levels[5]; + } else if (info.state == BatteryStateNotCharging) { + return levels[7]; + } else if (info.state == BatteryStateError) { + return levels[6]; + } else if (info.level < 15) { + return levels[0]; + } else if (info.level < 35) { + return levels[1]; + } else if (info.level < 65) { + return levels[2]; + } else if (info.level < 85) { + return levels[3]; + } else { + return levels[4]; + } +} + +void loadAllPixmaps (Widget widget) { + levels[0] = XmdLoadBitmapIcon(widget, level0); + levels[1] = XmdLoadBitmapIcon(widget, level1); + levels[2] = XmdLoadBitmapIcon(widget, level2); + levels[3] = XmdLoadBitmapIcon(widget, level3); + levels[4] = XmdLoadBitmapIcon(widget, level4); + levels[5] = XmdLoadBitmapIcon(widget, charging); + levels[6] = XmdLoadBitmapIcon(widget, error); + levels[7] = XmdLoadBitmapIcon(widget, not); +} + +void batteryPoll (XtPointer clientData, XtIntervalId *timer) { + (void)(clientData); + (void)(timer); + BatteryInfo info = getBatteryInfo(); + + XtVaSetValues ( + icon, + XmNlabelType, XmPIXMAP, + XmNlabelPixmap, selectBatteryIcon(info), + NULL); + XtVaSetValues ( + window, + XmNiconPixmap, selectBatteryIcon(info), + NULL); + + #define BUFFER_LEN 32 + char buffer[BUFFER_LEN]; + snprintf(buffer, BUFFER_LEN, "%d%%", info.level); + #undef BUFFER_LEN + + /* if we don't unmanage and then re-manage the child, the text flies to + * the top which is rather annoying. this little quirk bent me over and + * fucked me for hours. */ + XtUnmanageChild(text); + XmString string = XmStringCreateLocalized(buffer); + XtVaSetValues ( + text, + XmNlabelString, string, + NULL); + XmStringFree(string); + XtManageChild(text); + + resetBatteryPollTimeout(); +} + +void resetBatteryPollTimeout (void) { + XtAppAddTimeOut(application, 2000, batteryPoll, NULL); +} + +void batteryInfoDialog (Widget button, XtPointer clientData, XtPointer callData) { + (void)(clientData); + (void)(callData); + + BatteryInfo info = getBatteryInfo(); + + static const char *states[] = { + "Charging", + "Full", + "Discharging", + "Error" + }; + + #define BUFFER_LEN 48 + char timeBuffer[BUFFER_LEN] = { 0 }; + switch (info.state) { + case BatteryStateCharging: + snprintf ( + timeBuffer, BUFFER_LEN, "\n%d:%02d:%02d until charged.", + info.hours, info.minutes, info.seconds); + break; + case BatteryStateDischarging: + snprintf ( + timeBuffer, BUFFER_LEN, "\n%d:%02d:%02d until empty.", + info.hours, info.minutes, info.seconds); + break; + default: + } + #undef BUFFER_LEN + #define BUFFER_LEN 128 + char messageBuffer[BUFFER_LEN]; + snprintf ( + messageBuffer, BUFFER_LEN, "%d%%, %s%s", + info.level, states[info.state], timeBuffer); + #undef BUFFER_LEN + + Arg args[5] = { 0 }; + int n = 0; + XmString message = XmStringCreateLocalized(messageBuffer); + XtSetArg(args[n], XmNmessageString, message); n ++; + XmString title = XmStringCreateLocalized("Battery Status"); + XtSetArg(args[n], XmNdialogTitle, title); n ++; + + Widget dialog = XmCreateInformationDialog(button, "batteryInfo", args, n); + + XmStringFree(message); + XmStringFree(title); + + XtManageChild(dialog); + XtPopup(XtParent(dialog), XtGrabNone); +} diff --git a/xmbrightness/build.sh b/xmbrightness/build.sh new file mode 100755 index 0000000..d7847b7 --- /dev/null +++ b/xmbrightness/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +../scripts/buildapp.sh xmbrightness "$@" diff --git a/xmbrightness/src/main.c b/xmbrightness/src/main.c new file mode 100644 index 0000000..9e324ab --- /dev/null +++ b/xmbrightness/src/main.c @@ -0,0 +1,86 @@ +/* C99 */ + +#define _XOPEN_SOURCE +#include +#include +#include +#include +#include +#include +#include + +void valueChanged (Widget, XtPointer, XtPointer); +void setBrightness (int); +int getBrightness (); +int getMaxBrightness (); + +int main (int argc, char *argv[]) { + XtAppContext application; + Widget window = XtVaAppInitialize ( + &application, "Brightness", + NULL, 0, + &argc, argv, + NULL, + XmNtitle, "Battery", + NULL); + + int level = getBrightness(); + int max = getMaxBrightness(); + int percent = + (float)(level) / + (float)(max) * 100; + + Widget scale = XtVaCreateManagedWidget ( + "Brightness", xmScaleWidgetClass, window, + XmNmaximum, 100, + XmNminimum, 1, + XmNvalue, percent, + NULL); + XtAddCallback(scale, XmNvalueChangedCallback, valueChanged, NULL); + + XtVaSetValues(window, XmNmwmDecorations, MWM_DECOR_BORDER, NULL); + XtVaSetValues(window, XmNmwmFunctions, MWM_FUNC_RESIZE, NULL); + + //XtVaSetValues(window, XtNheight, 400, NULL); + //XtVaSetValues(window, XtNwidth, 400, NULL); + + XtRealizeWidget(window); + XtAppMainLoop(application); +} + +void valueChanged (Widget scale, XtPointer clientData, XtPointer callData) { + (void)(scale); + (void)(clientData); + XmScaleCallbackStruct *event = (XmScaleCallbackStruct *)(callData); + setBrightness(event->value); +} + +void setBrightness (int level) { + char command[32] = { 0 }; + snprintf(command, 32, "brightnessctl s %d%% -q", level); + system(command); +} + +int getBrightness () { + FILE *stream = popen("brightnessctl g", "r"); + if (stream == NULL) { + fprintf(stderr, "ERR could not get brightness\n"); + return 1; + } + int result = 1; + fscanf(stream, "%d", &result); + pclose(stream); + return result; +} + +int getMaxBrightness () { + FILE *stream = popen("brightnessctl m", "r"); + if (stream == NULL) { + fprintf(stderr, "ERR could not get brightness\n"); + return 1; + } + int result = 1; + fscanf(stream, "%d", &result); + pclose(stream); + return result; +} diff --git a/xmpanel/build.sh b/xmpanel/build.sh new file mode 100755 index 0000000..b773df2 --- /dev/null +++ b/xmpanel/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +../scripts/buildapp.sh xmpanel "$@" diff --git a/xmpanel/src/icons/appCalculator.xbm b/xmpanel/src/icons/appCalculator.xbm new file mode 100644 index 0000000..5893970 --- /dev/null +++ b/xmpanel/src/icons/appCalculator.xbm @@ -0,0 +1,27 @@ +#define appCalculator_width 48 +#define appCalculator_height 48 +static unsigned char appCalculator_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x00, 0x03, 0x00, 0x00, 0xc0, 0x00, 0x00, 0xfb, 0xff, 0xff, 0xdf, 0x00, + 0x00, 0x13, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x5b, 0x62, 0x00, 0xd8, 0x00, + 0x00, 0x53, 0x4a, 0x00, 0xc8, 0x00, 0x00, 0xdb, 0x48, 0x05, 0xd8, 0x00, + 0x00, 0x13, 0x00, 0x00, 0xc8, 0x00, 0x00, 0xfb, 0xff, 0xff, 0xdf, 0x00, + 0x00, 0x03, 0x00, 0x00, 0xc0, 0x00, 0x00, 0xfb, 0xff, 0xff, 0xdf, 0x00, + 0x00, 0x13, 0x42, 0x48, 0xc8, 0x00, 0x00, 0x1b, 0x42, 0x78, 0xd8, 0x00, + 0x00, 0x13, 0x42, 0x48, 0xc8, 0x00, 0x00, 0x1b, 0x42, 0x78, 0xd8, 0x00, + 0x00, 0x13, 0x42, 0x48, 0xc8, 0x00, 0x00, 0xfb, 0xff, 0xff, 0xdf, 0x00, + 0x00, 0xf3, 0xff, 0xcf, 0xcf, 0x00, 0x00, 0x1b, 0x42, 0x78, 0xd8, 0x00, + 0x00, 0x13, 0x42, 0x48, 0xc8, 0x00, 0x00, 0x1b, 0x42, 0x78, 0xd8, 0x00, + 0x00, 0x13, 0x42, 0x48, 0xc8, 0x00, 0x00, 0x1b, 0x42, 0x78, 0xd8, 0x00, + 0x00, 0xf3, 0xff, 0xcf, 0xcf, 0x00, 0x00, 0xfb, 0xff, 0xff, 0xdf, 0x00, + 0x00, 0x13, 0x42, 0x48, 0xc8, 0x00, 0x00, 0x1b, 0x42, 0x78, 0xd8, 0x00, + 0x00, 0x13, 0x42, 0x48, 0xc8, 0x00, 0x00, 0x1b, 0x42, 0x78, 0xd8, 0x00, + 0x00, 0x13, 0x42, 0x48, 0xc8, 0x00, 0x00, 0xfb, 0xff, 0xff, 0xdf, 0x00, + 0x00, 0xf3, 0xff, 0xcf, 0xcf, 0x00, 0x00, 0x1b, 0x42, 0x78, 0xd8, 0x00, + 0x00, 0x13, 0x42, 0x48, 0xc8, 0x00, 0x00, 0x1b, 0x42, 0x78, 0xd8, 0x00, + 0x00, 0x13, 0x42, 0x48, 0xc8, 0x00, 0x00, 0x1b, 0x42, 0x78, 0xd8, 0x00, + 0x00, 0xf3, 0xff, 0xcf, 0xcf, 0x00, 0x00, 0xfb, 0xff, 0xff, 0xdf, 0x00, + 0x00, 0x03, 0x00, 0x00, 0xc0, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/xmpanel/src/icons/appEditor.xbm b/xmpanel/src/icons/appEditor.xbm new file mode 100644 index 0000000..e86bf27 --- /dev/null +++ b/xmpanel/src/icons/appEditor.xbm @@ -0,0 +1,27 @@ +#define appEditor_width 48 +#define appEditor_height 48 +static unsigned char appEditor_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x80, 0xff, 0xff, 0xff, 0x01, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0x01, + 0x80, 0x01, 0x00, 0x00, 0x05, 0x01, 0x80, 0x01, 0x00, 0x00, 0x09, 0x01, + 0x80, 0x01, 0x00, 0x00, 0x11, 0x01, 0x80, 0xf1, 0x6f, 0x00, 0x21, 0x01, + 0x80, 0x01, 0x00, 0x00, 0x7f, 0x01, 0x80, 0x71, 0x02, 0x00, 0xfe, 0x01, + 0x80, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x80, 0x91, 0x3f, 0x0f, 0xc0, 0x01, + 0x80, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x80, 0xf1, 0xdc, 0x7b, 0xc0, 0x01, + 0x80, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x80, 0xf1, 0x8f, 0xff, 0xc7, 0x01, + 0x80, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x80, 0x01, 0x00, 0x00, 0xc0, 0x01, + 0x80, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x80, 0x01, 0x00, 0x00, 0xc0, 0x01, + 0x80, 0x71, 0x07, 0x00, 0xc0, 0x01, 0x80, 0x81, 0x00, 0x00, 0xc0, 0x01, + 0x80, 0x81, 0x00, 0x00, 0xc0, 0x01, 0x80, 0x81, 0x00, 0x00, 0xc0, 0x01, + 0x80, 0x81, 0x00, 0x00, 0xc0, 0x01, 0x80, 0x81, 0x00, 0x00, 0xc0, 0x01, + 0x80, 0x81, 0x00, 0x00, 0xc0, 0x01, 0x80, 0x81, 0x00, 0x00, 0xc0, 0x01, + 0x80, 0x81, 0x00, 0x00, 0xc0, 0x01, 0x80, 0x81, 0x00, 0x00, 0xc0, 0x01, + 0x80, 0x81, 0x00, 0x00, 0xc0, 0x01, 0x80, 0x81, 0x00, 0x00, 0xc0, 0x01, + 0x80, 0x71, 0x07, 0x00, 0xc0, 0x01, 0x80, 0x01, 0x00, 0x00, 0xc0, 0x01, + 0x80, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x80, 0x01, 0x00, 0x00, 0xc0, 0x01, + 0x80, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x80, 0x01, 0x00, 0x00, 0xc0, 0x01, + 0x80, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x80, 0x01, 0x00, 0x00, 0xc0, 0x01, + 0x80, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x80, 0x01, 0x00, 0x00, 0xc0, 0x01, + 0x80, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x80, 0xff, 0xff, 0xff, 0xff, 0x01, + 0x80, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/xmpanel/src/icons/appFiles.xbm b/xmpanel/src/icons/appFiles.xbm new file mode 100644 index 0000000..2c6abc3 --- /dev/null +++ b/xmpanel/src/icons/appFiles.xbm @@ -0,0 +1,27 @@ +#define appFiles_width 48 +#define appFiles_height 48 +static unsigned char appFiles_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xfe, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x7f, 0x00, + 0x00, 0x06, 0x00, 0x00, 0x60, 0x00, 0x00, 0xf6, 0xff, 0xff, 0x6f, 0x00, + 0x00, 0x16, 0x00, 0x00, 0x68, 0x00, 0x00, 0x56, 0x00, 0x00, 0x6a, 0x00, + 0x00, 0x16, 0x00, 0x00, 0x68, 0x00, 0x00, 0x16, 0x00, 0x00, 0x68, 0x00, + 0x00, 0x16, 0x00, 0x00, 0x68, 0x00, 0x00, 0x16, 0xf8, 0x1f, 0x68, 0x00, + 0x00, 0x16, 0x08, 0x10, 0x68, 0x00, 0x00, 0x16, 0x08, 0x10, 0x68, 0x00, + 0x00, 0x16, 0xf8, 0x1f, 0x68, 0x00, 0x00, 0x16, 0x00, 0x00, 0x68, 0x00, + 0x00, 0x16, 0x08, 0x10, 0x68, 0x00, 0x00, 0x16, 0xf8, 0x1f, 0x68, 0x00, + 0x00, 0x16, 0x00, 0x00, 0x68, 0x00, 0x00, 0x16, 0x00, 0x00, 0x68, 0x00, + 0x00, 0x56, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x16, 0x00, 0x00, 0x68, 0x00, + 0x00, 0xf6, 0xff, 0xff, 0x6f, 0x00, 0x00, 0x06, 0x00, 0x00, 0x60, 0x00, + 0x00, 0xf6, 0xff, 0xff, 0x6f, 0x00, 0x00, 0x36, 0x00, 0x00, 0x6c, 0x00, + 0x00, 0xf6, 0xff, 0xff, 0x6f, 0x00, 0x00, 0x36, 0x00, 0x00, 0x6c, 0x00, + 0x00, 0xf6, 0xff, 0xff, 0x6f, 0x00, 0x00, 0x16, 0x00, 0x00, 0x68, 0x00, + 0x00, 0x56, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x16, 0x00, 0x00, 0x68, 0x00, + 0x00, 0x16, 0x00, 0x00, 0x68, 0x00, 0x00, 0x16, 0x00, 0x00, 0x68, 0x00, + 0x00, 0x16, 0xf8, 0x1f, 0x68, 0x00, 0x00, 0x16, 0x08, 0x10, 0x68, 0x00, + 0x00, 0x16, 0x08, 0x10, 0x68, 0x00, 0x00, 0x16, 0xf8, 0x1f, 0x68, 0x00, + 0x00, 0x16, 0x00, 0x00, 0x68, 0x00, 0x00, 0x16, 0x08, 0x10, 0x68, 0x00, + 0x00, 0x16, 0xf8, 0x1f, 0x68, 0x00, 0x00, 0x16, 0x00, 0x00, 0x68, 0x00, + 0x00, 0x16, 0x00, 0x00, 0x68, 0x00, 0x00, 0x56, 0x00, 0x00, 0x6a, 0x00, + 0x00, 0x1e, 0x00, 0x00, 0x78, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x7f, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/xmpanel/src/icons/appMail.xbm b/xmpanel/src/icons/appMail.xbm new file mode 100644 index 0000000..2e36954 --- /dev/null +++ b/xmpanel/src/icons/appMail.xbm @@ -0,0 +1,27 @@ +#define appMail_width 48 +#define appMail_height 48 +static unsigned char appMail_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xfc, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x3f, + 0x1c, 0x00, 0x00, 0x00, 0x00, 0x38, 0x2c, 0x00, 0x00, 0x50, 0x55, 0x34, + 0x4c, 0x00, 0x00, 0xa8, 0x00, 0x32, 0x8c, 0x00, 0x00, 0x00, 0x44, 0x31, + 0x0c, 0x01, 0x00, 0x50, 0x81, 0x30, 0x0c, 0x02, 0x00, 0xa8, 0x54, 0x30, + 0x0c, 0x04, 0x00, 0x00, 0x20, 0x30, 0x0c, 0x08, 0x00, 0x00, 0x10, 0x30, + 0x0c, 0x10, 0x00, 0x00, 0x08, 0x30, 0x0c, 0x20, 0x00, 0x00, 0x04, 0x30, + 0x0c, 0x40, 0x00, 0x00, 0x02, 0x30, 0x0c, 0x80, 0x00, 0x00, 0x01, 0x30, + 0x0c, 0x00, 0x01, 0x80, 0x00, 0x30, 0x0c, 0x00, 0x02, 0x40, 0x00, 0x30, + 0x0c, 0x00, 0x06, 0x60, 0x00, 0x30, 0x0c, 0x00, 0x09, 0x90, 0x00, 0x30, + 0x0c, 0x80, 0x10, 0x08, 0x01, 0x30, 0x0c, 0x40, 0x20, 0x04, 0x02, 0x30, + 0x0c, 0x20, 0x40, 0x02, 0x04, 0x30, 0x0c, 0x10, 0x80, 0x01, 0x08, 0x30, + 0x0c, 0x08, 0x00, 0x00, 0x10, 0x30, 0x0c, 0x04, 0x00, 0x00, 0x20, 0x30, + 0x0c, 0x02, 0x00, 0x00, 0x40, 0x30, 0x0c, 0x01, 0x00, 0x00, 0x80, 0x30, + 0x8c, 0x00, 0x00, 0x00, 0x00, 0x31, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x32, + 0x2c, 0x00, 0x00, 0x00, 0x00, 0x34, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x38, + 0xfc, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x3f, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/xmpanel/src/icons/appTerminal.xbm b/xmpanel/src/icons/appTerminal.xbm new file mode 100644 index 0000000..2e0a026 --- /dev/null +++ b/xmpanel/src/icons/appTerminal.xbm @@ -0,0 +1,27 @@ +#define appTerminal_width 48 +#define appTerminal_height 48 +static unsigned char appTerminal_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xc0, 0xff, 0xff, 0xff, 0xff, 0x01, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x03, + 0x60, 0x00, 0x00, 0x00, 0x00, 0x03, 0x60, 0x00, 0x00, 0x00, 0x00, 0x03, + 0x60, 0xfe, 0xff, 0xff, 0x3f, 0x03, 0x60, 0xfe, 0xff, 0xff, 0x3f, 0x03, + 0x60, 0xfe, 0xff, 0xff, 0x3f, 0x03, 0x60, 0x0e, 0xfd, 0xff, 0x3f, 0x03, + 0x60, 0xfe, 0xff, 0xff, 0x3f, 0x03, 0x60, 0x0e, 0x80, 0xf2, 0x3f, 0x03, + 0x60, 0xfe, 0xff, 0xff, 0x3f, 0x03, 0x60, 0x0e, 0xfd, 0xff, 0x3f, 0x03, + 0x60, 0xfe, 0xff, 0xff, 0x3f, 0x03, 0x60, 0x0e, 0xf0, 0xff, 0x3f, 0x03, + 0x60, 0xfe, 0xff, 0xff, 0x3f, 0x03, 0x60, 0xfe, 0xff, 0xff, 0x3f, 0x03, + 0x60, 0xfe, 0xff, 0xff, 0x3f, 0x03, 0x60, 0xfe, 0xff, 0xff, 0x3f, 0x03, + 0x60, 0xfe, 0xff, 0xff, 0x3f, 0x03, 0x60, 0xfe, 0xff, 0xff, 0x3f, 0x03, + 0x60, 0xfe, 0xff, 0xff, 0x3f, 0x03, 0x60, 0xfe, 0xff, 0xff, 0x3f, 0x03, + 0x60, 0xfe, 0xff, 0xff, 0x3f, 0x03, 0x60, 0xfe, 0xff, 0xff, 0x3f, 0x03, + 0x60, 0x00, 0x00, 0x00, 0x00, 0x03, 0x60, 0x00, 0x00, 0x00, 0x00, 0x03, + 0x60, 0x00, 0x00, 0x00, 0x33, 0x03, 0x60, 0x00, 0x00, 0x00, 0x00, 0x03, + 0xe0, 0xff, 0xff, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x01, + 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, + 0xc0, 0xff, 0xff, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x00, 0x00, 0x03, + 0x30, 0x00, 0x00, 0x00, 0x00, 0x06, 0x18, 0x00, 0x00, 0x00, 0x00, 0x0c, + 0x0c, 0xc0, 0xff, 0xff, 0x03, 0x18, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x1f, + 0x0c, 0x00, 0x00, 0x00, 0x00, 0x18, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x1f, + 0xfc, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/xmpanel/src/icons/appWebBrowser.xbm b/xmpanel/src/icons/appWebBrowser.xbm new file mode 100644 index 0000000..5d72c2f --- /dev/null +++ b/xmpanel/src/icons/appWebBrowser.xbm @@ -0,0 +1,27 @@ +#define appWebBrowser_width 48 +#define appWebBrowser_height 48 +static unsigned char appWebBrowser_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0x00, 0xe0, 0x07, 0xe0, 0x07, 0x00, 0x00, 0xf0, 0x18, 0x1c, 0x0f, 0x00, + 0x00, 0xfc, 0xff, 0xfc, 0x3f, 0x00, 0x00, 0x0e, 0x80, 0x07, 0x70, 0x00, + 0x00, 0xff, 0xff, 0xff, 0xef, 0x00, 0x80, 0xf3, 0x00, 0x00, 0xc6, 0x01, + 0xc0, 0x01, 0xff, 0xff, 0x81, 0x03, 0xc0, 0x00, 0x38, 0x10, 0x00, 0x03, + 0x60, 0x00, 0xfc, 0x3f, 0x00, 0x06, 0x70, 0x00, 0x04, 0xc0, 0x00, 0x0e, + 0x30, 0x00, 0xf8, 0xff, 0x03, 0x0c, 0x30, 0x00, 0x10, 0x00, 0x0e, 0x0c, + 0x18, 0x00, 0xf0, 0xff, 0x0f, 0x18, 0x18, 0x00, 0x20, 0x00, 0x0e, 0x18, + 0x18, 0x00, 0xff, 0xff, 0x01, 0x18, 0x0c, 0xff, 0x01, 0x00, 0x01, 0x30, + 0x0c, 0xff, 0xff, 0xff, 0x07, 0x30, 0x0c, 0x01, 0x00, 0x00, 0x02, 0x30, + 0x8c, 0xff, 0xff, 0xff, 0xa1, 0x3f, 0x8c, 0x00, 0x00, 0x18, 0xc0, 0x31, + 0x8c, 0xff, 0xff, 0x0f, 0x00, 0x37, 0x9c, 0x00, 0x00, 0xc8, 0xff, 0x30, + 0xac, 0xff, 0xff, 0xcf, 0xff, 0x31, 0x2c, 0x04, 0x00, 0xc8, 0x80, 0x23, + 0x1c, 0xf8, 0xff, 0xcf, 0x80, 0x06, 0x18, 0x10, 0x00, 0xc8, 0x9c, 0x0c, + 0x18, 0xf0, 0xff, 0xdf, 0x80, 0x18, 0x18, 0x10, 0x00, 0xd0, 0x84, 0x3f, + 0x30, 0xf0, 0xff, 0xdf, 0x00, 0x3f, 0x30, 0x10, 0x00, 0xd0, 0x1c, 0x30, + 0x70, 0xf0, 0xff, 0xdf, 0x00, 0x30, 0x60, 0x10, 0x00, 0xd0, 0x7c, 0x33, + 0xc0, 0xf0, 0xff, 0xdf, 0x00, 0x30, 0xc0, 0x11, 0x00, 0xd0, 0x00, 0x30, + 0x80, 0xf3, 0xff, 0xdf, 0x00, 0x30, 0x00, 0x37, 0x00, 0xd3, 0x00, 0x30, + 0x00, 0xee, 0xff, 0xdd, 0x00, 0x30, 0x00, 0x3c, 0xf8, 0xd8, 0x00, 0x30, + 0x00, 0xf0, 0x0f, 0xc0, 0x00, 0x30, 0x00, 0xe0, 0x07, 0xc0, 0x00, 0x30, + 0x00, 0x00, 0xff, 0xcf, 0xff, 0x3f, 0x00, 0x00, 0xf8, 0xcf, 0xff, 0x3f, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/xmpanel/src/main.c b/xmpanel/src/main.c new file mode 100644 index 0000000..accea8e --- /dev/null +++ b/xmpanel/src/main.c @@ -0,0 +1,75 @@ +#define _XOPEN_SOURCE +#include +#include +#include +#include +#include +#include +#include + +#include "icons/appCalculator.xbm" +#include "icons/appEditor.xbm" +#include "icons/appFiles.xbm" +#include "icons/appMail.xbm" +#include "icons/appTerminal.xbm" +#include "icons/appWebBrowser.xbm" + +typedef struct { + Pixmap icon; + const char * command; +} Launcher; + +void createAllLaunchers (Widget); +Widget createLauncher (Widget, Launcher); +void activateLauncher (Widget, XtPointer, XtPointer); + +XtAppContext application; + +int main (int argc, char *argv[]) { + Widget window = XtVaAppInitialize ( + &application, "Panel", + NULL, 0, + &argc, argv, + NULL, NULL); + + Widget layout = XtVaCreateWidget ( + "layout", xmRowColumnWidgetClass, window, + XmNorientation, XmHORIZONTAL, + NULL); + createAllLaunchers(layout); + + XtManageChild(layout); + XtRealizeWidget(window); + XtAppMainLoop(application); +} + +void createAllLaunchers (Widget parent) { + #define add(name, cmd) createLauncher(parent, (Launcher){\ + .icon = XmdLoadBitmapIcon(parent, app##name),\ + .command = cmd " &"\ + } ); + add(Calculator, "xcalc"); + add(Editor, "nedit"); + add(Files, "caja"); + add(Mail, "nedit"); + add(Terminal, "xterm"); + add(WebBrowser, "firefox"); + #undef add +} + +Widget createLauncher (Widget parent, Launcher launcher) { + Widget button = XtVaCreateManagedWidget ( + "launcher", xmPushButtonWidgetClass, parent, + XmNleftAttachment, XmATTACH_FORM, + XmNlabelType, XmPIXMAP, + XmNlabelPixmap, launcher.icon, + NULL); + XtAddCallback(button, XmNactivateCallback, activateLauncher, (XtPointer)(launcher.command)); + return button; +} + +void activateLauncher (Widget button, XtPointer clientData, XtPointer callData) { + (void)(button); + (void)(callData); + system((char *)(clientData)); +}