-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create SensorManager, detect before accel search result (#388)
- Loading branch information
1 parent
25bdb7e
commit ecbc33f
Showing
4 changed files
with
64 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* SPDX-License-Identifier: LGPL-2.0-or-later | ||
* SPDX-FileCopyrightText: 2024 elementary, Inc. (https://elementary.io) | ||
*/ | ||
|
||
[DBus (name = "net.hadess.SensorProxy")] | ||
public interface Display.SensorProxy : GLib.DBusProxy { | ||
public abstract bool has_accelerometer { get; } | ||
} | ||
|
||
public class Display.SensorManager : Object { | ||
public bool has_accelerometer { get; private set; } | ||
|
||
private static GLib.Once<SensorManager> instance; | ||
public static unowned SensorManager get_default () { | ||
return instance.once (() => new SensorManager ()); | ||
} | ||
|
||
private class SensorManager () { } | ||
|
||
construct { | ||
try { | ||
// Synchronous otherwise search might be false negative | ||
SensorProxy sensor_proxy = Bus.get_proxy_sync (BusType.SYSTEM, "net.hadess.SensorProxy", "/net/hadess/SensorProxy"); | ||
has_accelerometer = sensor_proxy.has_accelerometer; | ||
} catch (Error e) { | ||
info ("Unable to connect to SensorProxy bus, probably means no accelerometer supported: %s", e.message); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters