Replace default config path by .config/wmfs/wmfsrc, add option -h -v and -C, new example wmfsrc.

This commit is contained in:
Martin Duquesnoy 2012-01-16 19:40:18 +01:00
parent a9356c834b
commit 3e04fc3bde
6 changed files with 124 additions and 101 deletions

View File

@ -11,8 +11,6 @@
#include "infobar.h" #include "infobar.h"
#include "util.h" #include "util.h"
#define CONFIG_DEFAULT_PATH ".config/wmfs/wmfsrc2" /* tmp */
static void static void
config_theme(void) config_theme(void)
{ {
@ -245,12 +243,14 @@ config_keybind(void)
void void
config_init(void) config_init(void)
{ {
char *path; if(get_conf(W->confpath) == -1)
{
warn("parsing configuration file (%s) failed.", W->confpath);
sprintf(W->confpath, "%s/"CONFIG_DEFAULT_PATH, getenv("HOME"));
xasprintf(&path, "%s/"CONFIG_DEFAULT_PATH, getenv("HOME")); if(get_conf(W->confpath) == -1)
errx(1, "parsing default configuration file (%s) failed.", W->confpath);
if(get_conf(path) == -1) }
errx(1, "parsing configuration file (%s) failed.", path);
config_theme(); config_theme();
config_keybind(); config_keybind();
@ -258,6 +258,5 @@ config_init(void)
config_bars(); config_bars();
config_rule(); config_rule();
free(path);
free_conf(); free_conf();
} }

View File

@ -58,6 +58,8 @@ screen_init(void)
screen_new(&g, i); screen_new(&g, i);
} }
W->nscreen = n;
XFree(xsi); XFree(xsi);
} }
else else
@ -68,6 +70,7 @@ screen_init(void)
g.h = DisplayHeight(W->dpy, W->xscreen); g.h = DisplayHeight(W->dpy, W->xscreen);
screen_new(&g, 0); screen_new(&g, 0);
W->nscreen = 1;
} }
} }

View File

