GNU bug report logs - #72714
[PATCH] home: services: Add 'home-sway-service-type'.

Previous Next

Package: guix-patches;

Reported by: Arnaud Daby-Seesaram <ds-ac <at> nanein.fr>

Date: Mon, 19 Aug 2024 15:33:02 UTC

Severity: normal

Tags: patch

Done: "pelzflorian (Florian Pelz)" <pelzflorian <at> pelzflorian.de>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: "pelzflorian (Florian Pelz)" <pelzflorian <at> pelzflorian.de>
To: Arnaud Daby-Seesaram <ds-ac <at> nanein.fr>
Cc: Hilton Chain <hako <at> ultrarare.space>, Ludovic Courtès <ludo <at> gnu.org>, 72714 <at> debbugs.gnu.org
Subject: [bug#72714] [PATCH] home: services: Add 'home-sway-service-type'.
Date: Tue, 08 Oct 2024 18:39:13 +0200
[Message part 1 (text/plain, inline)]
Hello Arnaud.  Please excuse the long delay.

Arnaud Daby-Seesaram <ds-ac <at> nanein.fr> writes:
> "pelzflorian (Florian Pelz)" <pelzflorian <at> pelzflorian.de> writes:
>> I am not sure if program-file or scheme-file should be preferred.
>
> I think that in our use case, program-file is better, because it does
> not require to call Guile explicitly in the Sway configuration (all we
> care about is that the serialised script "behaves like a menu program").

Not sure, because program-file calls guile with --no-auto-compile.
Maybe someone else has an opinion.  Also it does not really matter.


>>>> Another more thing.  I try (bar (sway-bar)), but it prints an empty bar
>>>> configuration to .config/sway/config.  In patch 6, you added
>>>> no-serialization.  Did this break it?
>[…]
>> (bar (sway-bar
>>       (position 'top)))
>>
>> is fine.  Not sure what defaults are best.
>
> Yes, this is arbitrary in my code.  Rationale behind my choice:
>
> At first, I wanted to make the default value match that of the default
> Sway configuration file.  However, this would force some fields to be
> mandatory (namely status-command, colors and position).  As users may
> not want to specify these fields in their Sway configuration,
> I preferred to make everything optional.

I agree to better keep the sway-bar record simple.  Maybe a more
complete sway-bar should be the default value for bar rather than
optional, because it is what upstream does, although then I would
disagree with Hilton (?) and actually I prefer no bar.


>> Arnaud Daby-Seesaram <ds-ac <at> nanein.fr> writes:
>>>>>   (receive (from to pid)
>>>>>       ((@@ (ice-9 popen) open-process) OPEN_BOTH wmenu)
>>>>
>>>> Better use @ instead of @@.
>>> Unfortunately, `open-process' is not exported in `(ice-9 popen)', so I
>>> kept @@.
>>>
>>
>> Not sure if exported open-pipe* would be better.  open-process is
>> checked in guile tests, but not exported, that is right.  But maybe a
>> red flag not to use it.
>
> I first tried to use (open-pipe wmenu OPEN_BOTH).  However, I needed
> to close the port to wmenu before reading its output.  I do not know how
> to do that with `open-pipe'.
>
>
> Best,

In vain I tried rewriting code to use open-pipe* until I looked at the
source <https://codeberg.org/adnano/wmenu/src/tag/0.1.9/wmenu.c>:
> static void read_items(struct menu *menu) {
> 	char buf[sizeof menu->input];
> 	while (fgets(buf, sizeof buf, stdin)) {
> 		char *p = strchr(buf, '\n');
> 		if (p) {
> 			*p = '\0';
> 		}
> 		menu_add_item(menu, strdup(buf), false);
> 	}
> }

Well, I guess the port must be closed or wmenu does not leave the while
loop.  No other way.  But perhaps use pipeline from (ice-9 popen), which
is public, unlike open-process.

[diff (text/plain, inline)]
diff --git a/home-configuration.scm b/home-configuration.scm
index b961f84..c7eed63 100644
--- a/home-configuration.scm
+++ b/home-configuration.scm
@@ -41,10 +41,12 @@
   (scheme-file
    "sway-menu.scm"
    #~(begin
-       (use-modules (ice-9 receive)
+       (use-modules (ice-9 popen)
+                    (ice-9 receive)
                     (ice-9 rdelim)
                     (ice-9 ftw)
-                    (guix build utils))
+                    (guix build utils)
+                    (srfi srfi-1))
 
        (define (directory->files dir)
          (define (executable-file? f)
@@ -62,15 +64,15 @@
                                   "/.guix-home/profile/bin"))
              (wmenu #$(file-append wmenu "/bin/wmenu"))
              (swaymsg #$(file-append sway "/bin/swaymsg")))
-         (receive (from to pid)
-             ((@@ (ice-9 popen) open-process) OPEN_BOTH wmenu)
+         (receive (from to pids)
+             (pipeline `((,wmenu)))
            (for-each
             (lambda (c) (format to "~a~%" c))
             (directory->files path))
            (close to)
            (let ((choice (read-line from)))
              (close from)
-             (waitpid pid)
+             (waitpid (first pids))
              (execl swaymsg swaymsg "exec"
                     ;(string-append path "/" choice)
                     choice)))))))
[Message part 3 (text/plain, inline)]
Could you send v8?

Regards,
Florian

This bug report was last modified 219 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.