-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e1d65a
commit ad3c171
Showing
9 changed files
with
1,121 additions
and
441 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,80 @@ | ||
Displays system power information such as the battery percentage, and estimated time to empty. | ||
|
||
`TODO: ADD SCREENSHOT` | ||
|
||
[//]: # (![Screenshot](https://user-images.githubusercontent.com/5057870/184540521-2278bdec-9742-46f0-9ac2-58a7b6f6ea1d.png)) | ||
|
||
|
||
## Configuration | ||
|
||
> Type: `upower` | ||
| Name | Type | Default | Description | | ||
|----------|----------|-----------------|---------------------------------------------------| | ||
| `format` | `string` | `{percentage}%` | Format string to use for the widget button label. | | ||
|
||
<details> | ||
<summary>JSON</summary> | ||
|
||
```json | ||
{ | ||
"end": [ | ||
{ | ||
"type": "upower", | ||
"format": "{percentage}%" | ||
} | ||
] | ||
} | ||
|
||
``` | ||
|
||
</details> | ||
|
||
<details> | ||
<summary>TOML</summary> | ||
|
||
```toml | ||
[[end]] | ||
type = "upower" | ||
format = "{percentage}%" | ||
``` | ||
|
||
</details> | ||
|
||
<details> | ||
<summary>YAML</summary> | ||
|
||
```yaml | ||
end: | ||
- type: "upower" | ||
format: "{percentage}%" | ||
``` | ||
</details> | ||
<details> | ||
<summary>Corn</summary> | ||
```corn | ||
{ | ||
end = [ | ||
{ | ||
type = "upower" | ||
format = "{percentage}%" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
</details> | ||
|
||
## Styling | ||
|
||
| Selector | Description | | ||
|---------------------------------|-----------------------------| | ||
| `#upower` | Upower widget container. | | ||
| `#upower #icon` | Upower widget battery icon. | | ||
| `#upower #button` | Upower widget button. | | ||
| `#upower #button #label` | Upower widget button label. | | ||
| `#popup-upower` | Clock popup box. | | ||
| `#popup-upower #upower-details` | Label inside the popup. | |
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
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,40 @@ | ||
use async_once::AsyncOnce; | ||
use lazy_static::lazy_static; | ||
use std::sync::Arc; | ||
use upower_dbus::UPowerProxy; | ||
use zbus::fdo::PropertiesProxy; | ||
|
||
lazy_static! { | ||
static ref DISPLAY_PROXY: AsyncOnce<Arc<PropertiesProxy<'static>>> = AsyncOnce::new(async { | ||
let dbus = zbus::Connection::system() | ||
.await | ||
.expect("failed to create connection to system bus"); | ||
|
||
let device_proxy = UPowerProxy::new(&dbus) | ||
.await | ||
.expect("failed to create upower proxy"); | ||
|
||
let display_device = device_proxy | ||
.get_display_device() | ||
.await | ||
.unwrap_or_else(|_| panic!("failed to get display device for {device_proxy:?}")); | ||
|
||
let path = display_device.path().to_owned(); | ||
|
||
let proxy = PropertiesProxy::builder(&dbus) | ||
.destination("org.freedesktop.UPower") | ||
.expect("failed to set proxy destination address") | ||
.path(path) | ||
.expect("failed to set proxy path") | ||
.cache_properties(zbus::CacheProperties::No) | ||
.build() | ||
.await | ||
.expect("failed to build proxy"); | ||
|
||
Arc::new(proxy) | ||
}); | ||
} | ||
|
||
pub async fn get_display_proxy() -> &'static PropertiesProxy<'static> { | ||
DISPLAY_PROXY.get().await | ||
} |
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
Oops, something went wrong.