How to launch a dbus client from a script?
Clash 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?
linux d-bus
add a comment |Â
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?
linux d-bus
I need answer, please
â AlmuHS
Mar 26 at 18:20
add a comment |Â
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?
linux d-bus
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?
linux d-bus
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
add a comment |Â
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
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
I need answer, please
â AlmuHS
Mar 26 at 18:20