A simple launcher 06/01/21 ------------------------------------------------------------ I enjoy the ability to launch things simply. I want something like dmenu, but haven't found it yet. the bar program doesn't work for me... It compiles and runs, but won't launch anything, no matter what I do. I settled for the solution below, which I called launch.c... if you've looked at the source for bar, you'll see I lifted their placement function (modified to only one placement). Before I paste launch.c, let me tell you how I use it. I created $home/bin/rc/launcher, an rc script, which takes the output from launch and runs stuff with it. This means I can use any keyboard key (launch reports the keycode), to launch any program etc. awk takes the stdout and uses it to launch. In practice, I have a square at the top-right where I can click, then hit a key to launch a few things. Here's the rc script, followed by launch.c: #!/bin/rc # launcher script for use with launch launch \ | awk ' /116/ {system("window -dx 600 -dy 400")} /102/ {system("fsterm")} /110/ {system("window -dx 1000 -dy 700 netsurf")} /97/ {system("window -dx 1000 -dy 600 acme")} ' /* begin launch.c */ #include #include #include #include #include #define MAX(a,b) ((a)>=(b)?(a):(b)) enum { Off = 3, }; static int wctl, width=100, height=100; void eresized(int new) { if(new&& getwindow(display, Refnone) < 0) sysfatal("can't reattach to window"); } static void place(void) { int w, h, minx, miny, maxx, maxy; char t[64]; fprint(wctl, "top"); w = Dx(display->image->r); h = Dy(display->image->r); miny = 0; maxy = height; minx = MAX(100, w-(Borderwidth+Off+width+Off+Borderwidth)); maxx = w; snprint(t, sizeof(t), "resize -r %d %d %d %d", minx, miny, maxx, maxy); write(wctl, "current", 7); if(fprint(wctl, "%s", t) < 0) fprint(2, "%s: %r\n", t); } void main(int argc, char* argv[]) { USED(argc, argv); Event ev; int e; initdraw(0,0, "Launch"); eresized(0); einit(Ekeyboard); if((wctl = open("/dev/wctl", ORDWR)) < 0) sysfatal("%r"); place(); for(;;) { e = event(&ev); if(e == Ekeyboard) { print("%d\n", ev.kbdc); if(ev.kbdc == 27) { print("Escaped\n"); break; } } } } /* end launch.c */