![스크립트에서 dbus 클라이언트를 시작하는 방법은 무엇입니까?](https://linux55.com/image/130125/%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%EC%97%90%EC%84%9C%20dbus%20%ED%81%B4%EB%9D%BC%EC%9D%B4%EC%96%B8%ED%8A%B8%EB%A5%BC%20%EC%8B%9C%EC%9E%91%ED%95%98%EB%8A%94%20%EB%B0%A9%EB%B2%95%EC%9D%80%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F.png)
방금 dbus 서비스(다른 사용자가 시작한)로부터 메시지를 받으면 데스크톱 알림을 표시하는 Python으로 작성된 dbus 클라이언트를 개발했습니다.
dbus 클라이언트 코드는 다음과 같습니다.
#!/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()
이제 스크립트에서 dbus 클라이언트를 시작하고 싶습니다. 하지만 스크립트가 완료될 때 죽지 않으려면 이 dbus 클라이언트가 필요합니다.
또한 특정(루트가 아닌) 사용자로 dbus 클라이언트를 시작해야 합니다. 스크립트는 루트로 실행됩니다.
나는 이것을 시도했습니다 :
nohup su user -c '/usr/bin/pendrive-reminder/client.py' &
그러나 이제 명령을 완료한 후에도 스크립트가 잠긴 상태로 유지되어 "만료된" 프로세스로 표시됩니다. 따라서 dbus 클라이언트를 시작한 후 스크립트를 완성해야 합니다.
이 문제를 어떻게 해결할 수 있나요?