[bug#34971] gnu: Add mako.

Message ID 20190324060845.7921-1-meiyo@riseup.net
State Accepted
Headers show
Series [bug#34971] gnu: Add mako. | expand

Checks

Context Check Description
cbaines/applying patch success Successfully applied
cbaines/applying patch success Successfully applied
cbaines/applying patch success Successfully applied
cbaines/applying patch success Successfully applied
cbaines/applying patch success Successfully applied
cbaines/applying patch success Successfully applied
cbaines/applying patch success Successfully applied
cbaines/applying patch success Successfully applied
cbaines/applying patch success Successfully applied
cbaines/applying patch success Successfully applied

Commit Message

Meiyo Peng March 24, 2019, 6:08 a.m. UTC
* gnu/packages/wm.scm (mako): New variable.
---
 gnu/packages/wm.scm | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

Comments

Meiyo Peng March 24, 2019, 6:39 a.m. UTC | #1
Hi everyone,

If you have trouble running mako and mako gives you an error message
like:

#+begin_example
  Failed to connect to user bus: No such file or directory
#+end_example

The problem is caused by that $DBUS_SESSION_BUS_ADDRESS is not set in
your GUI session.  You can start mako with this command:

#+begin_src sh
  dbus-launch --autolaunch=$(dbus-uuidgen --get) mako
#+end_src

I run mako with Sway.  And I put this line in Sway config file:

#+begin_src conf
  exec sh -c 'dbus-launch --autolaunch=$(dbus-uuidgen --get) mako'
#+end_src


--
Meiyo Peng
https://www.pengmeiyu.com/
Ludovic Courtès March 25, 2019, 10:39 a.m. UTC | #2
Hello,

Meiyo Peng <meiyo@riseup.net> skribis:

> If you have trouble running mako and mako gives you an error message
> like:
>
> #+begin_example
>   Failed to connect to user bus: No such file or directory
> #+end_example

I would expect Mako to automatically spawn the D-Bus user bus if it’s
not already needed, no?  We don’t need to do anything special with other
D-Bus applications AFAIK.

Thanks,
Ludo’.
Ricardo Wurmus March 25, 2019, 2:35 p.m. UTC | #3
Ludovic Courtès <ludo@gnu.org> writes:

> Hello,
>
> Meiyo Peng <meiyo@riseup.net> skribis:
>
>> If you have trouble running mako and mako gives you an error message
>> like:
>>
>> #+begin_example
>>   Failed to connect to user bus: No such file or directory
>> #+end_example
>
> I would expect Mako to automatically spawn the D-Bus user bus if it’s
> not already needed, no?  We don’t need to do anything special with other
> D-Bus applications AFAIK.

When the desktop environment has a D-Bus session daemon, this should
just work.  I suppose using dbus-lauch is necessary in cases where a
minimalist desktop environment is used that does not take steps to
launch/configure the D-Bus daemon.

In that sense I think mako behaves like any other D-Bus application.
Meiyo Peng March 25, 2019, 4:31 p.m. UTC | #4
Hi Ludovic,

Ludovic Courtès writes:

> Meiyo Peng <meiyo@riseup.net> skribis:
>
>> If you have trouble running mako and mako gives you an error message
>> like:
>>
>> #+begin_example
>>   Failed to connect to user bus: No such file or directory
>> #+end_example
>
> I would expect Mako to automatically spawn the D-Bus user bus if it’s
> not already needed, no?  We don’t need to do anything special with other
> D-Bus applications AFAIK.

Yeah.  I expect that too.  I am not sure why mako is so special.  mako
uses the sd-bus library of systemd/elogind instead of libdbus.  Do you
think that could be the cause?

I don't know much about D-Bus.  Maybe it's just because of mako's bad
program design.  I used dunst as my notification daemon and dunst did
just works.  dunst provides a D-Bus service file.  I don't even have to
manually start dunst.


--
Meiyo Peng
Ludovic Courtès March 25, 2019, 9:24 p.m. UTC | #5
Ricardo Wurmus <rekado@elephly.net> skribis:

> Ludovic Courtès <ludo@gnu.org> writes:
>
>> Hello,
>>
>> Meiyo Peng <meiyo@riseup.net> skribis:
>>
>>> If you have trouble running mako and mako gives you an error message
>>> like:
>>>
>>> #+begin_example
>>>   Failed to connect to user bus: No such file or directory
>>> #+end_example
>>
>> I would expect Mako to automatically spawn the D-Bus user bus if it’s
>> not already needed, no?  We don’t need to do anything special with other
>> D-Bus applications AFAIK.
>
> When the desktop environment has a D-Bus session daemon, this should
> just work.  I suppose using dbus-lauch is necessary in cases where a
> minimalist desktop environment is used that does not take steps to
> launch/configure the D-Bus daemon.

I thought along these lines, but then I use Ratpoison and D-Bus programs
“just work” for me.  There’s no DBUS_SESSION_BUS_whatever environment
variable set for me.  I’m curious!

Ludo’.
Ludovic Courtès April 3, 2019, 4:02 p.m. UTC | #6
Hi Meiyo,

Meiyo Peng <meiyo@riseup.net> skribis:

> Ludovic Courtès writes:
>
>> Meiyo Peng <meiyo@riseup.net> skribis:
>>
>>> If you have trouble running mako and mako gives you an error message
>>> like:
>>>
>>> #+begin_example
>>>   Failed to connect to user bus: No such file or directory
>>> #+end_example
>>
>> I would expect Mako to automatically spawn the D-Bus user bus if it’s
>> not already needed, no?  We don’t need to do anything special with other
>> D-Bus applications AFAIK.
>
> Yeah.  I expect that too.  I am not sure why mako is so special.  mako
> uses the sd-bus library of systemd/elogind instead of libdbus.  Do you
> think that could be the cause?

Could you check with ‘strace’ whether it tries to connect to
/run/dbus/system_bus_socket instead of /var/run/dbus/system_bus_socket?

Thanks,
Ludo’.
Meiyo Peng April 10, 2019, 8:44 a.m. UTC | #7
Hi Ludovic,

Ludovic Courtès writes:

> Meiyo Peng <meiyo@riseup.net> skribis:
>
>> Ludovic Courtès writes:
>>
>>> Meiyo Peng <meiyo@riseup.net> skribis:
>>>
>>>> If you have trouble running mako and mako gives you an error message
>>>> like:
>>>>
>>>> #+begin_example
>>>>   Failed to connect to user bus: No such file or directory
>>>> #+end_example
>>>
>>> I would expect Mako to automatically spawn the D-Bus user bus if it’s
>>> not already needed, no?  We don’t need to do anything special with other
>>> D-Bus applications AFAIK.
>>
>> Yeah.  I expect that too.  I am not sure why mako is so special.  mako
>> uses the sd-bus library of systemd/elogind instead of libdbus.  Do you
>> think that could be the cause?
>
> Could you check with ‘strace’ whether it tries to connect to
> /run/dbus/system_bus_socket instead of /var/run/dbus/system_bus_socket?

I get this output from `strace mako`:

#+begin_example
  ...
  socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
  getsockopt(3, SOL_SOCKET, SO_RCVBUF, [212992], [4]) = 0
  setsockopt(3, SOL_SOCKET, SO_RCVBUF, [8388608], 4) = 0
  getsockopt(3, SOL_SOCKET, SO_SNDBUF, [212992], [4]) = 0
  setsockopt(3, SOL_SOCKET, SO_SNDBUF, [8388608], 4) = 0
  connect(3, {sa_family=AF_UNIX, sun_path="/run/user/1000/bus"}, 21) = -1 ENOENT (No such file or directory)
  close(3)                                = 0
  write(2, "Failed to connect to user bus: N"..., 57Failed to connect to user bus: No such file or directory
  ) = 57
  exit_group(1)                           = ?
  +++ exited with 1 +++
#+end_example

It tries to connect to /run/user/1000/bus.

And that error message is from
https://github.com/emersion/mako/blob/master/dbus/dbus.c:

#+begin_src c
  ret = sd_bus_open_user(&state->bus);
  if (ret < 0) {
      fprintf(stderr, "Failed to connect to user bus: %s\n", strerror(-ret));
      goto error;
  }
#+end_src

--
Meiyo Peng
https://www.pengmeiyu.com/
Ludovic Courtès April 10, 2019, 8:35 p.m. UTC | #8
Hi,

Meiyo Peng <meiyo@riseup.net> skribis:

> I get this output from `strace mako`:
>
> #+begin_example
>   ...
>   socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
>   getsockopt(3, SOL_SOCKET, SO_RCVBUF, [212992], [4]) = 0
>   setsockopt(3, SOL_SOCKET, SO_RCVBUF, [8388608], 4) = 0
>   getsockopt(3, SOL_SOCKET, SO_SNDBUF, [212992], [4]) = 0
>   setsockopt(3, SOL_SOCKET, SO_SNDBUF, [8388608], 4) = 0
>   connect(3, {sa_family=AF_UNIX, sun_path="/run/user/1000/bus"}, 21) = -1 ENOENT (No such file or directory)

So I’m a bit at loss but what I can say is that /run/user/UID/bus
doesn’t seem to exist in practice.

For example, if I strace “dbus-monitor --session”, I see this:

  connect(3, {sa_family=AF_UNIX, sun_path=@"/tmp/dbus-ktJE8…"}, 23) = 0

I have no idea where this file name comes from but it seems to be
deterministic.

So… more investigation needed!

Ludo’.
Stefan Stefanović April 23, 2019, 12:14 p.m. UTC | #9
Hello.

AFAIK mako relies on elogind to access user DBus session daemon.

elogind relies on environment variable DBUS_SESSION_BUS_ADDRESS.
In my case DBUS_SESSION_BUS_ADDRESS is set to
"unix:path=/run/user/1000/dbus-1/session_bus_socket".

DBUS_SESSION_BUS_ADDRESS is created by user session manager.
In my case it is set in a shell script by executing:
echo "Starting user DBus session daemon."
dbus-daemon \
  --syslog --fork \
  --address="${DBUS_SESSION_BUS_ADDRESS}" \
  --print-pid --session

This is not perfect solution but it works, for now.

Please take a look at relevant elogind issue:
https://github.com/elogind/elogind/issues/87

Stefan.
Ludovic Courtès May 21, 2019, 2:50 p.m. UTC | #10
Hi Meiyo,

Did you make any progress on this front?

Thanks,
Ludo’.

Ludovic Courtès <ludo@gnu.org> skribis:

> Hi,
>
> Meiyo Peng <meiyo@riseup.net> skribis:
>
>> I get this output from `strace mako`:
>>
>> #+begin_example
>>   ...
>>   socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
>>   getsockopt(3, SOL_SOCKET, SO_RCVBUF, [212992], [4]) = 0
>>   setsockopt(3, SOL_SOCKET, SO_RCVBUF, [8388608], 4) = 0
>>   getsockopt(3, SOL_SOCKET, SO_SNDBUF, [212992], [4]) = 0
>>   setsockopt(3, SOL_SOCKET, SO_SNDBUF, [8388608], 4) = 0
>>   connect(3, {sa_family=AF_UNIX, sun_path="/run/user/1000/bus"}, 21) = -1 ENOENT (No such file or directory)
>
> So I’m a bit at loss but what I can say is that /run/user/UID/bus
> doesn’t seem to exist in practice.
>
> For example, if I strace “dbus-monitor --session”, I see this:
>
>   connect(3, {sa_family=AF_UNIX, sun_path=@"/tmp/dbus-ktJE8…"}, 23) = 0
>
> I have no idea where this file name comes from but it seems to be
> deterministic.
>
> So… more investigation needed!
>
> Ludo’.
Meiyo Peng May 23, 2019, 11:24 a.m. UTC | #11
Hi Ludovic,

Ludovic Courtès writes:

> Did you make any progress on this front?

I have discussed with the author of mako.  He agreed to add a D-Bus
service file for mako.  That will solve this issue here.  I have tested
it on my computer.  The D-Bus service file will cause mako to be
automatically started when needed.  mako will work out of the box after
installation.  No user action is required.

Link:
1. https://github.com/emersion/mako/issues/155
2. https://github.com/emersion/mako/pull/156

When that pull request is merged, I will send a new package definition
for mako.

> Ludovic Courtès <ludo@gnu.org> skribis:
>
>> Hi,
>>
>> Meiyo Peng <meiyo@riseup.net> skribis:
>>
>>> I get this output from `strace mako`:
>>>
>>> #+begin_example
>>>   ...
>>>   socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
>>>   getsockopt(3, SOL_SOCKET, SO_RCVBUF, [212992], [4]) = 0
>>>   setsockopt(3, SOL_SOCKET, SO_RCVBUF, [8388608], 4) = 0
>>>   getsockopt(3, SOL_SOCKET, SO_SNDBUF, [212992], [4]) = 0
>>>   setsockopt(3, SOL_SOCKET, SO_SNDBUF, [8388608], 4) = 0
>>>   connect(3, {sa_family=AF_UNIX, sun_path="/run/user/1000/bus"}, 21) = -1 ENOENT (No such file or directory)
>>
>> So I’m a bit at loss but what I can say is that /run/user/UID/bus
>> doesn’t seem to exist in practice.
>>
>> For example, if I strace “dbus-monitor --session”, I see this:
>>
>>   connect(3, {sa_family=AF_UNIX, sun_path=@"/tmp/dbus-ktJE8…"}, 23) = 0
>>
>> I have no idea where this file name comes from but it seems to be
>> deterministic.
>>
>> So… more investigation needed!
>>
>> Ludo’.


--
Meiyo Peng
https://www.pengmeiyu.com/
Ludovic Courtès May 24, 2019, 3:26 p.m. UTC | #12
Hi Meiyo,

Meiyo Peng <meiyo@riseup.net> skribis:

> I have discussed with the author of mako.  He agreed to add a D-Bus
> service file for mako.  That will solve this issue here.  I have tested
> it on my computer.  The D-Bus service file will cause mako to be
> automatically started when needed.  mako will work out of the box after
> installation.  No user action is required.
>
> Link:
> 1. https://github.com/emersion/mako/issues/155
> 2. https://github.com/emersion/mako/pull/156
>
> When that pull request is merged, I will send a new package definition
> for mako.

Alright, sounds good to me.  Thanks for the update!

Ludo’.

Patch

diff --git a/gnu/packages/wm.scm b/gnu/packages/wm.scm
index 0a05ff4ae4..cc7cd56d66 100644
--- a/gnu/packages/wm.scm
+++ b/gnu/packages/wm.scm
@@ -17,7 +17,7 @@ 
 ;;; Copyright © 2017 Oleg Pykhalov <go.wigust@gmail.com>
 ;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2018 Pierre-Antoine Rouby <contact@parouby.fr>
-;;; Copyright © 2018 Meiyo Peng <meiyo.peng@gmail.com>
+;;; Copyright © 2018, 2019 Meiyo Peng <meiyo@riseup.net>
 ;;; Copyright © 2019 Rutger Helling <rhelling@mykolab.com>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -1228,3 +1228,32 @@  modules for building a Wayland compositor.")
     (synopsis "Screen locking utility for Wayland compositors")
     (description "Swaylock is a screen locking utility for Wayland compositors.")
     (license license:expat))) ; MIT license
+
+(define-public mako
+  (package
+    (name "mako")
+    (version "1.2")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/emersion/mako")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "112b7s5bkvwlgsm2kng2vh8mn6wr3a6c7n1arl9adxlghdym449h"))))
+    (build-system meson-build-system)
+    (inputs
+     `(("cairo" ,cairo)
+       ("elogind" ,elogind)
+       ("pango" ,pango)
+       ("wayland" ,wayland)))
+    (native-inputs
+     `(("pkg-config" ,pkg-config)
+       ("scdoc" ,scdoc)
+       ("wayland-protocols" ,wayland-protocols)))
+    (home-page "https://github.com/emersion/mako")
+    (synopsis "Lightweight Wayland notification daemon")
+    (description "@code{mako} is a lightweight notification daemon for
+Wayland.")
+    (license license:expat)))