unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de>
To: Arnaud Daby-Seesaram <ds-ac@nanein.fr>
Cc: "Hilton Chain" <hako@ultrarare.space>,
	"Ludovic Courtès" <ludo@gnu.org>,
	72714@debbugs.gnu.org
Subject: [bug#72714] [PATCH] home: services: Add 'home-sway-service-type'.
Date: Tue, 08 Oct 2024 18:39:13 +0200	[thread overview]
Message-ID: <87cyka1rda.fsf@pelzflorian.de> (raw)
In-Reply-To: <87set9y0hz.fsf@nanein.fr> (Arnaud Daby-Seesaram's message of "Sun, 06 Oct 2024 12:44:08 +0200")

[-- Attachment #1: Type: text/plain, Size: 2798 bytes --]

Hello Arnaud.  Please excuse the long delay.

Arnaud Daby-Seesaram <ds-ac@nanein.fr> writes:
> "pelzflorian (Florian Pelz)" <pelzflorian@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@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.


[-- Attachment #2: diff --]
[-- Type: text/plain, Size: 1362 bytes --]

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)))))))

[-- Attachment #3: Type: text/plain, Size: 38 bytes --]


Could you send v8?

Regards,
Florian

  reply	other threads:[~2024-10-08 16:50 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-19 15:30 [bug#72714] [PATCH] home: services: Add 'home-sway-service-type' Arnaud Daby-Seesaram via Guix-patches via
2024-08-24 15:32 ` [bug#72714] [PATCH v2] " Arnaud Daby-Seesaram via Guix-patches via
2024-08-26 10:38 ` [bug#72714] [PATCH v3] " Arnaud Daby-Seesaram via Guix-patches via
2024-09-03  7:27 ` [bug#72714] [PATCH v4] " Arnaud Daby-Seesaram via Guix-patches via
2024-09-14 13:28   ` pelzflorian (Florian Pelz)
2024-09-14 14:06     ` pelzflorian (Florian Pelz)
2024-09-17  6:52     ` Arnaud Daby-Seesaram via Guix-patches via
2024-09-20 16:45       ` pelzflorian (Florian Pelz)
2024-09-22 13:43         ` Arnaud Daby-Seesaram via Guix-patches via
2024-09-25  6:58           ` pelzflorian (Florian Pelz)
2024-09-25  7:52             ` Arnaud Daby-Seesaram via Guix-patches via
2024-09-25 11:42             ` pelzflorian (Florian Pelz)
2024-09-18  8:15 ` [bug#72714] [PATCH v5] " Arnaud Daby-Seesaram via Guix-patches via
2024-09-18 18:56   ` Arnaud Daby-Seesaram via Guix-patches via
2024-09-22  8:14   ` Hilton Chain via Guix-patches via
2024-09-25  8:00 ` [bug#72714] [PATCH v6] " Arnaud Daby-Seesaram via Guix-patches via
2024-09-30 20:07   ` Ludovic Courtès
2024-10-01 22:12     ` [bug#72714] [PATCH] " Arnaud Daby-Seesaram via Guix-patches via
2024-10-02 14:08       ` pelzflorian (Florian Pelz)
2024-10-02 20:49         ` Arnaud Daby-Seesaram via Guix-patches via
2024-10-03 12:41           ` pelzflorian (Florian Pelz)
2024-10-03 20:53             ` Arnaud Daby-Seesaram via Guix-patches via
2024-10-04 20:17               ` pelzflorian (Florian Pelz)
2024-10-05 17:02                 ` Arnaud Daby-Seesaram via Guix-patches via
2024-10-06  8:15                   ` pelzflorian (Florian Pelz)
2024-10-06  9:05                     ` Arnaud Daby-Seesaram via Guix-patches via
2024-10-06  9:51                       ` pelzflorian (Florian Pelz)
2024-10-06 10:44                         ` Arnaud Daby-Seesaram via Guix-patches via
2024-10-08 16:39                           ` pelzflorian (Florian Pelz) [this message]
2024-10-08 22:33                             ` [bug#72714] [PATCH v8] " Arnaud Daby-Seesaram via Guix-patches via
2024-10-12 13:11                               ` bug#72714: " pelzflorian (Florian Pelz)
2024-10-01 22:30     ` [bug#72714] [PATCH v7] " Arnaud Daby-Seesaram via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87cyka1rda.fsf@pelzflorian.de \
    --to=pelzflorian@pelzflorian.de \
    --cc=72714@debbugs.gnu.org \
    --cc=ds-ac@nanein.fr \
    --cc=hako@ultrarare.space \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).