diff --git a/src/config.c b/src/config.c index 3c9366e..729bddd 100644 --- a/src/config.c +++ b/src/config.c @@ -11,8 +11,6 @@ #include "infobar.h" #include "util.h" -#define CONFIG_DEFAULT_PATH ".config/wmfs/wmfsrc2" /* tmp */ - static void config_theme(void) { @@ -245,12 +243,14 @@ config_keybind(void) 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(path) == -1) - errx(1, "parsing configuration file (%s) failed.", path); + if(get_conf(W->confpath) == -1) + errx(1, "parsing default configuration file (%s) failed.", W->confpath); + } config_theme(); config_keybind(); @@ -258,6 +258,5 @@ config_init(void) config_bars(); config_rule(); - free(path); free_conf(); } diff --git a/src/screen.c b/src/screen.c index b962a0a..b90f057 100644 --- a/src/screen.c +++ b/src/screen.c @@ -58,6 +58,8 @@ screen_init(void) screen_new(&g, i); } + W->nscreen = n; + XFree(xsi); } else @@ -68,6 +70,7 @@ screen_init(void) g.h = DisplayHeight(W->dpy, W->xscreen); screen_new(&g, 0); + W->nscreen = 1; } } diff --git a/src/tag.c b/src/tag.c index da7be78..55bb676 100644 --- a/src/tag.c +++ b/src/tag.c @@ -41,6 +41,9 @@ tag_new(struct screen *s, char *name) void tag_screen(struct screen *s, struct tag *t) { + if(!t) + t = TAILQ_FIRST(&s->tags); + t->prev = s->seltag; s->seltag = t; diff --git a/src/wmfs.c b/src/wmfs.c index ed5775e..ec485f2 100644 --- a/src/wmfs.c +++ b/src/wmfs.c @@ -307,7 +307,8 @@ wmfs_scan(void) if(!nscreen) { 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 { @@ -472,11 +473,39 @@ uicb_quit(Uicb cmd) int main(int argc, char **argv) { + int i; bool r; (void)argc; 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 ]\n" + " -h Show this page\n" + " -v Show WMFS version\n" + " -C 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 */ if(!(W->dpy = XOpenDisplay(NULL))) { @@ -484,23 +513,6 @@ main(int argc, char **argv) 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 */ wmfs_init(); wmfs_scan(); diff --git a/src/wmfs.h b/src/wmfs.h index e979652..6de0320 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -22,6 +22,7 @@ #include /* Local */ +#define CONFIG_DEFAULT_PATH ".config/wmfs/wmfsrc" #define ButtonMask (ButtonPressMask | ButtonReleaseMask | ButtonMotionMask) #define MouseMask (ButtonMask | PointerMotionMask) @@ -259,6 +260,8 @@ struct rule SLIST_ENTRY(rule) next; }; +#define MAX_PATH_LEN 8192 + struct wmfs { /* X11 stuffs */ @@ -266,12 +269,14 @@ struct wmfs Window root; int xscreen, xdepth; int xmaxw, xmaxh; + int nscreen; Flags numlockmask; #define WMFS_SCAN 0x01 Flags flags; GC gc, rgc; Atom *net_atom; char **argv; + char confpath[MAX_PATH_LEN]; bool running, reload; /* FIFO stuffs */ diff --git a/wmfsrc2 b/wmfsrc similarity index 51% rename from wmfsrc2 rename to wmfsrc index 0bd9d46..51c370d 100644 --- a/wmfsrc2 +++ b/wmfsrc @@ -2,114 +2,95 @@ # WMFS2 configuration file # +# Possible file inclusion: +# @include "file" + +# Multi theme section [themes] - [theme] + # No name mean default # name = "default" font = "fixed" # Bars bars_width = 14 - bars_fg = "#CCCCCC" - bars_bg = "#222222" + bars_fg = "#AABBAA" + bars_bg = "#223322" # Element tags - tags_normal_fg = "#CCCCCC" - tags_normal_bg = "#222222" - tags_sel_fg = "#222222" - tags_sel_bg = "#CCCCCC" - tags_border_color = "#888888" + tags_normal_fg = "#AABBAA" + tags_normal_bg = "#223322" + tags_sel_fg = "#223322" + tags_sel_bg = "#AABBAA" + tags_border_color = "#112211" tags_border_width = 1 # Frame / Client - client_normal_fg = "#CCCCCC" - client_normal_bg = "#222222" - client_sel_fg = "#222222" - client_sel_bg = "#CCCCCC" + client_normal_fg = "#AABBAA" + client_normal_bg = "#223322" + client_sel_fg = "#223322" + client_sel_bg = "#AABBAA" frame_bg = "#555555" - client_titlebar_width = 12 #useless for now + client_titlebar_width = 12 client_border_width = 1 [/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] [bars] # Position: - # 0 Top - # 1 Bottom - # 2 Hide + # + # 0 Top + # 1 Bottom + # 2 Hide # Element type: - # t Tags - # s Statustext + # + # t Tags + # s Statustext (will take available space) [bar] - #name = "default" position = 0 screen = 0 - elements = "ts" - theme = "perso" - [/bar] - - [bar] - name = "bar" - position = 1 - screen = 0 - elements = "st" + elements = "ts" # element order in bar theme = "default" [/bar] +# [bar] +# position = 0 +# screen = 1 +# elements = "ts" +# theme = "default" +# [/bar] + [/bars] [tags] - [tag] screen = 0 name = "one" [/tag] - [tag] screen = 0 name = "two" [/tag] - [tag] screen = 0 name = "three" [/tag] - - [tag] screen = 1 name = "four" [/tag] - [tag] screen = 1 name = "five" [/tag] - - [tag] name = "universal tag" [/tag] + [tag] screen = 0 name = "1" [/tag] + [tag] screen = 0 name = "2" [/tag] + [tag] screen = 0 name = "3" [/tag] + [tag] screen = 0 name = "4" [/tag] + [tag] screen = 0 name = "5" [/tag] + [tag] screen = 0 name = "6" [/tag] + [tag] screen = 0 name = "7" [/tag] [/tags] [rules] [rule] - class = "xterm" - instance = "xterm" -# role = "" -# name = "" - theme = "perso" + instance = "chromium" - tag = 0 + # role = "" + # name = "" + # theme = "default" + + tag = 1 # 2nd tag screen = 0 free = false @@ -121,23 +102,42 @@ [keys] - [key] mod = {"Super"} key = "Return" func = "spawn" cmd = "xterm" [/key] - [key] mod = {"Control","Alt"} key = "q" func = "quit" [/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 = "r" func = "reload" [/key] - [key] mod = {"Super"} key = "1" func = "tag_set" cmd = "0" [/key] - [key] mod = {"Super"} key = "2" func = "tag_set" cmd = "1" [/key] - [key] mod = {"Super"} key = "3" func = "tag_set" cmd = "2" [/key] - [key] mod = {"Super"} key = "s" func = "tag_next" [/key] - [key] mod = {"Super"} key = "a" func = "tag_prev" [/key] - [key] mod = {"Super"} key = "z" func = "tag" cmd = "tag2" [/key] + # Tag manipulation + [key] mod = {"Super"} key = "F1" func = "tag_set" cmd = "0" [/key] + [key] mod = {"Super"} key = "F2" func = "tag_set" cmd = "1" [/key] + [key] mod = {"Super"} key = "F3" func = "tag_set" cmd = "2" [/key] + [key] mod = {"Super"} key = "F4" func = "tag_set" cmd = "3" [/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] # Focus next / prev client and next / prev tabbed client - [key] mod = { "Alt" } key = "Tab" func = "client_focus_next" [/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 = { "Alt" } key = "Tab" func = "client_focus_next" [/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", "Shift" } key = "Tab" func = "client_focus_prev_tab" [/key] # Focus next client with direction @@ -175,6 +175,7 @@ [key] mod = {"Super"} key = "r" func = "layout_rotate_right" [/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 = "p" func = "layout_next_set" [/key]