Exemplo n.º 1
0
func setTimezone(conn *dbus.Conn, timezone string) error {
	timedate := conn.Object(TimedateBus, "/org/freedesktop/timedate1")
	return timedate.Call(
		TimedateInterface+".SetTimezone",
		0,
		timezone,
		false).Err
}
Exemplo n.º 2
0
func NewGeoclueClient(conn *dbus.Conn) (*GeoclueClient, error) {
	manager := conn.Object(
		GeoclueBus,
		"/org/freedesktop/GeoClue2/Manager",
	)

	var clientPath dbus.ObjectPath

	if err := manager.Call(
		GeoclueManagerInterface+".GetClient",
		0,
	).Store(&clientPath); err != nil {
		return nil, err
	}

	clientObject := conn.Object(
		GeoclueBus,
		clientPath,
	)

	if err := clientObject.SetProperty(
		GeoclueClientInterface+".DistanceThreshold",
		dbus.MakeVariant(uint32(1000)),
	); err != nil {
		return nil, err
	}

	if err := clientObject.SetProperty(
		GeoclueClientInterface+".RequestedAccuracyLevel",
		dbus.MakeVariant(uint32(GCLUE_ACCURACY_LEVEL_CITY)),
	); err != nil {
		return nil, err
	}

	if err := clientObject.SetProperty(
		GeoclueClientInterface+".DesktopId",
		dbus.MakeVariant("localtimed"),
	); err != nil {
		return nil, err
	}

	return &GeoclueClient{
		client: clientObject,
		conn:   conn,
		done:   nil,
	}, nil
}