2008-03-04 20:39:21 +01:00
|
|
|
/*
|
|
|
|
* awesome-menu.c - menu window for awesome
|
|
|
|
*
|
|
|
|
* Copyright © 2008 Julien Danjou <julien@danjou.info>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-04-19 21:24:23 +02:00
|
|
|
/* asprintf() */
|
2008-03-04 20:39:21 +01:00
|
|
|
#define _GNU_SOURCE
|
2008-03-13 15:11:59 +01:00
|
|
|
|
2008-03-18 17:25:57 +01:00
|
|
|
#define CHUNK_SIZE 4096
|
|
|
|
|
2008-03-04 20:39:21 +01:00
|
|
|
#include <getopt.h>
|
|
|
|
|
|
|
|
#include <signal.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
2008-03-08 15:15:26 +01:00
|
|
|
#include <dirent.h>
|
2008-03-09 20:32:25 +01:00
|
|
|
#include <pwd.h>
|
2008-03-08 15:15:26 +01:00
|
|
|
#include <sys/types.h>
|
2008-03-16 19:21:21 +01:00
|
|
|
#include <sys/stat.h>
|
2008-03-13 15:11:59 +01:00
|
|
|
#include <string.h>
|
2008-03-19 13:11:13 +01:00
|
|
|
#include <errno.h>
|
2008-03-04 20:39:21 +01:00
|
|
|
|
2008-03-16 19:21:21 +01:00
|
|
|
#include <X11/Xutil.h>
|
|
|
|
|
2008-03-04 20:39:21 +01:00
|
|
|
#include "common/swindow.h"
|
|
|
|
#include "common/util.h"
|
|
|
|
#include "common/version.h"
|
|
|
|
#include "common/configopts.h"
|
|
|
|
#include "common/xutil.h"
|
2008-03-13 12:06:10 +01:00
|
|
|
#include "common/xscreen.c"
|
2008-03-04 20:39:21 +01:00
|
|
|
|
|
|
|
#define PROGNAME "awesome-menu"
|
|
|
|
|
|
|
|
#define CLEANMASK(mask) (mask & ~(globalconf.numlockmask | LockMask))
|
|
|
|
|
2008-03-31 14:25:59 +02:00
|
|
|
/** awesome-menu run status */
|
2008-03-04 20:39:21 +01:00
|
|
|
typedef enum
|
|
|
|
{
|
2008-03-31 14:25:59 +02:00
|
|
|
/** Stop awesome-menu */
|
2008-03-04 20:39:21 +01:00
|
|
|
STOP = 0,
|
2008-03-31 14:25:59 +02:00
|
|
|
/** Run awesome-menu */
|
2008-03-04 20:39:21 +01:00
|
|
|
RUN = 1,
|
2008-03-31 14:25:59 +02:00
|
|
|
/** Stop awesome-menu and cancel any operation */
|
2008-03-04 20:39:21 +01:00
|
|
|
CANCEL = 2
|
|
|
|
} status_t;
|
|
|
|
|
2008-03-31 14:25:59 +02:00
|
|
|
/** Is awesome-menu running ? */
|
2008-03-04 20:39:21 +01:00
|
|
|
static status_t status = RUN;
|
|
|
|
|
|
|
|
/** Import awesome config file format */
|
|
|
|
extern cfg_opt_t awesome_opts[];
|
|
|
|
|
2008-03-31 14:25:59 +02:00
|
|
|
/** Item_t typedef */
|
2008-03-04 20:39:21 +01:00
|
|
|
typedef struct item_t item_t;
|
2008-03-31 14:25:59 +02:00
|
|
|
/** Item_t structure */
|
2008-03-04 20:39:21 +01:00
|
|
|
struct item_t
|
|
|
|
{
|
2008-03-31 14:25:59 +02:00
|
|
|
/** Data */
|
2008-03-04 20:39:21 +01:00
|
|
|
char *data;
|
2008-03-31 14:25:59 +02:00
|
|
|
/** Previous and next elems in item_t list */
|
2008-03-10 10:37:23 +01:00
|
|
|
item_t *prev, *next;
|
2008-03-31 14:25:59 +02:00
|
|
|
/** True if the item currently matches */
|
2008-03-04 20:39:21 +01:00
|
|
|
Bool match;
|
|
|
|
};
|
|
|
|
|
2008-03-31 14:25:59 +02:00
|
|
|
/** Destructor for item structure
|
|
|
|
* \param item item pointer
|
|
|
|
*/
|
2008-03-08 15:15:26 +01:00
|
|
|
static void
|
|
|
|
item_delete(item_t **item)
|
|
|
|
{
|
|
|
|
p_delete(&(*item)->data);
|
|
|
|
p_delete(item);
|
|
|
|
}
|
|
|
|
|
2008-03-13 15:06:14 +01:00
|
|
|
DO_SLIST(item_t, item, item_delete)
|
2008-03-04 20:39:21 +01:00
|
|
|
|
|
|
|
/** awesome-run global configuration structure */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
/** Display ref */
|
|
|
|
Display *display;
|
|
|
|
/** The window */
|
|
|
|
SimpleWindow *sw;
|
|
|
|
/** The draw contet */
|
|
|
|
DrawCtx *ctx;
|
2008-03-13 14:03:03 +01:00
|
|
|
/** Colors */
|
|
|
|
struct
|
|
|
|
{
|
2008-03-14 08:35:06 +01:00
|
|
|
style_t normal;
|
|
|
|
style_t focus;
|
|
|
|
} styles;
|
2008-03-04 20:39:21 +01:00
|
|
|
/** Numlock mask */
|
|
|
|
unsigned int numlockmask;
|
|
|
|
/** The text */
|
2008-03-18 17:25:57 +01:00
|
|
|
char *text;
|
2008-03-31 15:32:41 +02:00
|
|
|
/** The text when we asked to complete */
|
|
|
|
char *text_complete;
|
2008-03-18 17:25:57 +01:00
|
|
|
/** The text length */
|
|
|
|
size_t text_size;
|
2008-03-04 20:39:21 +01:00
|
|
|
/** Item list */
|
|
|
|
item_t *items;
|
|
|
|
/** Selected item */
|
|
|
|
item_t *item_selected;
|
|
|
|
/** What to do with the result text */
|
|
|
|
char *exec;
|
|
|
|
/** Prompt */
|
|
|
|
char *prompt;
|
|
|
|
} AwesomeMenuConf;
|
|
|
|
|
|
|
|
static AwesomeMenuConf globalconf;
|
|
|
|
|
2008-03-31 14:25:59 +02:00
|
|
|
/** Exit with given exit code
|
|
|
|
* \param exit_code exit code
|
|
|
|
* \return never returns
|
|
|
|
*/
|
2008-03-04 20:39:21 +01:00
|
|
|
static void __attribute__ ((noreturn))
|
|
|
|
exit_help(int exit_code)
|
|
|
|
{
|
|
|
|
FILE *outfile = (exit_code == EXIT_SUCCESS) ? stdout : stderr;
|
2008-03-15 10:20:24 +01:00
|
|
|
fprintf(outfile, "Usage: %s [-c config] [-e command] <message>\n",
|
2008-03-04 20:39:21 +01:00
|
|
|
PROGNAME);
|
|
|
|
exit(exit_code);
|
|
|
|
}
|
|
|
|
|
2008-03-31 14:25:59 +02:00
|
|
|
/** Parse configuration file and fill up AwesomeMenuConf
|
|
|
|
* data structures with configuration directives.
|
|
|
|
* \param screen screen number
|
|
|
|
* \param confpatharg configuration file pathname, or NULL if auto
|
|
|
|
* \param menu_title menu title
|
|
|
|
* \param geometry geometry to fill up with supplied information from
|
|
|
|
* configuration file
|
|
|
|
* \return cfg_parse status
|
|
|
|
*/
|
2008-03-04 20:39:21 +01:00
|
|
|
static int
|
2008-03-14 09:12:03 +01:00
|
|
|
config_parse(int screen, const char *confpatharg,
|
2008-03-14 09:37:25 +01:00
|
|
|
const char *menu_title, area_t *geometry)
|
2008-03-04 20:39:21 +01:00
|
|
|
{
|
2008-03-09 16:00:14 +01:00
|
|
|
int ret, i;
|
2008-03-14 08:35:06 +01:00
|
|
|
char *confpath;
|
2008-03-14 09:12:03 +01:00
|
|
|
cfg_t *cfg, *cfg_menu = NULL, *cfg_screen = NULL,
|
|
|
|
*cfg_styles, *cfg_menu_styles = NULL;
|
2008-03-04 20:39:21 +01:00
|
|
|
|
|
|
|
if(!confpatharg)
|
|
|
|
confpath = config_file();
|
|
|
|
else
|
|
|
|
confpath = a_strdup(confpatharg);
|
|
|
|
|
2008-03-18 13:00:10 +01:00
|
|
|
cfg = cfg_new();
|
2008-03-04 20:39:21 +01:00
|
|
|
|
|
|
|
switch((ret = cfg_parse(cfg, confpath)))
|
|
|
|
{
|
|
|
|
case CFG_FILE_ERROR:
|
2008-03-19 13:11:13 +01:00
|
|
|
warn("parsing configuration file failed: %s\n", strerror(errno));
|
2008-03-04 20:39:21 +01:00
|
|
|
break;
|
|
|
|
case CFG_PARSE_ERROR:
|
2008-03-19 13:11:13 +01:00
|
|
|
cfg_error(cfg, "W: awesome: parsing configuration file %s failed.\n", confpath);
|
2008-03-04 20:39:21 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ret)
|
|
|
|
return ret;
|
|
|
|
|
2008-03-09 16:02:21 +01:00
|
|
|
if(menu_title && !(cfg_menu = cfg_gettsec(cfg, "menu", menu_title)))
|
2008-03-14 09:12:03 +01:00
|
|
|
warn("no definition for menu %s in configuration file: using default\n",
|
|
|
|
menu_title);
|
2008-03-14 08:35:06 +01:00
|
|
|
|
2008-03-09 16:00:14 +01:00
|
|
|
/* get global screen section */
|
2008-03-14 09:12:03 +01:00
|
|
|
if(!(cfg_screen = cfg_getnsec(cfg, "screen", screen)))
|
|
|
|
cfg_screen = cfg_getsec(cfg, "screen");
|
2008-03-09 16:00:14 +01:00
|
|
|
|
|
|
|
if(cfg_menu)
|
|
|
|
{
|
2008-03-14 08:35:06 +01:00
|
|
|
cfg_menu_styles = cfg_getsec(cfg_menu, "styles");
|
2008-03-09 16:00:14 +01:00
|
|
|
if((i = cfg_getint(cfg_menu, "x")) != (int) 0xffffffff)
|
|
|
|
geometry->x = i;
|
|
|
|
if((i = cfg_getint(cfg_menu, "y")) != (int) 0xffffffff)
|
|
|
|
geometry->y = i;
|
|
|
|
if((i = cfg_getint(cfg_menu, "width")) > 0)
|
|
|
|
geometry->width = i;
|
|
|
|
if((i = cfg_getint(cfg_menu, "height")) > 0)
|
|
|
|
geometry->height = i;
|
|
|
|
}
|
|
|
|
|
2008-03-14 08:35:06 +01:00
|
|
|
if(cfg_screen
|
|
|
|
&& (cfg_styles = cfg_getsec(cfg_screen, "styles")))
|
|
|
|
{
|
|
|
|
/* Grab default styles */
|
|
|
|
draw_style_init(globalconf.display, DefaultScreen(globalconf.display),
|
|
|
|
cfg_getsec(cfg_styles, "normal"),
|
|
|
|
&globalconf.styles.normal, NULL);
|
|
|
|
|
|
|
|
draw_style_init(globalconf.display, DefaultScreen(globalconf.display),
|
|
|
|
cfg_getsec(cfg_styles, "focus"),
|
|
|
|
&globalconf.styles.focus, &globalconf.styles.normal);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now grab menu styles if any */
|
|
|
|
if(cfg_menu_styles)
|
|
|
|
{
|
|
|
|
draw_style_init(globalconf.display, DefaultScreen(globalconf.display),
|
|
|
|
cfg_getsec(cfg_menu_styles, "normal"),
|
|
|
|
&globalconf.styles.normal, NULL);
|
|
|
|
|
|
|
|
draw_style_init(globalconf.display, DefaultScreen(globalconf.display),
|
|
|
|
cfg_getsec(cfg_menu_styles, "focus"),
|
|
|
|
&globalconf.styles.focus, &globalconf.styles.normal);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!globalconf.styles.normal.font)
|
|
|
|
eprint("no default font available\n");
|
|
|
|
|
2008-03-04 20:39:21 +01:00
|
|
|
p_delete(&confpath);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-03-31 14:25:59 +02:00
|
|
|
/** Return the last word for a text.
|
|
|
|
* \param text the text to look into
|
|
|
|
* \return a pointer to the last word position in text
|
|
|
|
*/
|
2008-03-08 17:01:45 +01:00
|
|
|
static char *
|
|
|
|
get_last_word(char *text)
|
|
|
|
{
|
|
|
|
char *last_word;
|
|
|
|
|
|
|
|
if((last_word = strrchr(text, ' ')))
|
|
|
|
last_word++;
|
|
|
|
else
|
|
|
|
last_word = text;
|
|
|
|
|
|
|
|
return last_word;
|
|
|
|
}
|
|
|
|
|
2008-03-31 14:25:59 +02:00
|
|
|
/** Fill the completion list for awesome-menu with file list.
|
|
|
|
* \param directory directory to look into
|
|
|
|
* \return always true
|
|
|
|
*/
|
2008-03-09 14:35:53 +01:00
|
|
|
static Bool
|
2008-03-09 14:08:15 +01:00
|
|
|
item_list_fill_file(const char *directory)
|
2008-03-08 15:15:26 +01:00
|
|
|
{
|
2008-03-13 15:11:59 +01:00
|
|
|
char *cwd, *home, *user, *filename;
|
2008-03-09 20:32:25 +01:00
|
|
|
const char *file;
|
2008-03-08 15:15:26 +01:00
|
|
|
DIR *dir;
|
|
|
|
struct dirent *dirinfo;
|
|
|
|
item_t *item;
|
2008-03-09 20:48:34 +01:00
|
|
|
ssize_t len, lenfile;
|
2008-03-09 20:32:25 +01:00
|
|
|
struct passwd *passwd = NULL;
|
2008-03-09 20:48:34 +01:00
|
|
|
struct stat st;
|
2008-03-08 15:15:26 +01:00
|
|
|
|
|
|
|
item_list_wipe(&globalconf.items);
|
|
|
|
|
2008-03-10 11:00:38 +01:00
|
|
|
if(!directory)
|
2008-03-13 15:11:59 +01:00
|
|
|
cwd = a_strdup("./");
|
2008-03-10 11:00:38 +01:00
|
|
|
else if(a_strlen(directory) > 1 && directory[0] == '~')
|
2008-03-09 14:35:53 +01:00
|
|
|
{
|
2008-03-09 20:32:25 +01:00
|
|
|
if(directory[1] == '/')
|
2008-03-09 14:44:33 +01:00
|
|
|
{
|
2008-03-13 15:11:59 +01:00
|
|
|
home = getenv("HOME");
|
|
|
|
asprintf(&cwd, "%s%s", (home ? home : ""), directory + 1);
|
2008-03-09 14:44:33 +01:00
|
|
|
}
|
|
|
|
else
|
2008-03-09 20:32:25 +01:00
|
|
|
{
|
|
|
|
if(!(file = strchr(directory, '/')))
|
|
|
|
file = directory + a_strlen(directory);
|
|
|
|
len = (file - directory) + 1;
|
|
|
|
user = p_new(char, len);
|
|
|
|
a_strncpy(user, len, directory + 1, (file - directory) - 1);
|
|
|
|
if((passwd = getpwnam(user)))
|
|
|
|
{
|
2008-03-13 15:11:59 +01:00
|
|
|
asprintf(&cwd, "%s%s", passwd->pw_dir, file);
|
2008-03-09 20:32:25 +01:00
|
|
|
p_delete(&user);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
p_delete(&user);
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
}
|
2008-03-09 14:35:53 +01:00
|
|
|
}
|
2008-03-08 16:49:33 +01:00
|
|
|
else
|
2008-03-13 15:11:59 +01:00
|
|
|
cwd = a_strdup(directory);
|
2008-03-08 15:15:26 +01:00
|
|
|
|
2008-03-09 14:44:33 +01:00
|
|
|
if(!(dir = opendir(cwd)))
|
2008-03-13 15:11:59 +01:00
|
|
|
{
|
|
|
|
p_delete(&cwd);
|
2008-03-09 14:35:53 +01:00
|
|
|
return False;
|
2008-03-13 15:11:59 +01:00
|
|
|
}
|
2008-03-08 15:15:26 +01:00
|
|
|
|
|
|
|
while((dirinfo = readdir(dir)))
|
|
|
|
{
|
|
|
|
item = p_new(item_t, 1);
|
2008-03-09 20:48:34 +01:00
|
|
|
|
|
|
|
/* + 1 for \0 + 1 for / if directory */
|
|
|
|
len = a_strlen(directory) + a_strlen(dirinfo->d_name) + 2;
|
|
|
|
|
2008-03-08 16:49:33 +01:00
|
|
|
item->data = p_new(char, len);
|
2008-03-09 20:48:34 +01:00
|
|
|
if(a_strlen(directory))
|
2008-03-09 14:44:33 +01:00
|
|
|
a_strcpy(item->data, len, directory);
|
2008-03-08 16:49:33 +01:00
|
|
|
a_strcat(item->data, len, dirinfo->d_name);
|
2008-03-09 20:48:34 +01:00
|
|
|
|
|
|
|
lenfile = a_strlen(cwd) + a_strlen(dirinfo->d_name) + 2;
|
|
|
|
|
|
|
|
filename = p_new(char, lenfile);
|
|
|
|
a_strcpy(filename, lenfile, cwd);
|
|
|
|
a_strcat(filename, lenfile, dirinfo->d_name);
|
|
|
|
|
|
|
|
if(!stat(filename, &st) && S_ISDIR(st.st_mode))
|
|
|
|
a_strcat(item->data, len, "/");
|
|
|
|
|
|
|
|
p_delete(&filename);
|
|
|
|
|
2008-03-08 15:15:26 +01:00
|
|
|
item_list_push(&globalconf.items, item);
|
|
|
|
}
|
|
|
|
|
|
|
|
closedir(dir);
|
2008-03-13 15:11:59 +01:00
|
|
|
p_delete(&cwd);
|
2008-03-09 14:35:53 +01:00
|
|
|
|
|
|
|
return True;
|
2008-03-08 15:15:26 +01:00
|
|
|
}
|
|
|
|
|
2008-03-04 20:39:21 +01:00
|
|
|
static void
|
2008-03-07 11:27:27 +01:00
|
|
|
complete(Bool reverse)
|
2008-03-04 20:39:21 +01:00
|
|
|
{
|
2008-03-09 16:12:18 +01:00
|
|
|
int loop = 2;
|
2008-03-04 20:39:21 +01:00
|
|
|
item_t *item = NULL;
|
2008-03-08 17:02:28 +01:00
|
|
|
item_t *(*item_iter)(item_t **, item_t *) = item_list_next_cycle;
|
2008-03-07 11:27:27 +01:00
|
|
|
|
|
|
|
if(reverse)
|
2008-03-08 17:02:28 +01:00
|
|
|
item_iter = item_list_prev_cycle;
|
2008-03-04 20:39:21 +01:00
|
|
|
|
|
|
|
if(globalconf.item_selected)
|
2008-03-07 11:27:27 +01:00
|
|
|
item = item_iter(&globalconf.items, globalconf.item_selected);
|
2008-03-04 20:39:21 +01:00
|
|
|
else
|
2008-03-09 16:12:18 +01:00
|
|
|
item = globalconf.items;
|
|
|
|
|
|
|
|
for(; item && loop; item = item_iter(&globalconf.items, item))
|
|
|
|
{
|
2008-03-04 20:39:21 +01:00
|
|
|
if(item->match)
|
|
|
|
{
|
2008-03-31 15:32:41 +02:00
|
|
|
a_strcpy(globalconf.text_complete,
|
|
|
|
globalconf.text_size - (globalconf.text_complete - globalconf.text),
|
|
|
|
item->data);
|
2008-03-04 20:39:21 +01:00
|
|
|
globalconf.item_selected = item;
|
|
|
|
return;
|
|
|
|
}
|
2008-03-31 14:25:59 +02:00
|
|
|
/* Since loop is 2, it will be 1 at first iter, and then 0 if we
|
2008-03-09 16:12:18 +01:00
|
|
|
* get back before matching an item (i.e. no items match) to the
|
|
|
|
* first elem: so it will break the loop, otherwise it loops for
|
|
|
|
* ever
|
|
|
|
*/
|
|
|
|
if(item == globalconf.items)
|
|
|
|
loop--;
|
|
|
|
}
|
2008-03-04 20:39:21 +01:00
|
|
|
}
|
|
|
|
|
2008-03-31 14:25:59 +02:00
|
|
|
/** Compute a match from completion list for word.
|
|
|
|
* \param word the word to match
|
|
|
|
*/
|
2008-03-04 20:39:21 +01:00
|
|
|
static void
|
2008-03-09 14:22:05 +01:00
|
|
|
compute_match(const char *word)
|
2008-03-04 20:39:21 +01:00
|
|
|
{
|
2008-03-09 14:22:05 +01:00
|
|
|
ssize_t len = a_strlen(word);
|
2008-03-04 20:39:21 +01:00
|
|
|
item_t *item;
|
|
|
|
|
|
|
|
/* reset the selected item to NULL */
|
|
|
|
globalconf.item_selected = NULL;
|
|
|
|
|
2008-03-09 14:22:05 +01:00
|
|
|
if(len)
|
2008-03-08 16:49:33 +01:00
|
|
|
{
|
2008-03-09 14:22:05 +01:00
|
|
|
if(word[len - 1] == '/'
|
|
|
|
|| word[len - 1] == ' ')
|
|
|
|
item_list_fill_file(word);
|
2008-03-09 14:35:53 +01:00
|
|
|
|
2008-03-08 16:49:33 +01:00
|
|
|
for(item = globalconf.items; item; item = item->next)
|
2008-03-09 14:22:05 +01:00
|
|
|
if(!a_strncmp(word, item->data, a_strlen(word)))
|
2008-03-08 16:49:33 +01:00
|
|
|
item->match = True;
|
|
|
|
else
|
|
|
|
item->match = False;
|
|
|
|
}
|
|
|
|
else
|
2008-03-09 14:22:05 +01:00
|
|
|
{
|
2008-03-09 16:29:42 +01:00
|
|
|
if(a_strlen(globalconf.text))
|
|
|
|
item_list_fill_file(NULL);
|
2008-03-08 16:49:33 +01:00
|
|
|
for(item = globalconf.items; item; item = item->next)
|
2008-03-10 10:37:23 +01:00
|
|
|
item->match = True;
|
2008-03-09 14:22:05 +01:00
|
|
|
}
|
2008-03-04 20:39:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Why not? */
|
|
|
|
#define MARGIN 10
|
|
|
|
|
2008-03-31 14:25:59 +02:00
|
|
|
/** Redraw the menu. */
|
2008-03-04 20:39:21 +01:00
|
|
|
static void
|
|
|
|
redraw(void)
|
|
|
|
{
|
|
|
|
item_t *item;
|
2008-03-14 09:37:25 +01:00
|
|
|
area_t geometry = { 0, 0, 0, 0, NULL, NULL };
|
2008-03-07 11:31:05 +01:00
|
|
|
Bool selected_item_is_drawn = False;
|
2008-03-09 16:36:27 +01:00
|
|
|
int len, prompt_len, x_of_previous_item;
|
2008-03-14 08:35:06 +01:00
|
|
|
style_t style;
|
2008-03-04 20:39:21 +01:00
|
|
|
|
2008-03-07 16:31:31 +01:00
|
|
|
geometry.width = globalconf.sw->geometry.width;
|
|
|
|
geometry.height = globalconf.sw->geometry.height;
|
|
|
|
|
2008-03-09 16:02:21 +01:00
|
|
|
if(a_strlen(globalconf.prompt))
|
|
|
|
{
|
|
|
|
draw_text(globalconf.ctx, geometry, AlignLeft,
|
2008-03-14 08:35:06 +01:00
|
|
|
MARGIN, globalconf.prompt, globalconf.styles.focus);
|
2008-03-04 20:39:21 +01:00
|
|
|
|
2008-03-14 08:35:06 +01:00
|
|
|
len = MARGIN * 2 + draw_textwidth(globalconf.display, globalconf.styles.focus.font, globalconf.prompt);
|
2008-03-09 16:02:21 +01:00
|
|
|
geometry.x += len;
|
|
|
|
geometry.width -= len;
|
|
|
|
}
|
2008-03-04 20:39:21 +01:00
|
|
|
|
|
|
|
draw_text(globalconf.ctx, geometry, AlignLeft,
|
2008-03-14 08:35:06 +01:00
|
|
|
MARGIN, globalconf.text, globalconf.styles.normal);
|
2008-03-04 20:39:21 +01:00
|
|
|
|
2008-03-14 08:35:06 +01:00
|
|
|
len = MARGIN * 2 + MAX(draw_textwidth(globalconf.display, globalconf.styles.normal.font, globalconf.text),
|
2008-03-04 20:39:21 +01:00
|
|
|
geometry.width / 20);
|
|
|
|
geometry.x += len;
|
|
|
|
geometry.width -= len;
|
2008-03-07 11:31:05 +01:00
|
|
|
prompt_len = geometry.x;
|
2008-03-04 20:39:21 +01:00
|
|
|
|
2008-03-09 16:43:02 +01:00
|
|
|
for(item = globalconf.items; item && geometry.width > 0; item = item->next)
|
2008-03-04 20:39:21 +01:00
|
|
|
if(item->match)
|
|
|
|
{
|
2008-03-14 08:35:06 +01:00
|
|
|
style = item == globalconf.item_selected ? globalconf.styles.focus : globalconf.styles.normal;
|
|
|
|
len = MARGIN + draw_textwidth(globalconf.display, style.font, item->data);
|
2008-03-08 10:04:20 +01:00
|
|
|
if(item == globalconf.item_selected)
|
2008-03-09 16:36:27 +01:00
|
|
|
{
|
|
|
|
if(len > geometry.width)
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
selected_item_is_drawn = True;
|
|
|
|
}
|
2008-03-14 08:35:06 +01:00
|
|
|
draw_text(globalconf.ctx, geometry, AlignLeft,
|
|
|
|
MARGIN / 2, item->data, style);
|
2008-03-04 20:39:21 +01:00
|
|
|
geometry.x += len;
|
|
|
|
geometry.width -= len;
|
|
|
|
}
|
|
|
|
|
2008-03-07 11:31:05 +01:00
|
|
|
/* we have an item selected but not drawn, so redraw in the other side */
|
|
|
|
if(globalconf.item_selected && !selected_item_is_drawn)
|
|
|
|
{
|
|
|
|
geometry.x = globalconf.sw->geometry.width;
|
|
|
|
|
2008-03-07 16:31:31 +01:00
|
|
|
for(item = globalconf.item_selected; item; item = item_list_prev(&globalconf.items, item))
|
|
|
|
if(item->match)
|
|
|
|
{
|
2008-03-14 08:35:06 +01:00
|
|
|
style = item == globalconf.item_selected ? globalconf.styles.focus : globalconf.styles.normal;
|
2008-03-07 16:31:31 +01:00
|
|
|
x_of_previous_item = geometry.x;
|
2008-03-14 08:35:06 +01:00
|
|
|
geometry.width = MARGIN + draw_textwidth(globalconf.display, style.font, item->data);
|
2008-03-07 16:31:31 +01:00
|
|
|
geometry.x -= geometry.width;
|
2008-03-07 11:31:05 +01:00
|
|
|
|
2008-03-07 16:31:31 +01:00
|
|
|
if(geometry.x < prompt_len)
|
|
|
|
break;
|
2008-03-07 11:31:05 +01:00
|
|
|
|
2008-03-14 08:35:06 +01:00
|
|
|
draw_text(globalconf.ctx, geometry, AlignLeft,
|
|
|
|
MARGIN / 2, item->data, style);
|
2008-03-07 16:31:31 +01:00
|
|
|
}
|
2008-03-07 11:31:05 +01:00
|
|
|
|
|
|
|
if(item)
|
|
|
|
{
|
|
|
|
geometry.x = prompt_len;
|
|
|
|
geometry.width = x_of_previous_item - prompt_len;
|
2008-03-21 18:02:40 +01:00
|
|
|
draw_rectangle(globalconf.ctx, geometry, 1.0, True, globalconf.styles.normal.bg);
|
2008-03-07 11:31:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(geometry.width)
|
2008-03-21 18:02:40 +01:00
|
|
|
draw_rectangle(globalconf.ctx, geometry, 1.0, True, globalconf.styles.normal.bg);
|
2008-03-04 20:39:21 +01:00
|
|
|
|
|
|
|
simplewindow_refresh_drawable(globalconf.sw, DefaultScreen(globalconf.display));
|
|
|
|
XSync(globalconf.display, False);
|
|
|
|
}
|
|
|
|
|
2008-03-31 14:25:59 +02:00
|
|
|
/** Handle keypress event in awesome-menu.
|
|
|
|
* \param e received XKeyEvent
|
|
|
|
*/
|
2008-03-04 20:39:21 +01:00
|
|
|
static void
|
|
|
|
handle_kpress(XKeyEvent *e)
|
|
|
|
{
|
|
|
|
char buf[32];
|
|
|
|
KeySym ksym;
|
|
|
|
int num;
|
|
|
|
ssize_t len;
|
2008-03-18 17:25:57 +01:00
|
|
|
size_t text_dst_len;
|
2008-03-04 20:39:21 +01:00
|
|
|
|
|
|
|
len = a_strlen(globalconf.text);
|
|
|
|
num = XLookupString(e, buf, sizeof(buf), &ksym, 0);
|
|
|
|
if(e->state & ControlMask)
|
|
|
|
switch(ksym)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
case XK_bracketleft:
|
|
|
|
ksym = XK_Escape;
|
|
|
|
break;
|
|
|
|
case XK_h:
|
|
|
|
case XK_H:
|
|
|
|
ksym = XK_BackSpace;
|
|
|
|
break;
|
|
|
|
case XK_i:
|
|
|
|
case XK_I:
|
|
|
|
ksym = XK_Tab;
|
|
|
|
break;
|
|
|
|
case XK_j:
|
|
|
|
case XK_J:
|
|
|
|
ksym = XK_Return;
|
|
|
|
break;
|
|
|
|
case XK_c:
|
|
|
|
case XK_C:
|
|
|
|
status = CANCEL;
|
|
|
|
break;
|
|
|
|
case XK_w:
|
|
|
|
case XK_W:
|
|
|
|
/* erase word */
|
|
|
|
if(len)
|
|
|
|
{
|
|
|
|
int i = len - 1;
|
|
|
|
while(i >= 0 && globalconf.text[i] == ' ')
|
|
|
|
globalconf.text[i--] = '\0';
|
|
|
|
while(i >= 0 && globalconf.text[i] != ' ')
|
|
|
|
globalconf.text[i--] = '\0';
|
2008-03-09 14:22:05 +01:00
|
|
|
compute_match(get_last_word(globalconf.text));
|
2008-03-04 20:39:21 +01:00
|
|
|
redraw();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if(CLEANMASK(e->state) & Mod1Mask)
|
|
|
|
switch(ksym)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
case XK_h:
|
|
|
|
ksym = XK_Left;
|
|
|
|
break;
|
|
|
|
case XK_l:
|
|
|
|
ksym = XK_Right;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(ksym)
|
|
|
|
{
|
2008-03-31 15:32:41 +02:00
|
|
|
case XK_space:
|
|
|
|
globalconf.text_complete = globalconf.text + a_strlen(globalconf.text) + 1;
|
2008-03-04 20:39:21 +01:00
|
|
|
default:
|
|
|
|
if(num && !iscntrl((int) buf[0]))
|
|
|
|
{
|
2008-03-10 11:00:38 +01:00
|
|
|
if(buf[0] != '/' || globalconf.text[len - 1] != '/')
|
|
|
|
{
|
|
|
|
buf[num] = '\0';
|
2008-03-18 17:25:57 +01:00
|
|
|
|
|
|
|
/* Reallocate text string if needed to hold
|
|
|
|
* concatenation of text and buf */
|
|
|
|
if((text_dst_len = (a_strlen(globalconf.text) + num - 1)) > globalconf.text_size)
|
|
|
|
{
|
|
|
|
globalconf.text_size += ((int) (text_dst_len / globalconf.text_size)) * CHUNK_SIZE;
|
|
|
|
p_realloc(&globalconf.text, globalconf.text_size);
|
|
|
|
}
|
2008-03-18 17:31:13 +01:00
|
|
|
a_strncat(globalconf.text, globalconf.text_size, buf, num);
|
2008-03-10 11:00:38 +01:00
|
|
|
}
|
2008-03-09 14:22:05 +01:00
|
|
|
compute_match(get_last_word(globalconf.text));
|
2008-03-04 20:39:21 +01:00
|
|
|
redraw();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case XK_BackSpace:
|
|
|
|
if(len)
|
|
|
|
{
|
|
|
|
globalconf.text[--len] = '\0';
|
2008-03-09 14:22:05 +01:00
|
|
|
compute_match(get_last_word(globalconf.text));
|
2008-03-04 20:39:21 +01:00
|
|
|
redraw();
|
|
|
|
}
|
|
|
|
break;
|
2008-03-09 16:24:44 +01:00
|
|
|
case XK_ISO_Left_Tab:
|
2008-03-07 11:27:27 +01:00
|
|
|
case XK_Left:
|
|
|
|
complete(True);
|
|
|
|
redraw();
|
|
|
|
break;
|
2008-03-04 20:39:21 +01:00
|
|
|
case XK_Right:
|
|
|
|
case XK_Tab:
|
2008-03-07 11:27:27 +01:00
|
|
|
complete(False);
|
2008-03-04 20:39:21 +01:00
|
|
|
redraw();
|
|
|
|
break;
|
|
|
|
case XK_Escape:
|
|
|
|
status= CANCEL;
|
|
|
|
break;
|
|
|
|
case XK_Return:
|
|
|
|
status = STOP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-19 21:24:23 +02:00
|
|
|
#ifndef HAVE_GETLINE
|
|
|
|
static int
|
|
|
|
getline(char ** buf, size_t* len, FILE* in)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
if (*buf) {
|
|
|
|
p_delete(buf);
|
|
|
|
(*buf) = NULL;
|
|
|
|
}
|
|
|
|
if (*len)
|
|
|
|
*len = 0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
p_realloc(buf, *len + 10);
|
|
|
|
(*len) += 10;
|
|
|
|
for (i = 0; i < 10 && !feof(in); i++) {
|
|
|
|
(*buf)[*len - 10 + i] = getchar();
|
|
|
|
if ((*buf)[*len - 10 + i] == '\n' ||
|
|
|
|
(*buf)[*len - 10 + i] == '\r') {
|
|
|
|
return (*len - 10 + i + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while(!feof(in));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-03-31 14:25:59 +02:00
|
|
|
/** Fill the completion by reading on stdin.
|
|
|
|
* \return true if something has been filled up, false otherwise.
|
|
|
|
*/
|
2008-03-08 15:15:26 +01:00
|
|
|
static Bool
|
|
|
|
item_list_fill_stdin(void)
|
2008-03-04 20:39:21 +01:00
|
|
|
{
|
2008-03-13 15:11:59 +01:00
|
|
|
char *buf = NULL;
|
|
|
|
size_t len = 0;
|
|
|
|
ssize_t line_len;
|
|
|
|
|
2008-03-04 20:39:21 +01:00
|
|
|
item_t *newitem;
|
2008-03-08 15:15:26 +01:00
|
|
|
Bool has_entry = False;
|
2008-03-04 20:39:21 +01:00
|
|
|
|
|
|
|
item_list_init(&globalconf.items);
|
|
|
|
|
2008-03-13 15:11:59 +01:00
|
|
|
if((line_len = getline(&buf, &len, stdin)) != -1)
|
2008-03-08 15:15:26 +01:00
|
|
|
has_entry = True;
|
|
|
|
|
|
|
|
if(has_entry)
|
|
|
|
do
|
|
|
|
{
|
2008-03-13 15:11:59 +01:00
|
|
|
buf[line_len - 1] = '\0';
|
2008-03-08 15:15:26 +01:00
|
|
|
newitem = p_new(item_t, 1);
|
|
|
|
newitem->data = a_strdup(buf);
|
|
|
|
newitem->match = True;
|
|
|
|
item_list_append(&globalconf.items, newitem);
|
|
|
|
}
|
2008-03-13 15:11:59 +01:00
|
|
|
while((line_len = getline(&buf, &len, stdin)) != -1);
|
|
|
|
|
|
|
|
if(buf)
|
|
|
|
p_delete(&buf);
|
2008-03-08 15:15:26 +01:00
|
|
|
|
|
|
|
return has_entry;
|
2008-03-04 20:39:21 +01:00
|
|
|
}
|
|
|
|
|
2008-04-01 16:43:18 +02:00
|
|
|
/** Grab the keyboard.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
keyboard_grab(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for(i = 1000; i; i--)
|
|
|
|
{
|
|
|
|
if(XGrabKeyboard(globalconf.display, DefaultRootWindow(globalconf.display), True,
|
|
|
|
GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess)
|
|
|
|
break;
|
|
|
|
usleep(1000);
|
|
|
|
}
|
|
|
|
if(!i)
|
|
|
|
eprint("cannot grab keyboard");
|
|
|
|
}
|
|
|
|
|
2008-03-31 14:25:59 +02:00
|
|
|
/** Main function of awesome-menu.
|
|
|
|
* \param argc number of elements in argv
|
|
|
|
* \param argv arguments array
|
|
|
|
* \return EXIT_SUCCESS
|
|
|
|
*/
|
2008-03-04 20:39:21 +01:00
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
XEvent ev;
|
2008-03-14 09:12:03 +01:00
|
|
|
int opt, ret, x, y, i, screen = 0;
|
2008-03-04 20:39:21 +01:00
|
|
|
char *configfile = NULL, *cmd;
|
|
|
|
ssize_t len;
|
|
|
|
const char *shell = getenv("SHELL");
|
2008-03-14 09:37:25 +01:00
|
|
|
area_t geometry = { 0, 0, 0, 0, NULL, NULL };
|
2008-03-13 12:06:10 +01:00
|
|
|
ScreensInfo *si;
|
|
|
|
unsigned int ui;
|
|
|
|
Window dummy;
|
2008-03-04 20:39:21 +01:00
|
|
|
static struct option long_options[] =
|
|
|
|
{
|
|
|
|
{"help", 0, NULL, 'h'},
|
|
|
|
{"version", 0, NULL, 'v'},
|
|
|
|
{"exec", 0, NULL, 'e'},
|
|
|
|
{NULL, 0, NULL, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
while((opt = getopt_long(argc, argv, "vhf:b:x:y:n:c:e:",
|
|
|
|
long_options, NULL)) != -1)
|
|
|
|
switch(opt)
|
|
|
|
{
|
|
|
|
case 'v':
|
|
|
|
eprint_version(PROGNAME);
|
|
|
|
break;
|
|
|
|
case 'h':
|
|
|
|
exit_help(EXIT_SUCCESS);
|
|
|
|
break;
|
|
|
|
case 'c':
|
|
|
|
configfile = a_strdup(optarg);
|
|
|
|
break;
|
|
|
|
case 'e':
|
|
|
|
globalconf.exec = a_strdup(optarg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(argc - optind >= 1)
|
|
|
|
globalconf.prompt = a_strdup(argv[optind]);
|
|
|
|
|
2008-03-25 16:56:47 +01:00
|
|
|
if(!(globalconf.display = XOpenDisplay(NULL)))
|
|
|
|
eprint("unable to open display");
|
|
|
|
|
2008-03-04 20:39:21 +01:00
|
|
|
/* Get the numlock mask */
|
2008-03-25 16:56:47 +01:00
|
|
|
globalconf.numlockmask = xgetnumlockmask(globalconf.display);
|
2008-03-04 20:39:21 +01:00
|
|
|
|
2008-03-25 16:56:47 +01:00
|
|
|
si = screensinfo_new(globalconf.display);
|
2008-03-13 12:06:10 +01:00
|
|
|
if(si->xinerama_is_active)
|
2008-03-07 16:31:31 +01:00
|
|
|
{
|
2008-03-25 16:56:47 +01:00
|
|
|
if(XQueryPointer(globalconf.display, RootWindow(globalconf.display, DefaultScreen(globalconf.display)),
|
2008-03-14 09:12:03 +01:00
|
|
|
&dummy, &dummy, &x, &y, &i, &i, &ui))
|
|
|
|
{
|
|
|
|
screen = screen_get_bycoord(si, 0, x, y);
|
2008-03-07 16:31:31 +01:00
|
|
|
|
2008-03-14 09:12:03 +01:00
|
|
|
geometry.x = si->geometry[screen].x;
|
|
|
|
geometry.y = si->geometry[screen].y;
|
|
|
|
geometry.width = si->geometry[screen].width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-25 16:56:47 +01:00
|
|
|
screen = DefaultScreen(globalconf.display);
|
2008-03-09 16:00:14 +01:00
|
|
|
if(!geometry.width)
|
2008-03-25 16:56:47 +01:00
|
|
|
geometry.width = DisplayWidth(globalconf.display, DefaultScreen(globalconf.display));
|
2008-03-07 16:31:31 +01:00
|
|
|
}
|
2008-03-14 09:12:03 +01:00
|
|
|
|
|
|
|
if((ret = config_parse(screen, configfile, globalconf.prompt, &geometry)))
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* Init the geometry */
|
|
|
|
if(!geometry.height)
|
|
|
|
geometry.height = 1.5 * MAX(globalconf.styles.normal.font->height,
|
|
|
|
globalconf.styles.focus.font->height);
|
2008-03-04 20:39:21 +01:00
|
|
|
|
2008-03-13 12:06:10 +01:00
|
|
|
screensinfo_delete(&si);
|
|
|
|
|
2008-03-04 20:39:21 +01:00
|
|
|
/* Create the window */
|
2008-03-25 16:56:47 +01:00
|
|
|
globalconf.sw = simplewindow_new(globalconf.display, DefaultScreen(globalconf.display),
|
2008-03-04 20:39:21 +01:00
|
|
|
geometry.x, geometry.y, geometry.width, geometry.height, 0);
|
|
|
|
|
2008-03-25 16:56:47 +01:00
|
|
|
XStoreName(globalconf.display, globalconf.sw->window, PROGNAME);
|
2008-03-04 20:39:21 +01:00
|
|
|
|
|
|
|
/* Create the drawing context */
|
2008-03-25 16:56:47 +01:00
|
|
|
globalconf.ctx = draw_context_new(globalconf.display, DefaultScreen(globalconf.display),
|
2008-03-04 20:39:21 +01:00
|
|
|
geometry.width, geometry.height,
|
|
|
|
globalconf.sw->drawable);
|
|
|
|
|
2008-03-18 17:25:57 +01:00
|
|
|
/* Allocate a default size for the text on the heap instead of
|
|
|
|
* using stack allocation with PATH_MAX (may not been defined
|
|
|
|
* according to POSIX). This string size may be increased if
|
|
|
|
* needed */
|
2008-03-31 15:32:41 +02:00
|
|
|
globalconf.text_complete = globalconf.text = p_new(char, CHUNK_SIZE);
|
2008-03-18 17:25:57 +01:00
|
|
|
globalconf.text_size = CHUNK_SIZE;
|
2008-03-04 20:39:21 +01:00
|
|
|
|
2008-04-01 16:43:18 +02:00
|
|
|
if(isatty(STDIN_FILENO))
|
2008-03-09 12:25:20 +01:00
|
|
|
{
|
2008-04-01 16:43:18 +02:00
|
|
|
if(!item_list_fill_stdin())
|
|
|
|
item_list_fill_file(NULL);
|
|
|
|
keyboard_grab();
|
2008-03-09 12:25:20 +01:00
|
|
|
}
|
2008-04-01 16:43:18 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
keyboard_grab();
|
|
|
|
if(!item_list_fill_stdin())
|
|
|
|
item_list_fill_file(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
compute_match(NULL);
|
2008-03-04 20:39:21 +01:00
|
|
|
|
|
|
|
redraw();
|
|
|
|
|
2008-03-31 15:50:29 +02:00
|
|
|
XMapRaised(globalconf.display, globalconf.sw->window);
|
|
|
|
|
2008-03-04 20:39:21 +01:00
|
|
|
while(status == RUN)
|
|
|
|
{
|
2008-03-25 16:56:47 +01:00
|
|
|
XNextEvent(globalconf.display, &ev);
|
2008-03-04 20:39:21 +01:00
|
|
|
switch(ev.type)
|
|
|
|
{
|
|
|
|
case ButtonPress:
|
|
|
|
status = CANCEL;
|
|
|
|
break;
|
|
|
|
case KeyPress:
|
|
|
|
handle_kpress(&ev.xkey);
|
|
|
|
break;
|
|
|
|
case Expose:
|
|
|
|
if(!ev.xexpose.count)
|
2008-03-25 16:56:47 +01:00
|
|
|
simplewindow_refresh_drawable(globalconf.sw, DefaultScreen(globalconf.display));
|
2008-03-04 20:39:21 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(status != CANCEL)
|
|
|
|
{
|
|
|
|
if(!globalconf.exec)
|
|
|
|
printf("%s\n", globalconf.text);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(!shell)
|
|
|
|
shell = a_strdup("/bin/sh");
|
|
|
|
len = a_strlen(globalconf.exec) + a_strlen(globalconf.text) + 1;
|
|
|
|
cmd = p_new(char, len);
|
|
|
|
a_strcpy(cmd, len, globalconf.exec);
|
|
|
|
a_strcat(cmd, len, globalconf.text);
|
|
|
|
execl(shell, shell, "-c", cmd, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-18 17:25:57 +01:00
|
|
|
p_delete(&globalconf.text);
|
2008-03-21 11:26:56 +01:00
|
|
|
draw_context_delete(&globalconf.ctx);
|
|
|
|
simplewindow_delete(&globalconf.sw);
|
2008-03-25 16:56:47 +01:00
|
|
|
XCloseDisplay(globalconf.display);
|
2008-03-04 20:39:21 +01:00
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|