ViWMFS: Add viwmfs.c.
This commit is contained in:
parent
1dce5bae3b
commit
14762210c1
@ -44,6 +44,7 @@ set(wmfs_src
|
|||||||
src/screen.c
|
src/screen.c
|
||||||
src/tag.c
|
src/tag.c
|
||||||
src/util.c
|
src/util.c
|
||||||
|
src/viwmfs.c
|
||||||
src/wmfs.c)
|
src/wmfs.c)
|
||||||
|
|
||||||
# Set the executable from the wmfs_src
|
# Set the executable from the wmfs_src
|
||||||
|
|||||||
@ -388,4 +388,10 @@ typedef struct
|
|||||||
uint button;
|
uint button;
|
||||||
} name_to_uint_t;
|
} name_to_uint_t;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
char *cmd;
|
||||||
|
char *uicb;
|
||||||
|
} vicmd_to_uicb;
|
||||||
|
|
||||||
#endif /* STRUCTS_H */
|
#endif /* STRUCTS_H */
|
||||||
|
|||||||
96
src/viwmfs.c
Normal file
96
src/viwmfs.c
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
* viwmfs.c
|
||||||
|
* Copyright © 2008, 2009 Martin Duquesnoy <xorg62@gmail.com>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are
|
||||||
|
* met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above
|
||||||
|
* copyright notice, this list of conditions and the following disclaimer
|
||||||
|
* in the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* * Neither the name of the nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "wmfs.h"
|
||||||
|
|
||||||
|
vicmd_to_uicb vicmd[] =
|
||||||
|
{
|
||||||
|
{"r", "reload"},
|
||||||
|
{"q", "quit"},
|
||||||
|
{"t", "tag"},
|
||||||
|
{"tn", "tag_next"},
|
||||||
|
{"tp", "tag_prev"},
|
||||||
|
{"ln", "layout_next"},
|
||||||
|
{"lp", "layout_prev"},
|
||||||
|
{"s", "screen_select"},
|
||||||
|
{"screen", "screen_select"},
|
||||||
|
{"sn", "screen_next"},
|
||||||
|
{"sp", "screen_prev"},
|
||||||
|
{"cc", "client_kill"},
|
||||||
|
{"ct", "tag_transfert"},
|
||||||
|
{"client_transfert", "tag_transfert"},
|
||||||
|
{"cn", "client_next"},
|
||||||
|
{"cp", "client_prev"},
|
||||||
|
{"csn", "client_swap_next"},
|
||||||
|
{"csp", "client_swap_prev"},
|
||||||
|
{"tm", "toggle_max"},
|
||||||
|
{"tf", "toggle_free"},
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
viwmfs(char *str)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char *cmd;
|
||||||
|
Bool e;
|
||||||
|
|
||||||
|
if(!str)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(*str == ':')
|
||||||
|
{
|
||||||
|
++str;
|
||||||
|
|
||||||
|
cmd = _strdup(str);
|
||||||
|
for(i = 0; cmd[i] != ' ' && cmd[i] != '\0'; ++i);
|
||||||
|
cmd[i] = '\0';
|
||||||
|
|
||||||
|
for(i = 0; i < LEN(vicmd); ++i)
|
||||||
|
if(!strncmp(cmd, vicmd[i].cmd, strlen(cmd)))
|
||||||
|
{
|
||||||
|
exec_uicb_function(vicmd[i].uicb, str + strlen(cmd));
|
||||||
|
e = True;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!e)
|
||||||
|
{
|
||||||
|
cmd = _strdup(str);
|
||||||
|
for(i = 0; cmd[i] != ' '; ++i);
|
||||||
|
cmd[i] = '\0';
|
||||||
|
|
||||||
|
exec_uicb_function(cmd, str + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
12
src/wmfs.c
12
src/wmfs.c
@ -352,11 +352,11 @@ main(int argc, char **argv)
|
|||||||
argv_global = _strdup(argv[0]);
|
argv_global = _strdup(argv[0]);
|
||||||
sprintf(conf.confpath, "%s/"DEF_CONF, getenv("HOME"));
|
sprintf(conf.confpath, "%s/"DEF_CONF, getenv("HOME"));
|
||||||
|
|
||||||
while((i = getopt(argc, argv, "hvic:s:g:C:")) != -1)
|
while((i = getopt(argc, argv, "hvic:s:g:C:V:")) != -1)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* For options who need WMFS running */
|
/* For options who need WMFS running */
|
||||||
if((i == 'c' || i == 's' || i == 'g')
|
if((i == 'c' || i == 's' || i == 'g' || i == 'V')
|
||||||
&& !(dpy = XOpenDisplay(NULL)))
|
&& !(dpy = XOpenDisplay(NULL)))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "WMFS: cannot open X server.\n");
|
fprintf(stderr, "WMFS: cannot open X server.\n");
|
||||||
@ -367,11 +367,12 @@ main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
case 'h':
|
case 'h':
|
||||||
default:
|
default:
|
||||||
printf("usage: %s [-ihv] [-C <file>] [-c <uicb function> <cmd> ] [-g <argument>] [-s <string>]\n"
|
printf("usage: %s [-ihv] [-C <file>] [-c <uicb function> <cmd> ] [-g <argument>] [-s <string>] [-V <viwmfs cmd]\n"
|
||||||
" -C <file> Load a configuration file\n"
|
" -C <file> Load a configuration file\n"
|
||||||
" -c <uicb_function> <cmd> Execute an uicb function to control WMFS\n"
|
" -c <uicb_function> <cmd> Execute an uicb function to control WMFS\n"
|
||||||
" -g <argument> Show information about wmfs status\n"
|
" -g <argument> Show information about wmfs status\n"
|
||||||
" -s <string> Set the bar(s) statustext\n"
|
" -s <string> Set the bar(s) statustext\n"
|
||||||
|
" -V <viwmfs cmd> Manage WMFS with vi-like command\n"
|
||||||
" -h Show this page\n"
|
" -h Show this page\n"
|
||||||
" -i Show informations\n"
|
" -i Show informations\n"
|
||||||
" -v Show WMFS version\n", argv[0]);
|
" -v Show WMFS version\n", argv[0]);
|
||||||
@ -413,6 +414,11 @@ main(int argc, char **argv)
|
|||||||
XCloseDisplay(dpy);
|
XCloseDisplay(dpy);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
break;
|
break;
|
||||||
|
case 'V':
|
||||||
|
viwmfs(optarg);
|
||||||
|
XCloseDisplay(dpy);
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -317,6 +317,9 @@ void getinfo_mwfact(void);
|
|||||||
void getinfo_nmaster(void);
|
void getinfo_nmaster(void);
|
||||||
void getinfo(char *info);
|
void getinfo(char *info);
|
||||||
|
|
||||||
|
/* viwmfs.c */
|
||||||
|
void viwmfs(char *str);
|
||||||
|
|
||||||
/* wmfs.c */
|
/* wmfs.c */
|
||||||
int errorhandler(Display *d, XErrorEvent *event);
|
int errorhandler(Display *d, XErrorEvent *event);
|
||||||
int errorhandlerdummy(Display *d, XErrorEvent *event);
|
int errorhandlerdummy(Display *d, XErrorEvent *event);
|
||||||
|
|||||||
7
wmfs.1
7
wmfs.1
@ -13,7 +13,7 @@
|
|||||||
.SH "NAME"
|
.SH "NAME"
|
||||||
wmfs \- Window Manager From Scratch
|
wmfs \- Window Manager From Scratch
|
||||||
.SH "SYNOPSIS"
|
.SH "SYNOPSIS"
|
||||||
\fBwmfs\fR [\fB\-ihv\fR] [\fB\-C <file>\fR] [\fB\-c <uicb_function> <cmd>\fR] [\fB\-g <argument>\fR] [\fB\-s <string>\fR]
|
\fBwmfs\fR [\fB\-ihv\fR] [\fB\-C <file>\fR] [\fB\-c <uicb_function> <cmd>\fR] [\fB\-g <argument>\fR] [\fB\-s <string>\fR] [\fB\-V <viwmfs cmd>\fR]
|
||||||
.sp
|
.sp
|
||||||
.SH "DESCRIPTION"
|
.SH "DESCRIPTION"
|
||||||
\fBWMFS\fR is a basic, lightweight and dynamic tiling windows manager for X\&.
|
\fBWMFS\fR is a basic, lightweight and dynamic tiling windows manager for X\&.
|
||||||
@ -40,6 +40,11 @@ Show information about wmfs status\&.
|
|||||||
Set the bar(s) statustext\&.
|
Set the bar(s) statustext\&.
|
||||||
.RE
|
.RE
|
||||||
.PP
|
.PP
|
||||||
|
\fB\-V <viwmfs cmd>\fR
|
||||||
|
.RS 4
|
||||||
|
Manage WMFS with vi-like command\&.
|
||||||
|
.RE
|
||||||
|
.PP
|
||||||
\fB\-v\fR
|
\fB\-v\fR
|
||||||
.RS 4
|
.RS 4
|
||||||
Print version information to standard output, then exit\&.
|
Print version information to standard output, then exit\&.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user