load configuration optionally

This commit is contained in:
speedie 2023-03-13 21:31:13 +01:00
parent af4c682814
commit 522ea5d50d
7 changed files with 32 additions and 1 deletions

View file

@ -95,6 +95,9 @@ See a list below for a list.
- spmenu -ic - Position the image in the center - spmenu -ic - Position the image in the center
- spmenu -itc - Position the image in the top center - spmenu -itc - Position the image in the top center
- spmenu -wm - Spawn spmenu as a window manager controlled client - spmenu -wm - Spawn spmenu as a window manager controlled client
- spmenu -nwm - Don't spawn spmenu as a window manager controlled client
- spmenu -lcfg - Load spmenu configuration (~/.spmenu or ~/.config/spmenu/spmenurc)
- spmenu -ncfg - Don't load spmenu configuration (~/.spmenu or ~/.config/spmenu/spmenurc)
- spmenu -v - Print spmenu version to stdout - spmenu -v - Print spmenu version to stdout
- spmenu -fn font - Set the spmenu font to font - spmenu -fn font - Set the spmenu font to font

View file

@ -60,6 +60,8 @@ spmenu.preselected: 0
spmenu.type: 1 spmenu.type: 1
spmenu.class: spmenu spmenu.class: spmenu
spmenu.mon: -1 spmenu.mon: -1
spmenu.managed: 0
spmenu.loadconfig: 0
spmenu.leftarrow: < spmenu.leftarrow: <
spmenu.rightarrow: > spmenu.rightarrow: >
spmenu.password: . spmenu.password: .

View file

@ -14,6 +14,11 @@ readargs(int argc, char *argv[])
} }
if (xresources) { if (xresources) {
if (loadconfig) {
int cxrdb = system("[ -e $HOME/.config/spmenu/spmenurc ] && xrdb -override $HOME/.config/spmenu/spmenurc");
int hxrdb = system("[ -e $HOME/.spmenurc ] && xrdb -override $HOME/.spmenurc");
}
load_xresources(); load_xresources();
} }
@ -77,6 +82,12 @@ readargs(int argc, char *argv[])
generatecache = 0; generatecache = 0;
} else if (!strcmp(argv[i], "-wm")) { /* display as managed wm window */ } else if (!strcmp(argv[i], "-wm")) { /* display as managed wm window */
managed = 1; managed = 1;
} else if (!strcmp(argv[i], "-nwm")) { /* don't display as managed wm window */
managed = 0;
} else if (!strcmp(argv[i], "-lcfg")) { /* load config */
loadconfig = 1;
} else if (!strcmp(argv[i], "-ncfg")) { /* don't load config */
loadconfig = 0;
} else if (!strcmp(argv[i], "-na")) { /* disable alpha */ } else if (!strcmp(argv[i], "-na")) { /* disable alpha */
alpha = 0; alpha = 0;
} else if (!strcmp(argv[i], "-a")) { /* alpha */ } else if (!strcmp(argv[i], "-a")) { /* alpha */
@ -355,6 +366,9 @@ usage(void)
"spmenu -ic Position the image in the center\n" "spmenu -ic Position the image in the center\n"
"spmenu -itc Position the image in the top center\n" "spmenu -itc Position the image in the top center\n"
"spmenu -wm Spawn spmenu as a window manager controlled client/window. Useful for testing\n" "spmenu -wm Spawn spmenu as a window manager controlled client/window. Useful for testing\n"
"spmenu -nwm Don't spawn spmenu as a window manager controlled client/window. Useful for testing\n"
"spmenu -lcfg Load spmenu configuration (~/.spmenu or ~/.config/spmenu/spmenurc)\n"
"spmenu -ncfg Don't load spmenu configuration (~/.spmenu or ~/.config/spmenu/spmenurc)\n"
"spmenu -v Print spmenu version to stdout\n" "spmenu -v Print spmenu version to stdout\n"
"\n", stdout); "\n", stdout);
fputs("- Appearance arguments -\n" fputs("- Appearance arguments -\n"

View file

@ -134,6 +134,8 @@ ResourcePref resources[] = {
{ "generatecache", INTEGER, &generatecache }, { "generatecache", INTEGER, &generatecache },
{ "mode", INTEGER, &mode }, { "mode", INTEGER, &mode },
{ "fast", INTEGER, &fast }, { "fast", INTEGER, &fast },
{ "loadconfig", INTEGER, &loadconfig },
{ "managed", INTEGER, &managed },
{ "mon", INTEGER, &mon }, { "mon", INTEGER, &mon },
{ "pango_item", INTEGER, &pango_item }, { "pango_item", INTEGER, &pango_item },
{ "pango_prompt", INTEGER, &pango_prompt }, { "pango_prompt", INTEGER, &pango_prompt },

View file

@ -7,6 +7,7 @@
static char class[] = "spmenu"; /* Class for spmenu */ static char class[] = "spmenu"; /* Class for spmenu */
static int fast = 0; /* Grab keyboard first */ static int fast = 0; /* Grab keyboard first */
static int xresources = 1; /* Enable .Xresources support */ static int xresources = 1; /* Enable .Xresources support */
static int loadconfig = 1; /* Load configuration (~/.spmenurc or ~/.config/spmenu/spmenurc) on runtime */
static int mon = -1; /* Monitor to run spmenu on */ static int mon = -1; /* Monitor to run spmenu on */
/* Window options */ /* Window options */
@ -16,6 +17,7 @@ static int menupaddingv = 0; /* Vertical padding of bar (in pixels) */
static int menupaddingh = 0; /* Horizontal padding of bar (in pixels) */ static int menupaddingh = 0; /* Horizontal padding of bar (in pixels) */
static int minwidth = 500; /* Minimum width */ static int minwidth = 500; /* Minimum width */
static int centered = 0; /* Whether or not to center spmenu by default */ static int centered = 0; /* Whether or not to center spmenu by default */
static int managed = 0; /* Let your window manager manage spmenu? */
/* Image options */ /* Image options */
static int imagewidth = 86; /* Default image width */ static int imagewidth = 86; /* Default image width */

View file

@ -183,6 +183,15 @@ spmenu -itc - Position the image in the top center
.IP \[bu] 2 .IP \[bu] 2
spmenu -wm - Spawn spmenu as a window manager controlled client spmenu -wm - Spawn spmenu as a window manager controlled client
.IP \[bu] 2 .IP \[bu] 2
spmenu -nwm - Don\[cq]t spawn spmenu as a window manager controlled
client
.IP \[bu] 2
spmenu -lcfg - Load spmenu configuration (\[ti]/.spmenu or
\[ti]/.config/spmenu/spmenurc)
.IP \[bu] 2
spmenu -ncfg - Don\[cq]t load spmenu configuration (\[ti]/.spmenu or
\[ti]/.config/spmenu/spmenurc)
.IP \[bu] 2
spmenu -v - Print spmenu version to stdout spmenu -v - Print spmenu version to stdout
.IP \[bu] 2 .IP \[bu] 2
spmenu -fn font - Set the spmenu font to font spmenu -fn font - Set the spmenu font to font

View file

@ -154,7 +154,6 @@ static struct item *items = NULL, *backup_items;
static struct item *matches, *matchend; static struct item *matches, *matchend;
static struct item *prev, *curr, *next, *sel; static struct item *prev, *curr, *next, *sel;
static int screen; static int screen;
static int managed = 0;
/* image globals */ /* image globals */
#if USEIMAGE #if USEIMAGE