1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
|
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include "fbiconfig.h"
/* ------------------------------------------------------------------------ */
struct cfg_cmdline fbi_cmd[] = {
{
.letter = 'h',
.cmdline = "help",
.option = { O_HELP },
.value = "1",
.desc = "print this help text",
},{
.letter = 'V',
.cmdline = "version",
.option = { O_VERSION },
.value = "1",
.desc = "print fbi version number",
},{
.cmdline = "store",
.option = { O_WRITECONF },
.value = "1",
.desc = "write cmd line args to config file",
},{
.letter = 'l',
.cmdline = "list",
.option = { O_FILE_LIST },
.needsarg = 1,
.desc = "read image filelist from file <arg>",
},{
.letter = 'P',
.cmdline = "text",
.option = { O_TEXT_MODE },
.value = "1",
.desc = "switch into text reading mode",
},{
.letter = 'a',
.cmdline = "autozoom",
.option = { O_AUTO_ZOOM },
.value = "1",
.desc = "automagically pick useful zoom factor",
},{
/* end of list */
}
};
struct cfg_cmdline fbi_cfg[] = {
{
.cmdline = "autoup",
.option = { O_AUTO_UP },
.yesno = 1,
.desc = " like the above, but upscale only",
},{
.cmdline = "autodown",
.option = { O_AUTO_DOWN },
.yesno = 1,
.desc = " like the above, but downscale only",
},{
.cmdline = "fitwidth",
.option = { O_FIT_WIDTH },
.yesno = 1,
.desc = " use width only for autoscaling",
},{
.letter = 'v',
.cmdline = "verbose",
.option = { O_VERBOSE },
.yesno = 1,
.desc = "show filenames all the time",
},{
.letter = 'u',
.cmdline = "random",
.option = { O_RANDOM },
.yesno = 1,
.desc = "show files in a random order",
},{
.letter = '1',
.cmdline = "once",
.option = { O_ONCE },
.yesno = 1,
.desc = "don't loop (for use with -t)",
},{
.cmdline = "comments",
.option = { O_COMMENTS },
.yesno = 1,
.desc = "display image comments",
},{
.letter = 'e',
.cmdline = "edit",
.option = { O_EDIT },
.yesno = 1,
.desc = "enable editing commands (see man page)",
},{
.cmdline = "backup",
.option = { O_BACKUP },
.yesno = 1,
.desc = " create backup files when editing",
},{
.cmdline = "preserve",
.option = { O_PRESERVE },
.yesno = 1,
.desc = " preserve timestamps when editing",
},{
.cmdline = "readahead",
.option = { O_READ_AHEAD },
.yesno = 1,
.desc = "read ahead images into cache",
},{
.cmdline = "cachemem",
.option = { O_CACHE_MEM },
.needsarg = 1,
.desc = "image cache size in megabytes",
},{
.cmdline = "blend",
.option = { O_BLEND_MSECS },
.needsarg = 1,
.desc = "image blend time in miliseconds",
},{
.letter = 'T',
.cmdline = "vt",
.option = { O_VT },
.needsarg = 1,
.desc = "start on virtual console <arg>",
},{
.letter = 's',
.cmdline = "scroll",
.option = { O_SCROLL },
.needsarg = 1,
.desc = "scroll image by <arg> pixels",
},{
.letter = 't',
.cmdline = "timeout",
.option = { O_TIMEOUT },
.needsarg = 1,
.desc = "load next image after <arg> sec without user input",
},{
.letter = 'r',
.cmdline = "resolution",
.option = { O_PCD_RES },
.needsarg = 1,
.desc = "pick PhotoCD resolution (1..5)",
},{
.letter = 'g',
.cmdline = "gamma",
.option = { O_GAMMA },
.needsarg = 1,
.desc = "set display gamma (doesn't work on all hardware)",
},{
.letter = 'f',
.cmdline = "font",
.option = { O_FONT },
.needsarg = 1,
.desc = "use font <arg> (anything fontconfig accepts)",
},{
.letter = 'd',
.cmdline = "device",
.option = { O_DEVICE },
.needsarg = 1,
.desc = "use framebuffer device <arg>",
},{
.letter = 'm',
.cmdline = "mode",
.option = { O_VIDEO_MODE },
.needsarg = 1,
.desc = "use video mode <arg> (from /etc/fb.modes)",
},{
/* end of list */
}
};
/* ------------------------------------------------------------------------ */
static char *fbi_config = NULL;
static void init_config(void)
{
char *home;
home = getenv("HOME");
if (NULL == home)
return;
fbi_config = malloc(strlen(home) + 16);
sprintf(fbi_config,"%s/.fbirc", home);
}
void fbi_read_config(void)
{
init_config();
if (fbi_config)
cfg_parse_file("config", fbi_config);
}
void fbi_write_config(void)
{
if (fbi_config)
cfg_write_file("config", fbi_config);
}
|