From dd29e81df5e3aa917bb89d13282c3ba38f458a3f Mon Sep 17 00:00:00 2001 From: sin Date: Mon, 22 Aug 2016 13:44:52 +0100 Subject: [PATCH] Make toggle dot behaviour persistent Once set, the default filter is updated. This means that toggle dot will also work as expected when noice is executed as root. Based on discussion with Ypnose. --- config.def.h | 1 + noice.c | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/config.def.h b/config.def.h index ca757dfe..34386938 100644 --- a/config.def.h +++ b/config.def.h @@ -5,6 +5,7 @@ int mtimeorder = 0; /* Set to 1 to sort by time modified */ int idletimeout = 0; /* Screensaver timeout in seconds, 0 to disable */ +int showhidden = 0; /* Set to 1 to show hidden files by default */ char *idlecmd = "rain"; /* The screensaver program */ struct assoc assocs[] = { diff --git a/noice.c b/noice.c index a588a55c..0d5627df 100644 --- a/noice.c +++ b/noice.c @@ -733,10 +733,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; + ifilter = showhidden ? "." : "^[^.]"; + strlcpy(fltr, ifilter, sizeof(fltr)); goto begin; case SEL_MTIME: mtimeorder = !mtimeorder; @@ -795,9 +794,12 @@ main(int argc, char *argv[]) } if (getuid() == 0) + showhidden = 1; + + if (showhidden) ifilter = "."; else - ifilter = "^[^.]"; /* Hide dotfiles */ + ifilter = "^[^.]"; if (argv[1] != NULL) { ipath = argv[1];