package obus

  1. Overview
  2. Docs
Pure Ocaml implementation of the D-Bus protocol

Install

Dune Dependency

Authors

Maintainers

Sources

obus-1.2.5.tar.gz
md5=81eb1034c6ef4421a2368a9b352199de
sha512=4b540497188a7d78f4f14f94c6b7fdff47dd06436a34e650ff378dd77bb3e2acb7afd45cd72daf4ddba06e732e9944d560c2882dc37862f1b1f1bb6df37e6205

doc/src/obus.upower/uPower_monitor.ml.html

Source file uPower_monitor.ml

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
34
35
(*
 * uPower_monitor.ml
 * -----------------
 * Copyright : (c) 2011, Jeremie Dimino <jeremie@dimino.org>
 * Licence   : BSD3
 *
 * This file is a part of obus, an ocaml implementation of D-Bus.
 *)

open Lwt_react
open Lwt

module String_map = Map.Make(String)

let changed interface =
  OBus_member.Signal.make
    ~interface
    ~member:"Changed"
    ~args:OBus_value.arg0
    ~annotations:[]

let monitor proxy interface switch =
  let%lwt event =
    OBus_signal.connect ~switch
      (OBus_signal.with_context
         (OBus_signal.make (changed interface) proxy))
  and context, dict = OBus_property.get_all_no_cache proxy interface in
  return (S.hold
            ~eq:(String_map.equal (=))
            (OBus_property.map_of_list context dict)
            (E.map_s
               (fun (context, ()) ->
                  let%lwt context, dict = OBus_property.get_all_no_cache proxy interface in
                  return (OBus_property.map_of_list context dict))
               event))
OCaml

Innovation. Community. Security.