mirror of
https://github.com/0intro/wmii
synced 2024-11-22 05:42:05 +03:00
Update selection and execution of wmiirc.
This commit is contained in:
parent
e1e6794aca
commit
79ad0dd568
1
Makefile
1
Makefile
@ -5,6 +5,7 @@ PDIRS = \
|
||||
cmd \
|
||||
libwmii_hack \
|
||||
rc \
|
||||
alternative_wmiircs \
|
||||
man
|
||||
|
||||
DIRS = \
|
||||
|
20
alternative_wmiircs/Makefile
Normal file
20
alternative_wmiircs/Makefile
Normal file
@ -0,0 +1,20 @@
|
||||
ROOT=..
|
||||
include $(ROOT)/mk/hdr.mk
|
||||
include $(ROOT)/mk/wmii.mk
|
||||
|
||||
BIN = $(ETC)/wmii$(CONFVERSION)
|
||||
TARG = python \
|
||||
plan9port
|
||||
|
||||
$(TARG:%=%.install):
|
||||
echo INSTALL $$($(CLEANNAME) $(BASE)${@:.install=})
|
||||
cp -r ${@:.install=} $(DESTDIR)$(BIN)
|
||||
$(TARG:%=%.uninstall):
|
||||
echo UNINSTALL $$($(CLEANNAME) $(BASE)${@:.uninstall=})
|
||||
rm -rf $(DESTDIR)$(BIN)/${@:.uninstall=}
|
||||
|
||||
.PHONY: $(TARG:%=%.install) $(TARG:%=%.uninstall)
|
||||
|
||||
install: $(TARG:%=%.install)
|
||||
uninstall: $(TARG:%=%.uninstall)
|
||||
|
4
alternative_wmiircs/python/wmiirc
Normal file → Executable file
4
alternative_wmiircs/python/wmiirc
Normal file → Executable file
@ -1,3 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
import os, sys
|
||||
for p in os.environ.get("WMII_CONFPATH", "").split(':'):
|
||||
sys.path += [p, p + '/python']
|
||||
|
||||
import pygmi
|
||||
import wmiirc
|
||||
|
@ -11,8 +11,7 @@ TARG = wihack \
|
||||
wmii.sh \
|
||||
wmii9menu \
|
||||
wmii9rc \
|
||||
wmiir \
|
||||
wmiistartrc
|
||||
wmiir
|
||||
|
||||
OFILES = util.o
|
||||
|
||||
|
@ -317,6 +317,31 @@ strlcatprint(char *buf, int len, const char *fmt, ...) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
char*
|
||||
pathsearch(const char *path, const char *file, bool slashok) {
|
||||
char *orig, *p, *s;
|
||||
|
||||
if(!slashok && strchr(file, '/') > file)
|
||||
file = sxprint("%s/%s", getcwd(buffer, sizeof buffer), file);
|
||||
else if(!strncmp(file, "./", 2))
|
||||
file = sxprint("%s/%s", getcwd(buffer, sizeof buffer), file+2);
|
||||
if(file[0] == '/') {
|
||||
if(access(file, X_OK))
|
||||
return strdup(file);
|
||||
return nil;
|
||||
}
|
||||
|
||||
orig = estrdup(path ? path : getenv("PATH"));
|
||||
for(p=orig; (s=strtok(p, ":")); p=nil) {
|
||||
s = smprint("%s/%s", s, file);
|
||||
if(!access(s, X_OK))
|
||||
break;
|
||||
free(s);
|
||||
}
|
||||
free(orig);
|
||||
return s;
|
||||
}
|
||||
|
||||
int
|
||||
unquote(char *buf, char *toks[], int ntoks) {
|
||||
char *s, *t;
|
||||
|
@ -206,6 +206,7 @@ void update_keys(void);
|
||||
|
||||
/* main.c */
|
||||
void init_screens(void);
|
||||
void spawn_command(const char*);
|
||||
|
||||
/* map.c */
|
||||
void** hash_get(Map*, const char*, bool create);
|
||||
@ -291,6 +292,7 @@ char** comm(int, char**, char**);
|
||||
int doublefork(void);
|
||||
void grep(char**, Reprog*, int);
|
||||
char* join(char**, char*);
|
||||
char* pathsearch(const char*, const char*, bool);
|
||||
void refree(Regex*);
|
||||
void reinit(Regex*, char*);
|
||||
int strlcatprint(char*, int, const char*, ...);
|
||||
|
@ -95,6 +95,9 @@ init_environment(void) {
|
||||
setenv("WMII_ADDRESS", address, true);
|
||||
else
|
||||
address = smprint("unix!%s/wmii", ns_path);
|
||||
setenv("WMII_CONFPATH", sxprint("%s/.wmii%s:%s/wmii%s",
|
||||
getenv("HOME"), CONFVERSION,
|
||||
CONFPREFIX, CONFVERSION), true);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -281,18 +284,21 @@ init_traps(void) {
|
||||
sigaction(SIGUSR2, &sa, nil);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
spawn_command(const char *cmd) {
|
||||
char *shell, *p;
|
||||
|
||||
if((p = pathsearch(getenv("WMII_CONFPATH"), cmd, true)))
|
||||
cmd = p;
|
||||
|
||||
if(doublefork() == 0) {
|
||||
if(setsid() == -1)
|
||||
fatal("Can't setsid: %r");
|
||||
|
||||
/* Run through the user's shell as a login shell */
|
||||
shell = passwd->pw_shell;
|
||||
if(shell[0] != '/')
|
||||
fatal("Shell is not an absolute path: %s", shell);
|
||||
/* Run through the user's shell as a login shell */
|
||||
p = smprint("-%s", strrchr(shell, '/') + 1);
|
||||
|
||||
close(0);
|
||||
@ -300,7 +306,7 @@ spawn_command(const char *cmd) {
|
||||
|
||||
execl(shell, p, "-c", cmd, nil);
|
||||
fatal("Can't exec '%s': %r", cmd);
|
||||
/* Not reached */
|
||||
/* NOTREACHED */
|
||||
}
|
||||
}
|
||||
|
||||
@ -332,7 +338,7 @@ main(int argc, char *argv[]) {
|
||||
extern int fmtevent(Fmt*);
|
||||
fmtinstall('E', fmtevent);
|
||||
|
||||
wmiirc = "wmiistartrc";
|
||||
wmiirc = "wmiirc";
|
||||
|
||||
oargv = argv;
|
||||
ARGBEGIN{
|
||||
@ -380,7 +386,7 @@ extern int fmtevent(Fmt*);
|
||||
closeexec(ConnectionNumber(display));
|
||||
closeexec(sock);
|
||||
|
||||
if(wmiirc)
|
||||
if(wmiirc[0])
|
||||
spawn_command(wmiirc);
|
||||
|
||||
init_traps();
|
||||
|
@ -50,6 +50,7 @@ enum {
|
||||
LSELECT,
|
||||
LSEND,
|
||||
LSLAY,
|
||||
LSPAWN,
|
||||
LSWAP,
|
||||
LTOGGLE,
|
||||
LUP,
|
||||
@ -83,6 +84,7 @@ char *symtab[] = {
|
||||
"select",
|
||||
"send",
|
||||
"slay",
|
||||
"spawn",
|
||||
"swap",
|
||||
"toggle",
|
||||
"up",
|
||||
@ -502,6 +504,9 @@ message_root(void *p, IxpMsg *m) {
|
||||
execstr = strdup(m->pos);
|
||||
srv.running = 0;
|
||||
break;
|
||||
case LSPAWN:
|
||||
spawn_command(m->pos);
|
||||
break;
|
||||
case LFOCUSCOLORS:
|
||||
ret = msg_parsecolors(m, &def.focuscolor);
|
||||
view_update(selview);
|
||||
|
Loading…
Reference in New Issue
Block a user