guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GNOME: Suggesting ‘guix gc’ upon low disk space


From: Ludovic Courtès
Subject: GNOME: Suggesting ‘guix gc’ upon low disk space
Date: Thu, 17 Sep 2020 14:39:30 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

Hello Guix!

GNOME (actually ‘gnome-settings-daemon’) pops up a notification upon low
disk space that looks like this:

    Low Disk Space on “filesystem root”

    [ Empty Trash ]    [ Examine ]

The “Examine” button spawns the Disk Space Analyzer (aka Baobab) and the
“Empty Trash” button does its thing.

The untested patch below adds a ‘guix gc’ button, which is probably more
important than the other two on Guix System.

I’m not sure whether implementing it is as simple as this: is it OK to
block during GC or should it be done in a separate process?

If someone here has more insight or would like to give it a try, please
let me know!

Ludo’.

diff --git a/plugins/housekeeping/gsd-disk-space.c 
b/plugins/housekeeping/gsd-disk-space.c
index bd3437e..870430b 100644
--- a/plugins/housekeeping/gsd-disk-space.c
+++ b/plugins/housekeeping/gsd-disk-space.c
@@ -546,6 +546,20 @@ empty_trash_callback (NotifyNotification *n,
         notify_notification_close (n, NULL);
 }
 
+static void
+guix_gc_callback (NotifyNotification *n,
+                  const char         *action)
+{
+        GDateTime *old;
+
+        g_assert (action != NULL);
+        g_assert (strcmp (action, "run-guix-gc") == 0);
+
+        system ("guix gc");
+
+        notify_notification_close (n, NULL);
+}
+
 static void
 on_notification_closed (NotifyNotification *n)
 {
@@ -591,6 +605,13 @@ ldsm_notify (const char *summary,
                                                 g_free);
         }
 
+        notify_notification_add_action (notification,
+                                        "run-guix-gc",
+                                        _("Collect Unused Guix Items"),
+                                        (NotifyActionCallback) 
guix_gc_callback,
+                                        NULL,
+                                        NULL);
+
         has_trash = ldsm_mount_has_trash (mount_path);
 
         if (has_trash) {

reply via email to

[Prev in Thread] Current Thread [Next in Thread]