diff --git a/Makefile b/Makefile index b293e4f7..6705c3af 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION = 0.5 +VERSION = 0.6 PREFIX = /usr/local MANPREFIX = $(PREFIX)/man @@ -16,7 +16,7 @@ BIN = noice all: $(BIN) $(BIN): $(OBJ) - $(CC) $(CFLAGS) -o $@ $(OBJ) $(LDLIBS) + $(CC) $(CFLAGS) -o $@ $(OBJ) $(LDFLAGS) $(LDLIBS) noice.o: util.h config.h strlcat.o: util.h diff --git a/config.def.h b/config.def.h index 663351a9..bffc69d5 100644 --- a/config.def.h +++ b/config.def.h @@ -1,11 +1,12 @@ /* See LICENSE file for copyright and license details. */ -#define CWD "cwd: " +#define CWD "cwd: " #define CURSR " > " #define EMPTY " " -int mtimeorder = 0; /* Set to 1 to sort by time modified */ +int mtimeorder = 0; /* Set to 1 to sort by time modified */ int idletimeout = 0; /* Screensaver timeout in seconds, 0 to disable */ -char *idlecmd = "rain"; /* The screensaver program */ +int showhidden = 0; /* Set to 1 to show hidden files by default */ +char *idlecmd = "rain"; /* The screensaver program */ struct assoc assocs[] = { //{ "\\.(avi|mp4|mkv|mp3|ogg|flac|mov)$", "mpv" }, diff --git a/noice.c b/noice.c index 0e3eca7c..e9e4e653 100644 --- a/noice.c +++ b/noice.c @@ -256,6 +256,12 @@ setfilter(regex_t *regex, char *filter) return r; } +void +initfilter(int dot, char **ifilter) +{ + *ifilter = dot ? "." : "^[^.]"; +} + int visible(regex_t *regex, char *file) { @@ -793,10 +799,9 @@ nochange: DPRINTF_S(path); goto begin; case SEL_TOGGLEDOT: - if (strcmp(fltr, ifilter) != 0) - strlcpy(fltr, ifilter, sizeof(fltr)); - else - strlcpy(fltr, ".", sizeof(fltr)); + showhidden ^= 1; + initfilter(showhidden, &ifilter); + strlcpy(fltr, ifilter, sizeof(fltr)); goto begin; case SEL_MTIME: mtimeorder = !mtimeorder; @@ -855,9 +860,8 @@ main(int argc, char *argv[]) } if (getuid() == 0) - ifilter = "."; - else - ifilter = "^[^.]"; /* Hide dotfiles */ + showhidden = 1; + initfilter(showhidden, &ifilter); if (argv[1] != NULL) { ipath = argv[1];