rename last jdwm to awesome and make config a little more robust
This commit is contained in:
parent
0f4fbc51cc
commit
baa1e422fe
|
@ -29,8 +29,8 @@
|
|||
* To understand everything else, start reading main.c:main().
|
||||
*/
|
||||
|
||||
#ifndef JDWM_JDWM_H
|
||||
#define JDWM_JDWM_H
|
||||
#ifndef AWESOME_AWESOME_H
|
||||
#define AWESOME_AWESOME_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
|
4
client.c
4
client.c
|
@ -312,7 +312,7 @@ loadprops(Client * c, int ntags)
|
|||
|
||||
prop = p_new(char, ntags + 2);
|
||||
|
||||
if(gettextprop(c->display, c->win, JDWMPROPS_ATOM(c->display), prop, ntags + 2))
|
||||
if(gettextprop(c->display, c->win, AWESOMEPROPS_ATOM(c->display), prop, ntags + 2))
|
||||
{
|
||||
for(i = 0; i < ntags && prop[i]; i++)
|
||||
if((c->tags[i] = prop[i] == '1'))
|
||||
|
@ -511,7 +511,7 @@ saveprops(Client * c, int ntags)
|
|||
|
||||
prop[++i] = '\0';
|
||||
|
||||
XChangeProperty(c->display, c->win, JDWMPROPS_ATOM(c->display), XA_STRING, 8,
|
||||
XChangeProperty(c->display, c->win, AWESOMEPROPS_ATOM(c->display), XA_STRING, 8,
|
||||
PropModeReplace, (unsigned char *) prop, i);
|
||||
|
||||
p_delete(&prop);
|
||||
|
|
4
client.h
4
client.h
|
@ -1,7 +1,7 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
#ifndef JDWM_CLIENT_H
|
||||
#define JDWM_CLIENT_H
|
||||
#ifndef AWESOME_CLIENT_H
|
||||
#define AWESOME_CLIENT_H
|
||||
|
||||
/* mask shorthands, used in event.c and client.c */
|
||||
#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
|
||||
|
|
98
config.c
98
config.c
|
@ -167,6 +167,9 @@ set_default_config(awesome_config *awesomeconf)
|
|||
strcpy(awesomeconf->statustext, "awesome-" VERSION);
|
||||
awesomeconf->statusbar.width = 0;
|
||||
awesomeconf->statusbar.height = 0;
|
||||
awesomeconf->opacity_unfocused = -1;
|
||||
awesomeconf->nkeys = 0;
|
||||
awesomeconf->nrules = 0;
|
||||
}
|
||||
|
||||
/** Parse configuration file and initialize some stuff
|
||||
|
@ -181,59 +184,70 @@ parse_config(Display * disp, int scr, DC * drawcontext, awesome_config *awesomec
|
|||
config_setting_t *conflayouts, *confsublayouts;
|
||||
config_setting_t *confrules, *confsubrules;
|
||||
config_setting_t *confkeys, *confsubkeys, *confkeysmasks, *confkeymaskelem;
|
||||
int i, j;
|
||||
int i = 0, j = 0;
|
||||
double f = 0.0;
|
||||
const char *tmp, *homedir;
|
||||
char *confpath;
|
||||
KeySym tmp_key;
|
||||
|
||||
set_default_config(awesomeconf);
|
||||
|
||||
homedir = getenv("HOME");
|
||||
confpath = p_new(char, strlen(homedir) + strlen(JDWM_CONFIG_FILE) + 2);
|
||||
confpath = p_new(char, strlen(homedir) + strlen(AWESOME_CONFIG_FILE) + 2);
|
||||
strcpy(confpath, homedir);
|
||||
strcat(confpath, "/");
|
||||
strcat(confpath, JDWM_CONFIG_FILE);
|
||||
strcat(confpath, AWESOME_CONFIG_FILE);
|
||||
|
||||
config_init(&awesomelibconf);
|
||||
|
||||
if(config_read_file(&awesomelibconf, confpath) == CONFIG_FALSE)
|
||||
eprint("error parsing configuration file at line %d: %s\n",
|
||||
eprint("awesome: error parsing configuration file at line %d: %s\n",
|
||||
config_error_line(&awesomelibconf), config_error_text(&awesomelibconf));
|
||||
|
||||
/* font */
|
||||
initfont(config_lookup_string(&awesomelibconf, "awesome.font"), disp, drawcontext);
|
||||
tmp = config_lookup_string(&awesomelibconf, "awesome.font");
|
||||
initfont(tmp ? tmp : "-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*", disp, drawcontext);
|
||||
|
||||
/* layouts */
|
||||
conflayouts = config_lookup(&awesomelibconf, "awesome.layouts");
|
||||
|
||||
if(!conflayouts)
|
||||
eprint("layouts not found in configuration file\n");
|
||||
|
||||
fprintf(stderr, "layouts not found in configuration file\n");
|
||||
else
|
||||
{
|
||||
awesomeconf->nlayouts = config_setting_length(conflayouts);
|
||||
awesomeconf->layouts = p_new(Layout, awesomeconf->nlayouts + 1);
|
||||
for(i = 0; (confsublayouts = config_setting_get_elem(conflayouts, i)); i++)
|
||||
{
|
||||
awesomeconf->layouts[i].symbol = config_setting_get_string_elem(confsublayouts, 0);
|
||||
awesomeconf->layouts[i].arrange =
|
||||
name_func_lookup(config_setting_get_string_elem(confsublayouts, 1), LayoutsList);
|
||||
if(!awesomeconf->layouts[i].arrange)
|
||||
eprint("unknown layout in configuration file\n");
|
||||
{
|
||||
fprintf(stderr, "awesome: unknown layout #%d in configuration file\n", i);
|
||||
awesomeconf->layouts[i].symbol = NULL;
|
||||
continue;
|
||||
}
|
||||
awesomeconf->layouts[i].symbol = config_setting_get_string_elem(confsublayouts, 0);
|
||||
|
||||
j = textw(awesomeconf->layouts[i].symbol);
|
||||
if(j > awesomeconf->statusbar.width)
|
||||
awesomeconf->statusbar.width = j;
|
||||
}
|
||||
|
||||
awesomeconf->layouts[i].symbol = NULL;
|
||||
awesomeconf->layouts[i].arrange = NULL;
|
||||
}
|
||||
|
||||
|
||||
if(!awesomeconf->layouts[0].arrange)
|
||||
eprint("awesome: fatal: no default layout available\n");
|
||||
/** \todo put this in set_default_layout */
|
||||
awesomeconf->current_layout = awesomeconf->layouts;
|
||||
|
||||
/* tags */
|
||||
conftags = config_lookup(&awesomelibconf, "awesome.tags");
|
||||
|
||||
if(!conftags)
|
||||
eprint("tags not found in configuration file\n");
|
||||
|
||||
eprint("awesome: fatal: no tags found in configuration file\n");
|
||||
awesomeconf->ntags = config_setting_length(conftags);
|
||||
awesomeconf->tags = p_new(const char *, awesomeconf->ntags);
|
||||
awesomeconf->selected_tags = p_new(Bool, awesomeconf->ntags);
|
||||
|
@ -257,8 +271,9 @@ parse_config(Display * disp, int scr, DC * drawcontext, awesome_config *awesomec
|
|||
confrules = config_lookup(&awesomelibconf, "awesome.rules");
|
||||
|
||||
if(!confrules)
|
||||
eprint("rules not found in configuration file\n");
|
||||
|
||||
fprintf(stderr, "awesome: no rules found in configuration file\n");
|
||||
else
|
||||
{
|
||||
awesomeconf->nrules = config_setting_length(confrules);
|
||||
awesomeconf->rules = p_new(Rule, awesomeconf->nrules);
|
||||
for(i = 0; (confsubrules = config_setting_get_elem(confrules, i)); i++)
|
||||
|
@ -270,9 +285,11 @@ parse_config(Display * disp, int scr, DC * drawcontext, awesome_config *awesomec
|
|||
awesomeconf->rules[i].isfloating =
|
||||
config_setting_get_bool(config_setting_get_member(confsubrules, "float"));
|
||||
}
|
||||
}
|
||||
|
||||
/* modkey */
|
||||
awesomeconf->modkey = key_mask_lookup(config_lookup_string(&awesomelibconf, "awesome.modkey"));
|
||||
tmp_key = key_mask_lookup(config_lookup_string(&awesomelibconf, "awesome.modkey"));
|
||||
awesomeconf->modkey = tmp_key ? tmp_key : Mod1Mask;
|
||||
|
||||
/* find numlock mask */
|
||||
awesomeconf->numlockmask = get_numlockmask(disp);
|
||||
|
@ -281,8 +298,9 @@ parse_config(Display * disp, int scr, DC * drawcontext, awesome_config *awesomec
|
|||
confkeys = config_lookup(&awesomelibconf, "awesome.keys");
|
||||
|
||||
if(!confkeys)
|
||||
eprint("keys not found in configuration file\n");
|
||||
|
||||
fprintf(stderr, "awesome: no keys found in configuration file\n");
|
||||
else
|
||||
{
|
||||
awesomeconf->nkeys = config_setting_length(confkeys);
|
||||
awesomeconf->keys = p_new(Key, awesomeconf->nkeys);
|
||||
|
||||
|
@ -296,16 +314,20 @@ parse_config(Display * disp, int scr, DC * drawcontext, awesome_config *awesomec
|
|||
name_func_lookup(config_setting_get_string_elem(confsubkeys, 2), KeyfuncList);
|
||||
awesomeconf->keys[i].arg = config_setting_get_string_elem(confsubkeys, 3);
|
||||
}
|
||||
}
|
||||
|
||||
/* barpos */
|
||||
tmp = config_lookup_string(&awesomelibconf, "awesome.barpos");
|
||||
|
||||
if(!strncmp(tmp, "BarTop", 6))
|
||||
awesomeconf->statusbar_default_position = BarTop;
|
||||
if(tmp)
|
||||
{
|
||||
if(!strncmp(tmp, "BarOff", 6))
|
||||
awesomeconf->statusbar_default_position = BarOff;
|
||||
else if(!strncmp(tmp, "BarBot", 6))
|
||||
awesomeconf->statusbar_default_position = BarBot;
|
||||
else if(!strncmp(tmp, "BarOff", 6))
|
||||
awesomeconf->statusbar_default_position = BarOff;
|
||||
}
|
||||
else
|
||||
awesomeconf->statusbar_default_position = BarTop;
|
||||
|
||||
awesomeconf->statusbar.position = awesomeconf->statusbar_default_position;
|
||||
|
||||
|
@ -318,26 +340,38 @@ parse_config(Display * disp, int scr, DC * drawcontext, awesome_config *awesomec
|
|||
awesomeconf->opacity_unfocused = -1;
|
||||
|
||||
/* snap */
|
||||
awesomeconf->snap = config_lookup_int(&awesomelibconf, "awesome.snap");
|
||||
i = config_lookup_int(&awesomelibconf, "awesome.snap");
|
||||
awesomeconf->snap = i ? i : 8;
|
||||
|
||||
/* nmaster */
|
||||
awesomeconf->nmaster = config_lookup_int(&awesomelibconf, "awesome.nmaster");
|
||||
i = config_lookup_int(&awesomelibconf, "awesome.nmaster");
|
||||
awesomeconf->nmaster = i ? i : 1;
|
||||
|
||||
/* mwfact */
|
||||
awesomeconf->mwfact = config_lookup_float(&awesomelibconf, "awesome.mwfact");
|
||||
f = config_lookup_float(&awesomelibconf, "awesome.mwfact");
|
||||
awesomeconf->mwfact = f ? f : 0.6;
|
||||
|
||||
/* resize_hints */
|
||||
awesomeconf->resize_hints = config_lookup_float(&awesomelibconf, "awesome.resize_hints");
|
||||
|
||||
/* colors */
|
||||
dc.norm[ColBorder] = initcolor(config_lookup_string(&awesomelibconf, "awesome.normal_border_color"),
|
||||
disp, scr);
|
||||
dc.norm[ColBG] = initcolor(config_lookup_string(&awesomelibconf, "awesome.normal_bg_color"), disp, scr);
|
||||
dc.norm[ColFG] = initcolor(config_lookup_string(&awesomelibconf, "awesome.normal_fg_color"), disp, scr);
|
||||
dc.sel[ColBorder] = initcolor(config_lookup_string(&awesomelibconf, "awesome.focus_border_color"),
|
||||
disp, scr);
|
||||
dc.sel[ColBG] = initcolor(config_lookup_string(&awesomelibconf, "awesome.focus_bg_color"), disp, scr);
|
||||
dc.sel[ColFG] = initcolor(config_lookup_string(&awesomelibconf, "awesome.focus_fg_color"), disp, scr);
|
||||
tmp = config_lookup_string(&awesomelibconf, "awesome.normal_border_color");
|
||||
dc.norm[ColBorder] = initcolor(tmp ? tmp : "#dddddd", disp, scr);
|
||||
|
||||
tmp = config_lookup_string(&awesomelibconf, "awesome.normal_bg_color");
|
||||
dc.norm[ColBG] = initcolor(tmp ? tmp : "#000000", disp, scr);
|
||||
|
||||
tmp = config_lookup_string(&awesomelibconf, "awesome.normal_fg_color");
|
||||
dc.norm[ColFG] = initcolor(tmp ? tmp : "#ffffff", disp, scr);
|
||||
|
||||
tmp = config_lookup_string(&awesomelibconf, "awesome.focus_border_color");
|
||||
dc.sel[ColBorder] = initcolor(tmp ? tmp : "#008b8b", disp, scr);
|
||||
|
||||
tmp = config_lookup_string(&awesomelibconf, "awesome.focus_bg_color");
|
||||
dc.sel[ColBG] = initcolor(tmp ? tmp : "#008b8b", disp, scr);
|
||||
|
||||
tmp = config_lookup_string(&awesomelibconf, "awesome.focus_fg_color");
|
||||
dc.sel[ColFG] = initcolor(tmp ? tmp : "#ffffff", disp, scr);
|
||||
|
||||
p_delete(&confpath);
|
||||
}
|
||||
|
|
6
config.h
6
config.h
|
@ -1,9 +1,9 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
#ifndef JDWM_CONFIG_H
|
||||
#define JDWM_CONFIG_H
|
||||
#ifndef AWESOME_CONFIG_H
|
||||
#define AWESOME_CONFIG_H
|
||||
|
||||
#define JDWM_CONFIG_FILE ".awesomerc"
|
||||
#define AWESOME_CONFIG_FILE ".awesomerc"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
|
|
4
draw.h
4
draw.h
|
@ -1,7 +1,7 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
#ifndef JDWM_DRAW_H
|
||||
#define JDWM_DRAW_H
|
||||
#ifndef AWESOME_DRAW_H
|
||||
#define AWESOME_DRAW_H
|
||||
|
||||
#include <string.h>
|
||||
#include "config.h"
|
||||
|
|
4
event.h
4
event.h
|
@ -1,7 +1,7 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
#ifndef JDWM_EVENT_H
|
||||
#define JDWM_EVENT_H
|
||||
#ifndef AWESOME_EVENT_H
|
||||
#define AWESOME_EVENT_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
|
4
layout.c
4
layout.c
|
@ -79,7 +79,7 @@ loadawesomeprops(Display *disp, awesome_config * awesomeconf)
|
|||
|
||||
prop = p_new(char, awesomeconf->ntags + 1);
|
||||
|
||||
if(gettextprop(disp, DefaultRootWindow(disp), JDWMPROPS_ATOM(disp), prop, awesomeconf->ntags + 1))
|
||||
if(gettextprop(disp, DefaultRootWindow(disp), AWESOMEPROPS_ATOM(disp), prop, awesomeconf->ntags + 1))
|
||||
for(i = 0; i < awesomeconf->ntags && prop[i]; i++)
|
||||
awesomeconf->selected_tags[i] = prop[i] == '1';
|
||||
|
||||
|
@ -130,7 +130,7 @@ saveawesomeprops(Display *disp, awesome_config *awesomeconf)
|
|||
prop[i] = awesomeconf->selected_tags[i] ? '1' : '0';
|
||||
prop[i] = '\0';
|
||||
XChangeProperty(disp, DefaultRootWindow(disp),
|
||||
JDWMPROPS_ATOM(disp), XA_STRING, 8,
|
||||
AWESOMEPROPS_ATOM(disp), XA_STRING, 8,
|
||||
PropModeReplace, (unsigned char *) prop, i);
|
||||
p_delete(&prop);
|
||||
}
|
||||
|
|
6
layout.h
6
layout.h
|
@ -1,14 +1,14 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
#ifndef JDWM_LAYOUT_H
|
||||
#define JDWM_LAYOUT_H
|
||||
#ifndef AWESOME_LAYOUT_H
|
||||
#define AWESOME_LAYOUT_H
|
||||
|
||||
#include "client.h"
|
||||
|
||||
/** Check if current layout is arranged with a layout */
|
||||
#define IS_ARRANGE(layout) (layout == awesomeconf->current_layout->arrange)
|
||||
|
||||
#define JDWMPROPS_ATOM(disp) XInternAtom(disp, "_JDWM_PROPERTIES", False)
|
||||
#define AWESOMEPROPS_ATOM(disp) XInternAtom(disp, "_AWESOME_PROPERTIES", False)
|
||||
|
||||
void arrange(Display *, awesome_config *); /* arranges all windows depending on the layout in use */
|
||||
void restack(Display *, awesome_config *); /* restores z layers of all clients */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
#ifndef JDWM_FLOATING_H
|
||||
#define JDWM_FLOATING_H
|
||||
#ifndef AWESOME_FLOATING_H
|
||||
#define AWESOME_FLOATING_H
|
||||
|
||||
void floating(Display *, awesome_config *); /* floating layout */
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
#ifndef JDWM_GRID_H
|
||||
#define JDWM_GRID_H
|
||||
#ifndef AWESOME_GRID_H
|
||||
#define AWESOME_GRID_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
#ifndef JDWM_SPIRAL_H
|
||||
#define JDWM_SPIRAL_H
|
||||
#ifndef AWESOME_SPIRAL_H
|
||||
#define AWESOME_SPIRAL_H
|
||||
|
||||
void dwindle(Display *, awesome_config *); /* dwindle windows */
|
||||
void spiral(Display *, awesome_config *); /* spiral windows */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
#ifndef JDWM_TILE_H
|
||||
#define JDWM_TILE_H
|
||||
#ifndef AWESOME_TILE_H
|
||||
#define AWESOME_TILE_H
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
|
4
tag.h
4
tag.h
|
@ -1,7 +1,7 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
#ifndef JDWM_TAG_H
|
||||
#define JDWM_TAG_H
|
||||
#ifndef AWESOME_TAG_H
|
||||
#define AWESOME_TAG_H
|
||||
|
||||
#include <regex.h>
|
||||
#include "client.h"
|
||||
|
|
Loading…
Reference in New Issue