You should use HAL and/or DBUS for this.