progman.exe^H^H^H^H
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

main: Compile in progman.ini contents, use as defaults

This avoids having to specify any default keybindings in code and if
the user has their own config file, no longer requires them to
override the default keybindings to get rid of them.

+39 -41
+5 -2
Makefile
··· 37 37 #CFLAGS+= -g -DDEBUG=1 38 38 39 39 # uncomment for HiDPI displays 40 - #CFLAGS+= -DHIDPI=1 40 + CFLAGS+= -DHIDPI=1 41 41 42 42 # uncomment to use gdk-pixbuf to rescale icons 43 43 PKGLIBS+= gdk-pixbuf-xlib-2.0 ··· 71 71 72 72 all: $(BIN) 73 73 74 - $(PROGMAN_OBJ): progman.h 74 + $(PROGMAN_OBJ): progman.h progman_ini.h 75 + 76 + progman_ini.h: progman.ini 77 + xxd -i progman.ini > $@ 75 78 76 79 progman: $(PROGMAN_OBJ) 77 80 $(CC) -o $@ $(PROGMAN_OBJ) $(LDFLAGS)
+15 -5
parser.c
··· 24 24 #include <string.h> 25 25 #include "common.h" 26 26 #include "parser.h" 27 + #include "progman_ini.h" 27 28 28 29 /* 29 30 * If the user specifies an ini file, return NULL immediately if it's not 30 31 * found; otherwise, search for the usual suspects. 31 32 */ 32 - 33 33 FILE * 34 34 open_ini(char *inifile) 35 35 { 36 - FILE *ini; 36 + FILE *ini = NULL; 37 37 char buf[BUF_SIZE]; 38 38 39 - if (inifile) 40 - return fopen(inifile, "r"); 39 + if (inifile) { 40 + ini = fopen(inifile, "r"); 41 + if (!ini) 42 + err(1, "can't open config file %s", inifile); 43 + 44 + return ini; 45 + } 41 46 42 47 snprintf(buf, sizeof(buf), "%s/.config/progman/progman.ini", 43 48 getenv("HOME")); 44 49 if ((ini = fopen(buf, "r"))) 45 50 return ini; 46 51 47 - return NULL; 52 + /* load compiled-in defaults */ 53 + ini = fmemopen(progman_ini, sizeof(progman_ini), "r"); 54 + if (!ini || sizeof(progman_ini) == 0) 55 + errx(1, "no compiled-in default config file"); 56 + 57 + return ini; 48 58 } 49 59 50 60 int
+9 -31
progman.c
··· 121 121 122 122 int exitmsg[2]; 123 123 124 + char *opt_config_file = NULL; 124 125 char *opt_font = DEF_FONT; 125 126 char *opt_iconfont = DEF_ICONFONT; 126 127 char *opt_fg = DEF_FG; ··· 140 141 char *opt_launcher = DEF_LAUNCHER; 141 142 142 143 static void cleanup(void); 143 - static void read_config(char *); 144 + static void read_config(void); 144 145 static void setup_display(void); 145 146 146 147 int 147 148 main(int argc, char **argv) 148 149 { 149 150 struct sigaction act; 150 - char *config = NULL; 151 151 int ch; 152 152 153 153 setlocale(LC_ALL, ""); ··· 155 155 while ((ch = getopt(argc, argv, "c:")) != -1) { 156 156 switch (ch) { 157 157 case 'c': 158 - if (config) 159 - free(config); 160 - config = strdup(optarg); 158 + if (opt_config_file) 159 + free(opt_config_file); 160 + opt_config_file = strdup(optarg); 161 161 break; 162 162 default: 163 163 printf("usage: %s [-c <config file>]\n", argv[0]); ··· 174 174 screen = DefaultScreen(dpy); 175 175 root = RootWindow(dpy, screen); 176 176 177 - /* setup default key bindings before config which may override them */ 178 - bind_key("alt+tab", "cycle"); 179 - bind_key("shift+alt+tab", "reverse_cycle"); 180 - bind_key("alt+f4", "close"); 181 - bind_key("alt+1", "desk 0"); 182 - bind_key("alt+2", "desk 1"); 183 - bind_key("alt+3", "desk 2"); 184 - bind_key("alt+4", "desk 3"); 185 - bind_key("alt+5", "desk 4"); 186 - bind_key("alt+6", "desk 5"); 187 - bind_key("alt+7", "desk 6"); 188 - bind_key("alt+8", "desk 7"); 189 - bind_key("alt+9", "desk 8"); 190 - bind_key("alt+0", "desk 9"); 191 - 192 - read_config(config); 193 - 194 - if (config) 195 - free(config); 177 + read_config(); 196 178 197 179 if (pipe2(exitmsg, O_CLOEXEC) != 0) 198 180 err(1, "pipe2"); ··· 212 194 } 213 195 214 196 static void 215 - read_config(char *inifile) 197 + read_config(void) 216 198 { 217 - FILE *ini; 199 + FILE *ini = NULL; 218 200 char *key, *val; 219 201 220 - if (!(ini = open_ini(inifile))) { 221 - if (inifile) 222 - err(1, "can't open config file \"%s\"", inifile); 223 - return; 224 - } 202 + ini = open_ini(opt_config_file); 225 203 226 204 if (find_ini_section(ini, "progman")) { 227 205 while (get_ini_kv(ini, &key, &val)) {
+1
progman.h
··· 298 298 extern Cursor resize_sw_curs; 299 299 extern Cursor resize_ne_curs; 300 300 extern Cursor resize_se_curs; 301 + extern char *opt_config_file; 301 302 extern char *opt_font; 302 303 extern char *opt_iconfont; 303 304 extern char *opt_fg;
+9 -3
progman.ini
··· 33 33 # What to launch when right-clicking the root 34 34 launcher = aemenu 35 35 36 - 37 36 # Custom key bindings can be specified as "Modifier+Key = action". 38 - # Default key bindings can be disabled by specifying a blank action. 39 37 [keyboard] 40 38 Alt+Tab = cycle 41 39 Shift+Alt+Tab = reverse_cycle 42 40 Alt+F4 = close 43 41 Alt+1 = desk 0 42 + Alt+2 = desk 1 43 + Alt+3 = desk 2 44 + Alt+4 = desk 3 45 + Alt+5 = desk 4 46 + Alt+6 = desk 5 47 + Alt+7 = desk 6 48 + Alt+8 = desk 7 49 + Alt+9 = desk 8 50 + Alt+0 = desk 9 44 51 Win+T = exec xterm 45 - 46 52 47 53 [launcher] 48 54 Xterm = xterm