Skip to content

Make geoclue optional #14

@Quackdoc

Description

@Quackdoc

If geoclue is not available for one reason or another, cosmic-settings-daemon will fail to run, the fix can be as simple as the below patch. I do however get the below stacktrace when doing this. I'm not sure if it's directly related or not. however this breaks setting theme in GTK applications. It takes a while for the segfault to occur. once it does occur, the theme can change once, and then never again afterwards.

diff --git a/src/main.rs b/src/main.rs
index 4f8e0c2..6cfce62 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -326,8 +326,11 @@ pub enum Change {
 
 #[tokio::main(flavor = "current_thread")]
 async fn main() -> zbus::Result<()> {
-    std::process::Command::new(GEOCLUE_AGENT.unwrap_or("/usr/libexec/geoclue-2.0/demos/agent"))
-        .spawn()?;
+    match std::process::Command::new(GEOCLUE_AGENT.unwrap_or("/usr/libexec/geoclue-2.0/demos/agent"))
+        .spawn(){
+            Ok(_) => println!("Geoclue started)"),
+            Err(e) => { println!("Geoclue failed with {}", e) }, 
+        }
     task::LocalSet::new()
         .run_until(async {
             let backlights = match backlight_enumerate() {
Click me
Geoclue failed with No such file or directory (os error 2)
Failed to watch theme org.freedesktop.DBus.Error.NoReply: Remote peer disconnected

Stack backtrace:
   0: anyhow::error::<impl core::convert::From<E> for anyhow::Error>::from
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/anyhow-1.0.81/src/error.rs:565:25
   1: <core::result::Result<T,F> as core::ops::try_trait::FromResidual<core::result::Result<core::convert::Infallible,E>>>::from_residual
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/result.rs:1963:27
   2: cosmic_settings_daemon::theme::watch_theme::{{closure}}
             at ./src/theme.rs:194:18
   3: cosmic_settings_daemon::main::{{closure}}::{{closure}}::{{closure}}
             at ./src/main.rs:461:66
   4: tokio::runtime::task::core::Core<T,S>::poll::{{closure}}
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/core.rs:328:17
   5: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/loom/std/unsafe_cell.rs:16:9
   6: tokio::runtime::task::core::Core<T,S>::poll
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/core.rs:317:13
   7: tokio::runtime::task::harness::poll_future::{{closure}}
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/harness.rs:485:19
   8: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panic/unwind_safe.rs:272:9
   9: std::panicking::try::do_call
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
  10: __rust_try
  11: std::panicking::try
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
  12: std::panic::catch_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
  13: tokio::runtime::task::harness::poll_future
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/harness.rs:473:18
  14: tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/harness.rs:208:27
  15: tokio::runtime::task::harness::Harness<T,S>::poll
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/harness.rs:153:15
  16: tokio::runtime::task::raw::poll
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/raw.rs:271:5
  17: tokio::runtime::task::raw::RawTask::poll
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/raw.rs:201:18
  18: tokio::runtime::task::LocalNotified<S>::run
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/mod.rs:416:9
  19: tokio::task::local::LocalSet::tick::{{closure}}
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/task/local.rs:676:63
  20: tokio::runtime::coop::with_budget
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/coop.rs:107:5
  21: tokio::runtime::coop::budget
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/coop.rs:73:5
  22: tokio::task::local::LocalSet::tick
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/task/local.rs:676:31
  23: <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll::{{closure}}
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/task/local.rs:982:16
  24: tokio::task::local::LocalSet::with::{{closure}}
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/task/local.rs:730:13
  25: std::thread::local::LocalKey<T>::try_with
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:270:16
  26: std::thread::local::LocalKey<T>::with
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:246:9
  27: tokio::task::local::LocalSet::with
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/task/local.rs:728:9
  28: <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/task/local.rs:968:9
  29: tokio::task::local::LocalSet::run_until::{{closure}}
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/task/local.rs:635:19
  30: cosmic_settings_daemon::main::{{closure}}
             at ./src/main.rs:566:10
  31: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/future/future.rs:125:9
  32: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}::{{closure}}
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/current_thread/mod.rs:659:57
  33: tokio::runtime::coop::with_budget
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/coop.rs:107:5
  34: tokio::runtime::coop::budget
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/coop.rs:73:5
  35: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/current_thread/mod.rs:659:25
  36: tokio::runtime::scheduler::current_thread::Context::enter
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/current_thread/mod.rs:404:19
  37: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/current_thread/mod.rs:658:36
  38: tokio::runtime::scheduler::current_thread::CoreGuard::enter::{{closure}}
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/current_thread/mod.rs:737:68
  39: tokio::runtime::context::scoped::Scoped<T>::set
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/context/scoped.rs:40:9
  40: tokio::runtime::context::set_scheduler::{{closure}}
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/context.rs:176:26
  41: std::thread::local::LocalKey<T>::try_with
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:270:16
  42: std::thread::local::LocalKey<T>::with
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:246:9
  43: tokio::runtime::context::set_scheduler
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/context.rs:176:9
  44: tokio::runtime::scheduler::current_thread::CoreGuard::enter
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/current_thread/mod.rs:737:27
  45: tokio::runtime::scheduler::current_thread::CoreGuard::block_on
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/current_thread/mod.rs:646:19
  46: tokio::runtime::scheduler::current_thread::CurrentThread::block_on::{{closure}}
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/current_thread/mod.rs:175:28
  47: tokio::runtime::context::runtime::enter_runtime
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/context/runtime.rs:65:16
  48: tokio::runtime::scheduler::current_thread::CurrentThread::block_on
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/current_thread/mod.rs:167:9
  49: tokio::runtime::runtime::Runtime::block_on
             at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/runtime.rs:348:47
  50: cosmic_settings_daemon::main
             at ./src/main.rs:329:5
  51: core::ops::function::FnOnce::call_once
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:250:5
  52: std::sys_common::backtrace::__rust_begin_short_backtrace
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:154:18
  53: std::rt::lang_start::{{closure}}
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:167:18
  54: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:284:13
  55: std::panicking::try::do_call
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
  56: std::panicking::try
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
  57: std::panic::catch_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
  58: std::rt::lang_start_internal::{{closure}}
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:148:48
  59: std::panicking::try::do_call
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
  60: std::panicking::try
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
  61: std::panic::catch_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
  62: std::rt::lang_start_internal
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:148:20
  63: std::rt::lang_start
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:166:17
  64: main
  65: <unknown>
  66: __libc_start_main
  67: _start. Will try again in 0s

EDIT: installed geoclue and recompiled the app with proper envvar and it now works fine without segfault, so it does seem related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions