Giter Site home page Giter Site logo

Comments (6)

thediveo avatar thediveo commented on June 16, 2024 1

Go doesn't support fork() in the way used by libtinynotify-systemwide, due to the way the Golang runtime works: it needs multiple Go routines which might map to multiple OS-level threads. After a fork() syscall only the current OS-level thread would be running in the child, with the other OS-level threads lost, which might happen to have the garbage collector, background IO handlers, et cetera.

Go only supports running a new process (as a child) from some binary. What actually is possible (and what I am doing in a the lxkns package), is to run the same binary /proc/self/exe again as a child process via Command.Start(). You can pass some special env variable or CLI flag to tell the child to just carry out connecting to a dedicated dbus instance. Of course, you need to write all the parameter passing from parent to re-executed child.

from beeep.

gen2brain avatar gen2brain commented on June 16, 2024

It is already like that in code https://github.com/gen2brain/beeep/blob/master/alert_darwin.go#L14, i.e. tell System Events. Did you try to use it, what happens and what is expected?

from beeep.

dustin-decker avatar dustin-decker commented on June 16, 2024

On Linux the notifications only work for the user that the function is run as.

Running beeep with sudo will not create notifications for the user on Linux.

It would be nice if beeep as root would notify users of the system.

from beeep.

gen2brain avatar gen2brain commented on June 16, 2024

There is support currently for sw-notify-send that I use, repo is here https://github.com/mgorny/libtinynotify-systemwide/ .

As written there "All it does is looking over procfs (/proc) for all D-Bus session buses,
and trying to send the notification to every one of them". I think all that can be reproduced in Go, just not sure about the fork() and setreuid(), it seems it is needed and Go still has some issues with it.

from beeep.

dustin-decker avatar dustin-decker commented on June 16, 2024

Thanks @gen2brain I will look into that a little more.

from beeep.

pymq avatar pymq commented on June 16, 2024

If someone stumbles on this issue, here is workaround I found:
godbus/dbus#246

You can rename main function to init in reproducer code from the issue above and in new main function run beeep.Notify and it will just work.

Note: you need dbus version from this pr: godbus/dbus#247

from beeep.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.