@ -41,6 +41,9 @@ tag_new(struct screen *s, char *name)
void void
tag_screen(struct screen *s, struct tag *t) tag_screen(struct screen *s, struct tag *t)
{ {
if(!t)
t = TAILQ_FIRST(&s->tags);
t->prev = s->seltag; t->prev = s->seltag;
s->seltag = t; s->seltag = t;

View File

@ -307,7 +307,8 @@ wmfs_scan(void)
if(!nscreen) if(!nscreen)
{ {
SLIST_FOREACH(s, &W->h.screen, next) SLIST_FOREACH(s, &W->h.screen, next)
tag_screen(s, TAILQ_FIRST(&s->tags)); if(!TAILQ_EMPTY(&s->tags))
tag_screen(s, TAILQ_FIRST(&s->tags));
} }
else else
{ {
@ -472,11 +473,39 @@ uicb_quit(Uicb cmd)
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
int i;
bool r; bool r;
(void)argc; (void)argc;
W = (struct wmfs*)xcalloc(1, sizeof(struct wmfs)); W = (struct wmfs*)xcalloc(1, sizeof(struct wmfs));
/* Default path ~/.config/wmfs/wmfsrc */
sprintf(W->confpath, "%s/"CONFIG_DEFAULT_PATH, getenv("HOME"));
/* Opt */
while((i = getopt(argc, argv, "hvC:")) != -1)
{
switch(i)
{
case 'h':
printf("usage: %s [-hv] [-C <file>]\n"
" -h Show this page\n"
" -v Show WMFS version\n"
" -C <file> Launch WMFS a specified configuration file\n", argv[0]);
free(W);
exit(EXIT_SUCCESS);
break;
case 'v':
printf("wmfs("WMFS_VERSION") 2 beta\n");
free(W);
exit(EXIT_SUCCESS);
break;
case 'C':
strncpy(W->confpath, optarg, sizeof(W->confpath));
break;
}
}
/* Get X display */ /* Get X display */
if(!(W->dpy = XOpenDisplay(NULL))) if(!(W->dpy = XOpenDisplay(NULL)))
{ {
@ -484,23 +513,6 @@ main(int argc, char **argv)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/* Opt */
/*
int i;
while((i = getopt(argc, argv, "hviC:")) != -1)
{
switch(i)
{
case 'h':
break;
case 'v':
break;
case 'C':
break;
}
}
*/
/* Core */ /* Core */
wmfs_init(); wmfs_init();
wmfs_scan(); wmfs_scan();

View File

@ -22,6 +22,7 @@
#include <X11/Xatom.h> #include <X11/Xatom.h>
/* Local */ /* Local */
#define CONFIG_DEFAULT_PATH ".config/wmfs/wmfsrc"
#define ButtonMask (ButtonPressMask | ButtonReleaseMask | ButtonMotionMask) #define ButtonMask (ButtonPressMask | ButtonReleaseMask | ButtonMotionMask)
#define MouseMask (ButtonMask | PointerMotionMask) #define MouseMask (ButtonMask | PointerMotionMask)
@ -259,6 +260,8 @@ struct rule
SLIST_ENTRY(rule) next; SLIST_ENTRY(rule) next;
}; };
#define MAX_PATH_LEN 8192
struct wmfs struct wmfs
{ {
/* X11 stuffs */ /* X11 stuffs */
@ -266,12 +269,14 @@ struct wmfs
Window root; Window root;
int xscreen, xdepth; int xscreen, xdepth;
int xmaxw, xmaxh; int xmaxw, xmaxh;
int nscreen;
Flags numlockmask; Flags numlockmask;
#define WMFS_SCAN 0x01 #define WMFS_SCAN 0x01
Flags flags; Flags flags;
GC gc, rgc; GC gc, rgc;
Atom *net_atom; Atom *net_atom;
char **argv; char **argv;
char confpath[MAX_PATH_LEN];
bool running, reload; bool running, reload;
/* FIFO stuffs */ /* FIFO stuffs */

View File

@ -2,114 +2,95 @@
# WMFS2 configuration file # WMFS2 configuration file
# #
# Possible file inclusion:
# @include "file"
# Multi theme section
[themes] [themes]
[theme] [theme]
# No name mean default
# name = "default" # name = "default"
font = "fixed" font = "fixed"
# Bars # Bars
bars_width = 14 bars_width = 14
bars_fg = "#CCCCCC" bars_fg = "#AABBAA"
bars_bg = "#222222" bars_bg = "#223322"
# Element tags # Element tags
tags_normal_fg = "#CCCCCC" tags_normal_fg = "#AABBAA"
tags_normal_bg = "#222222" tags_normal_bg = "#223322"
tags_sel_fg = "#222222" tags_sel_fg = "#223322"
tags_sel_bg = "#CCCCCC" tags_sel_bg = "#AABBAA"
tags_border_color = "#888888" tags_border_color = "#112211"
tags_border_width = 1 tags_border_width = 1
# Frame / Client # Frame / Client
client_normal_fg = "#CCCCCC" client_normal_fg = "#AABBAA"
client_normal_bg = "#222222" client_normal_bg = "#223322"
client_sel_fg = "#222222" client_sel_fg = "#223322"
client_sel_bg = "#CCCCCC" client_sel_bg = "#AABBAA"
frame_bg = "#555555" frame_bg = "#555555"
client_titlebar_width = 12 #useless for now client_titlebar_width = 12
client_border_width = 1 client_border_width = 1
[/theme] [/theme]
[theme]
name = "perso"
font = "-*-fixed-bold-*-*-18"
bars_width = 20
bars_fg = "#222222"
bars_bg = "#CCCCCC"
tags_sel_bg = "#33AA33"
tags_normal_fg = "#AA3333"
client_normal_fg = "#CCCCCC"
client_normal_bg = "#222222"
client_sel_fg = "#222222"
client_sel_bg = "#33AA33"
client_titlebar_width = 16
[/theme]
[/themes] [/themes]
[bars] [bars]
# Position: # Position:
# 0 Top #
# 1 Bottom # 0 Top
# 2 Hide # 1 Bottom
# 2 Hide
# Element type: # Element type:
# t Tags #
# s Statustext # t Tags
# s Statustext (will take available space)
[bar] [bar]
#name = "default"
position = 0 position = 0
screen = 0 screen = 0
elements = "ts" elements = "ts" # element order in bar
theme = "perso"
[/bar]
[bar]
name = "bar"
position = 1
screen = 0
elements = "st"
theme = "default" theme = "default"
[/bar] [/bar]
# [bar]
# position = 0
# screen = 1
# elements = "ts"
# theme = "default"
# [/bar]
[/bars] [/bars]
[tags] [tags]
[tag] screen = 0 name = "one" [/tag] [tag] screen = 0 name = "1" [/tag]
[tag] screen = 0 name = "two" [/tag] [tag] screen = 0 name = "2" [/tag]
[tag] screen = 0 name = "three" [/tag] [tag] screen = 0 name = "3" [/tag]
[tag] screen = 0 name = "4" [/tag]
[tag] screen = 1 name = "four" [/tag] [tag] screen = 0 name = "5" [/tag]
[tag] screen = 1 name = "five" [/tag] [tag] screen = 0 name = "6" [/tag]
[tag] screen = 0 name = "7" [/tag]
[tag] name = "universal tag" [/tag]
[/tags] [/tags]
[rules] [rules]
[rule] [rule]
class = "xterm" instance = "chromium"
instance = "xterm"
# role = ""
# name = ""
theme = "perso"
tag = 0 # role = ""
# name = ""
# theme = "default"
tag = 1 # 2nd tag
screen = 0 screen = 0
free = false free = false
@ -121,23 +102,42 @@
[keys] [keys]
[key] mod = {"Super"} key = "Return" func = "spawn" cmd = "xterm" [/key] [key] mod = {"Super"} key = "Return" func = "spawn" cmd = "urxvt || xterm" [/key]
[key] mod = {"Control","Alt"} key = "q" func = "quit" [/key]
[key] mod = {"Control", "Alt"} key = "q" func = "quit" [/key]
[key] mod = {"Control", "Alt"} key = "r" func = "reload" [/key] [key] mod = {"Control", "Alt"} key = "r" func = "reload" [/key]
[key] mod = {"Super"} key = "1" func = "tag_set" cmd = "0" [/key] # Tag manipulation
[key] mod = {"Super"} key = "2" func = "tag_set" cmd = "1" [/key] [key] mod = {"Super"} key = "F1" func = "tag_set" cmd = "0" [/key]
[key] mod = {"Super"} key = "3" func = "tag_set" cmd = "2" [/key] [key] mod = {"Super"} key = "F2" func = "tag_set" cmd = "1" [/key]
[key] mod = {"Super"} key = "s" func = "tag_next" [/key] [key] mod = {"Super"} key = "F3" func = "tag_set" cmd = "2" [/key]
[key] mod = {"Super"} key = "a" func = "tag_prev" [/key] [key] mod = {"Super"} key = "F4" func = "tag_set" cmd = "3" [/key]
[key] mod = {"Super"} key = "z" func = "tag" cmd = "tag2" [/key] [key] mod = {"Super"} key = "F5" func = "tag_set" cmd = "4" [/key]
[key] mod = {"Super"} key = "F6" func = "tag_set" cmd = "5" [/key]
[key] mod = {"Super"} key = "F7" func = "tag_set" cmd = "6" [/key]
[key] mod = {"Super"} key = "F8" func = "tag_set" cmd = "7" [/key]
[key] mod = {"Super", "Shift"} key = "F1" func = "tag_client" cmd = "0" [/key]
[key] mod = {"Super", "Shift"} key = "F2" func = "tag_client" cmd = "1" [/key]
[key] mod = {"Super", "Shift"} key = "F3" func = "tag_client" cmd = "2" [/key]
[key] mod = {"Super", "Shift"} key = "F4" func = "tag_client" cmd = "3" [/key]
[key] mod = {"Super", "Shift"} key = "F5" func = "tag_client" cmd = "4" [/key]
[key] mod = {"Super", "Shift"} key = "F6" func = "tag_client" cmd = "5" [/key]
[key] mod = {"Super", "Shift"} key = "F7" func = "tag_client" cmd = "6" [/key]
[key] mod = {"Super", "Shift"} key = "F8" func = "tag_client" cmd = "7" [/key]
# tag function: cmd = nameofthetag
#[key] mod = {"Super"} key = "z" func = "tag" cmd = "2" [/key]
[key] mod = {"Control"} key = "Right" func = "tag_next" [/key]
[key] mod = {"Control"} key = "Left" func = "tag_prev" [/key]
[key] mod = {"Super"} key = "q" func = "client_close" [/key] [key] mod = {"Super"} key = "q" func = "client_close" [/key]
# Focus next / prev client and next / prev tabbed client # Focus next / prev client and next / prev tabbed client
[key] mod = { "Alt" } key = "Tab" func = "client_focus_next" [/key] [key] mod = { "Alt" } key = "Tab" func = "client_focus_next" [/key]
[key] mod = { "Alt", "Shift" } key = "Tab" func = "client_focus_prev" [/key] [key] mod = { "Alt", "Shift" } key = "Tab" func = "client_focus_prev" [/key]
[key] mod = { "Super" } key = "Tab" func = "client_focus_next_tab" [/key] [key] mod = { "Super" } key = "Tab" func = "client_focus_next_tab" [/key]
[key] mod = { "Super", "Shift" } key = "Tab" func = "client_focus_prev_tab" [/key] [key] mod = { "Super", "Shift" } key = "Tab" func = "client_focus_prev_tab" [/key]
# Focus next client with direction # Focus next client with direction
@ -175,6 +175,7 @@
[key] mod = {"Super"} key = "r" func = "layout_rotate_right" [/key] [key] mod = {"Super"} key = "r" func = "layout_rotate_right" [/key]
[key] mod = {"Super", "Shift"} key = "r" func = "layout_rotate_left" [/key] [key] mod = {"Super", "Shift"} key = "r" func = "layout_rotate_left" [/key]
# Layout set historic travelling function (TESTING)
[key] mod = {"Super"} key = "o" func = "layout_prev_set" [/key] [key] mod = {"Super"} key = "o" func = "layout_prev_set" [/key]
[key] mod = {"Super"} key = "p" func = "layout_next_set" [/key] [key] mod = {"Super"} key = "p" func = "layout_next_set" [/key]