From cb8032c7c2755769ae44e96eb8be7d3f33156e6d Mon Sep 17 00:00:00 2001 From: Luke Date: Mon, 8 Jun 2020 19:54:07 +1200 Subject: [PATCH] Create AniMe device only if physical device exists The call to create the device handler will return with an error if the physical device doesn't exist, the device (if exists) is stored in an option already so just keep that as `None` if errored. Addresses issue #14 --- README.md | 4 ++++ rog-core/src/animatrix_control.rs | 2 +- rog-core/src/daemon.rs | 6 ++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 74554799..4334e89c 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,10 @@ sudo systemctl enable rog-core.service Thanks to @aspann you can grab it here [sys-power/rog-core](https://lab.retarded.farm/zappel/zGentoo/-/tree/master/sys-power/rog-core) +### Arch AUR + +You can find the thingimajig [here](https://aur.archlinux.org/packages/rog-core/) + ## Updating Occasionally I might break things for you by tweaking or changing the config file layout. Usually this will mean you diff --git a/rog-core/src/animatrix_control.rs b/rog-core/src/animatrix_control.rs index e734e5dc..f0d34bb2 100644 --- a/rog-core/src/animatrix_control.rs +++ b/rog-core/src/animatrix_control.rs @@ -33,7 +33,7 @@ impl AniMeWriter { pub fn new() -> Result> { // We don't expect this ID to ever change let mut dev_handle = AniMeWriter::get_device(0x0b05, 0x193b).map_err(|err| { - error!("Could not get device handle: {:?}", err); + error!("Could not get AniMe display handle: {:?}", err); err })?; // This config seems to be the required device config for writing diff --git a/rog-core/src/daemon.rs b/rog-core/src/daemon.rs index d6eb2670..c28b32c1 100644 --- a/rog-core/src/daemon.rs +++ b/rog-core/src/daemon.rs @@ -69,8 +69,10 @@ pub async fn start_daemon() -> Result<(), Box> { // Possible Animatrix let mut animatrix_writer = None; if laptop.support_animatrix() { - animatrix_writer = Some(AniMeWriter::new()?); - info!("Device has an AniMe Matrix display"); + if let Ok(dev) = AniMeWriter::new() { + animatrix_writer = Some(dev); + info!("Device has an AniMe Matrix display"); + } } // Set up the mutexes