I've just developed a dbus client, writed in Python, to shows a desktop notification when it receives a message from a dbus service, which is launched by another user.
The dbus client code is here:
#!/usr/bin/python3 from gi.repository import Gtk from gi.repository import Notify import dbus from dbus.mainloop.glib import DBusGMainLoop DBusGMainLoop(set_as_default=True) bus = dbus.SystemBus() def msg_handler(*args,**keywords): try: #show notification to desktop Notify.init('Pendrive Reminder') notify = Notify.Notification.new('Pendrive Reminder', 'Shutdown lock enabled. Disconnect pendrive to enable shutdown') notify.show() except: pass bus.add_signal_receiver(handler_function=msg_handler, dbus_interface='org.preminder', path_keyword='path') Gtk.main()
Now, I want to launch the dbus client from a script. But I need that this dbus client don't dead when script finish.
Also, I need that the dbus client to be launched as a specific (non root) user. The script will be executed as root.
I tried with this:
nohup su user -c '/usr/bin/pendrive-reminder/client.py' &
But now the script keeps locked after finish its commands, shows as "defunct" process. So, I need to get that my script can finish after launch the dbus client
How can I solve this?