]> Sergey Matveev's repositories - nnn.git/commitdiff
Make toggle dot behaviour persistent
authorsin <sin@2f30.org>
Mon, 22 Aug 2016 12:44:52 +0000 (13:44 +0100)
committersin <sin@2f30.org>
Mon, 22 Aug 2016 13:07:07 +0000 (14:07 +0100)
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
noice.c

index ca757dfee9dacaeab6140b6883f8f0d735d8f570..343869386c319ede671598e2def58b23e9819115 100644 (file)
@@ -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 a588a55cede83b485cd0c2758cdca7b26cb275db..0d5627dfea0b8cdf7aade9215cd63802c42218c2 100644 (file)
--- 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];