File: list_services.ml

package info (click to toggle)
obus 1.2.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,480 kB
  • sloc: ml: 14,675; lisp: 52; makefile: 11; xml: 8
file content (33 lines) | stat: -rw-r--r-- 840 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(*
 * list_services.ml
 * ----------------
 * Copyright : (c) 2008, Jeremie Dimino <jeremie@dimino.org>
 * Licence   : BSD3
 *
 * This file is a part of obus, an ocaml implementation of D-Bus.
 *)

(* List services with their owner *)

open Lwt
open Lwt_io

let list name get_bus =
  let%lwt () = printlf "service name mapping on %s bus:" name in
  let%lwt bus = get_bus () in

  (* Get the list of all names on the session bus *)
  let%lwt names = OBus_bus.list_names bus in

  Lwt_list.iter_p
    (fun name ->
      let%lwt owner = OBus_bus.get_name_owner bus name in
       printlf "  %s -> %s" owner name)

    (* Select only names which are not connection unique names *)
    (List.filter (fun s -> s.[0] <> ':') names)

let () = Lwt_main.run begin
  let%lwt () = list "session" OBus_bus.session in
  list "system" OBus_bus.system
end