Put user settable config in separate file.

This commit is contained in:
QC 2014-01-26 13:29:38 +01:00
parent 2b453668e7
commit bd33e93e16
4 changed files with 64 additions and 33 deletions

View File

@ -11,16 +11,16 @@ MAN_DIR?=$(PREFIX)/share/man/man1
MAN_PAGE=$(PROGRAM).1
BUILD_DIR=build
SOURCE_DIR=source
CONFIG_DIR=config
DOC_DIR=doc
BUILD_DIR=build
SOURCES=$(wildcard $(SOURCE_DIR)/*.c)
OBJECTS=$(SOURCES:$(SOURCE_DIR)/%.c=$(BUILD_DIR)/%.o)
SOURCES=$(wildcard $(SOURCE_DIR)/*.c $(CONFIG_DIR)/*.c )
OBJECTS=$(SOURCES:%.c=$(BUILD_DIR)/%.o)
HEADERS=$(wildcard include/*.h)
OTHERS=Makefile LICENSE README.md
INSTALL_MANPAGE_PATH=$(MAN_DIR)/$(MAN_PAGE).gz
INSTALL_PROGRAM=$(BIN_DIR)/$(PROGRAM)
@ -69,9 +69,11 @@ all: $(BUILD_DIR)/$(PROGRAM)
$(BUILD_DIR):
$(info Creating build dir)
$(QUIET)mkdir -p $@
$(QUIET)mkdir -p $@/$(SOURCE_DIR)
$(QUIET)mkdir -p $@/$(CONFIG_DIR)
# Objects depend on header files and makefile too.
$(BUILD_DIR)/%.o: $(SOURCE_DIR)/%.c | Makefile $(HEADERS) $(BUILD_DIR)
$(BUILD_DIR)/%.o: %.c | Makefile $(HEADERS) $(BUILD_DIR)
$(info Compiling $^ -> $@)
$(QUIET) $(CC) $(CFLAGS) -c -o $@ $^

54
config/config.c Normal file
View File

@ -0,0 +1,54 @@
/**
* simpleswitcher
*
* MIT/X11 License
* Modified 2013-2014 Qball Cow <qball@gmpclient.org>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "simpleswitcher.h"
Settings config = {
// Window settings
.window_opacity = 100,
// Menu settings
.menu_bw = 1,
.menu_width = 50,
.menu_lines = 15,
.menu_font = "mono-12",
.menu_fg = "#222222",
.menu_bg = "#f2f1f0",
.menu_bgalt = "#e9e8e7",
.menu_hlfg = "#ffffff",
.menu_hlbg = "#005577",
.menu_bc = "black",
// Behavior
.zeltak_mode = 0,
.terminal_emulator = "x-terminal-emulator",
.i3_mode = 0,
// Key binding
.window_key = "F12",
.run_key = "mod1+F2",
.ssh_key = "mod1+F3",
.location = CENTER,
.wmode = VERTICAL,
.inner_margin = 5
};

View File

@ -1,7 +1,7 @@
#ifndef __SIMPLESWITCHER_H__
#define __SIMPLESWITCHER_H__
#include <basedir.h>
#include <X11/X.h>
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

View File

@ -59,6 +59,8 @@
#include <i3/ipc.h>
#endif
#include <basedir.h>
#include "simpleswitcher.h"
#include "run-dialog.h"
#include "ssh-dialog.h"
@ -73,33 +75,6 @@ xdgHandle xdg_handle;
const char *cache_dir = NULL;
Settings config = {
// Window settings
.window_opacity = 100,
// Menu settings
.menu_bw = 1,
.menu_width = 50,
.menu_lines = 15,
.menu_font = "mono-12",
.menu_fg = "#222222",
.menu_bg = "#f2f1f0",
.menu_bgalt = "#e9e8e7",
.menu_hlfg = "#ffffff",
.menu_hlbg = "#005577",
.menu_bc = "black",
// Behavior
.zeltak_mode = 0,
.terminal_emulator = "x-terminal-emulator",
.i3_mode = 0,
// Key binding
.window_key = "F12",
.run_key = "mod1+F2",
.ssh_key = "mod1+F3",
.location = CENTER,
.wmode = VERTICAL,
.inner_margin = 5
};
void* allocate( unsigned long bytes )
{