How to launch a dbus client from a script?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












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?







share|improve this question






















  • I need answer, please
    – AlmuHS
    Mar 26 at 18:20














up vote
1
down vote

favorite












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?







share|improve this question






















  • I need answer, please
    – AlmuHS
    Mar 26 at 18:20












up vote
1
down vote

favorite









up vote
1
down vote

favorite











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?







share|improve this question














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?









share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 16:00

























asked Mar 23 at 23:25









AlmuHS

1346




1346











  • I need answer, please
    – AlmuHS
    Mar 26 at 18:20
















  • I need answer, please
    – AlmuHS
    Mar 26 at 18:20















I need answer, please
– AlmuHS
Mar 26 at 18:20




I need answer, please
– AlmuHS
Mar 26 at 18:20















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f433175%2fhow-to-launch-a-dbus-client-from-a-script%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f433175%2fhow-to-launch-a-dbus-client-from-a-script%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Christian Cage

How to properly install USB display driver for Fresco Logic FL2000DX on Ubuntu?