From: Arnaud Daby-Seesaram via Guix-patches via <guix-patches@gnu.org>
To: "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de>
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: Sat, 05 Oct 2024 19:02:11 +0200 [thread overview]
Message-ID: <877camv5yk.fsf@nanein.fr> (raw)
In-Reply-To: <87jzenr5bj.fsf@pelzflorian.de> (pelzflorian@pelzflorian.de's message of "Fri, 04 Oct 2024 22:17:20 +0200")
[-- Attachment #1: Type: text/plain, Size: 5423 bytes --]
Hello Florian,
> I’d welcome if you, Arnaud, sent a patch calling your sway-menu script.
>
> Also I’d be happy if more careful commiters would push it; I prefer to
> restrict my commits to translation updates.
I will proof-read and re-test the whole patch soon, hoping to avoid
additional careless bugs on my end.
Also: given that you assisted me quite a lot, do you want me to add a
line in the commit message to express that you helped me write the patch
(such as "This patch was co-authored with Florian Pelz.", as in Guix
commit 9371cf2138711ea7305951d82c5cf0b36ac4d6f1)?
I will send a v8 as soon as I have both seen your answer and proof-read
the patch.
NB: I think that the v8 can be the last version of the patch. Thank you
for your help and for your patience :)!
> Sorry for having proposed compiled-file previously.
No problem. I actually meant `program-file' instead of `computed-file'
(which was incorrectly used in my previous email). This way, the
lowered object in the store will be executable, allowing to define the
menu directly like this¹:
--8<---------------cut here---------------start------------->8---
(define %sway-default-variables
`([...]
(menu . ,sway-menu)))
--8<---------------cut here---------------end--------------->8---
¹: In the next version of the patch, I allow any file-like object in
`string-ish' instead of file-append objects only, so that Sway
variables can be bound to anything that can be lowered into a file
(in additions to strings and G-expressions).
> At first I had thought a compiled sway-menu.go would be appropriate,
> created in a computed-file, which invokes `guild compile` on the .scm
> code, but apparently this is not useful. I do not know enough here
> and gnu/services/shepherd.scm does it in the scm->go procedure.
Thank you for the pointer, `scm->go' is an interesting function.
I experimented and bit and was able to compile the menu to byte-code
using a similar function. However, I do not know a way to compile to
native code in Guile. Hence, I will stick to `program-file'.
> Anyway, some feedback:
>
>> (define (directory->files dir)
>> (define (executable-file? f)
>> ;; Cf. `(@@ (guix build utils) executable-file?)' for an
>> ;; explanation of `(zero? ...)'.
>
> This is a comment anyway, but one @ in (@ (guix build utils)
> executable-file?) would be enough, since the executable-file?
> predicate is exported.
Thx, fixed.
>> (lambda (s)
>
> To reduce clutter in the wmenu suggestions more, I’d prefer
>
> (and=> (and (not (eq? (string-ref f 0) #\.))
> (stat f))
> (lambda (s)
Indeed, this is better.
>> (not (or (zero? (logand (stat:mode s) #o100))
>> (eq? (stat:type s) 'directory))))))
>> (with-directory-excursion dir
>> (scandir "." executable-file?)))
>>
>> (let ((path (string-append (getenv "HOME")
>> "/.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)
>
> Better use @ instead of @@.
Unfortunately, `open-process' is not exported in `(ice-9 popen)', so I
kept @@.
>> (for-each
>> (lambda (c) (format to "~a~%" c))
>> (directory->files path))
>> (close to)
>> (let ((choice (read-line from)))
>> (close from)
>> (waitpid pid)
>> (execl swaymsg swaymsg "exec"
>> (string-append path "/" choice))))))))
>
> Even though I like to get suggestions only for
> ~/.guix-home/profile/bin, if you do not prepend path, [...]
> then it will remain possible to write shell commands in wmenu [...]
> to run apps without installing them.
Yes; I removed the string-append here. (As ~/.guix-home/profile/bin is
supposed to be in the path, this should work properly).
> Since you told me about wmenu-run, I also locally updated wmenu [1]
> and tested the menu config
>
> (menu . ,#~(string-append
> #$wmenu "/bin/wmenu-run"))
>
> which would also work, but in my opinion the suggestions are better
> when tied to .guix-home/profile. The wmenu-run does not use exec but
> a protocol called XDG_ACTIVATION_TOKEN. But I do not see an advantage
> to it. It behaves like always.
It is nice that this works too.
NB: if you want, you can use `(file-append pkg "stuff")' instead of
`#~(string-append #$pkg "stuff")'.
I do not know much about the XDG_ACTIVATION stuff; only that it has to
do with focused clients on Wayland IIRC. In my menu, I use `swaymsg
exec -- [command]', which takes care of a few things as well, as
explained below.
--8<---------------cut here---------------start------------->8---
Note: pass the final command to swaymsg so that the resulting window can
be opened on the original workspace that the command was run on.
--8<---------------cut here---------------end--------------->8---
Source: commit c3353bb27317d294a91a8accec9a554ea392de04 of Sway. It
explains why the menu is piped to 'swaymg exec --'. (I have added the
"--" argument in the v8).
> Also one more thing, in the commit message, you meant to write
> flatmap instead of flatten.
Indeed, thx.
Best regards,
--
Arnaud
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 857 bytes --]
next prev parent reply other threads:[~2024-10-05 17:03 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 [this message]
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)
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=877camv5yk.fsf@nanein.fr \
--to=guix-patches@gnu.org \
--cc=72714@debbugs.gnu.org \
--cc=ds-ac@nanein.fr \
--cc=hako@ultrarare.space \
--cc=ludo@gnu.org \
--cc=pelzflorian@pelzflorian.de \
/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).