Find out the owner of a DBus service name

118

Solution 1

The d-bus debug utility d-feet which is available as a package in many systems seems to be able to find the process id and command providing a service. For example, I ran it on a Fedora 23 xfce4 X11 systemd platform and selected Session Bus and entered the service name org.freedesktop.Notifications. It introspected the service, activating it, and showed the pid and /usr/lib64/xfce4/notifyd/xfce4-notifyd command:

before activation

after activation

Solution 2

You can get the caller PID via org.freedesktop.DBus.GetConnectionUnixProcessID:

gdbus call --session --dest org.freedesktop.DBus --object-path / --method \
org.freedesktop.DBus.GetConnectionUnixProcessID org.freedesktop.Notifications

prints

(uint32 737,)

so there's your PID. If you prefer dbus-send (as gdbus is GNOME specific) then:

dbus-send --session --print-reply --dest=org.freedesktop.DBus / \
org.freedesktop.DBus.GetConnectionUnixProcessID string:org.freedesktop.Notifications
Share:
118

Related videos on Youtube

Gonzalo Pincheira Arancibia
Author by

Gonzalo Pincheira Arancibia

Updated on September 18, 2022

Comments

  • Gonzalo Pincheira Arancibia
    Gonzalo Pincheira Arancibia over 1 year

    I'm new using Restangular and I don't understand how resolve the promises using my own service. I' ve been trying to return the customGET method but in my controller the response it's a object that contain all the methods of the restangular resource, so i don't understand how get the response data. I inspect the network activity and the data it's retrieved.

    My Service

      angular
        .module('Form29')
        .service('Form29Service', Service);
    
      Service.$inject = ['Restangular'];
    
      function Service(Restangular) {
    
        this.serviceResource = Restangular.all('forms');
        this.getForm29 = getForm29;
    
        function getForm29(_month, _year, _type) {
          var params = {
            rut: '76195496',
            month: _month,
            year: _year,
            type: _type
          };
          return this.serviceResource.customGET('',params);
        }
      }
    

    My Controller

    angular
        .module('Form29')
        .controller('Form29Controller', Controller);
    
      Controller.$inject = ['Form29Service'];
    
      function Controller(Form29Service) {
    
        var vm = this;
    
        vm.submitForm = submitForm;
    
        function submitForm(month, year, type){
          Form29Service.getForm29(month, year, type).then(showForm);
        }
        function showForm(response){
          console.log(response);
        }
    
      }
    
    • Silvinus
      Silvinus almost 8 years
      Did you try to replace return this.serviceResource.customGET('',params); by this.serviceResource.get(params)
    • Austin Hemmelgarn
      Austin Hemmelgarn almost 7 years
      I don't know of a way to get this information generically, but in this case the particular service you're asking about is usually provided by a daemon bundled with your desktop environment (Cinnamon, XFCE4, and MATE all do it this way), and it's usually somewhat difficult to get the desktop to use a different notification daemon if it comes with one bundled.
    • Mael
      Mael almost 7 years
      @AustinHemmelgarn Thanks. I'm running AwesomeWM which does not bundle notifications daemon (I'm not actually sure about it, I'll investigate, thanks for the clue).
    • Austin Hemmelgarn
      Austin Hemmelgarn almost 7 years
      I think AwesomeWM provides the service itself internally actually (at least, on Gentoo and Debian it appears to be recognized as a notification provider). If not, the most likely possibility is 'notify-osd', as that's the most widely used desktop-agnostic notification daemon out there.
    • Mael
      Mael almost 7 years
      @AustinHemmelgarn You've pointed me in the right direction! It was enough to comment out require("naughty") in Awesome's config, restart, and I was able to launch the daemon I wanted.
    • Austin Hemmelgarn
      Austin Hemmelgarn almost 7 years
      For what it's worth, I'm actually still kind of curious myself if somebody out there knows of a way to trace a service name in DBus back to a process. I bet there is something to do so, but a cursory look at the documentation isn't revealing anything for me either.
    • meuh
      meuh almost 7 years
      @AustinHemmelgarn I dont know how it does it, but d-feet found a pid. See my answer.