pop-os / cosmic-settings-daemon

GNU General Public License v3.0
20 stars 16 forks source link

Make geoclue optional #14

Open Quackdoc opened 5 months ago

Quackdoc commented 5 months ago

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:: for anyhow::Error>::from at /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/anyhow-1.0.81/src/error.rs:565:25 1: as core::ops::try_trait::FromResidual>>::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::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::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::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: 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::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::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::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: 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::try_with at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:270:16 26: std::thread::local::LocalKey::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: 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: 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::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::try_with at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:270:16 42: std::thread::local::LocalKey::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:: 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: 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

ikeycode commented 4 months ago

In addition, when distros use a "weird" libexecdir for geoclue, the same thing occurs, as seen in Solus:

/usr/lib64/geoclue/geoclue-2.0/demos/agent

Quackdoc commented 4 months ago

@ikeycode you can set the location at compile time export GEOCLUE_AGENT="/usr/lib64/geoclue/geoclue-2.0/demos/agent" cargo build...

ikeycode commented 4 months ago

I don't doubt that you can :) However without any kind of configure or build option summary, or digging into the Makefile (when the git submodules repo uses justfile) - this isn't remotely obvious.

On Sun, 21 Apr 2024, 18:21 Mitchel Stewart, @.***> wrote:

@ikeycode https://github.com/ikeycode you can set the location at compile time export GEOCLUE_AGENT="/usr/lib64/geoclue/geoclue-2.0/demos/agent" cargo build...

— Reply to this email directly, view it on GitHub https://github.com/pop-os/cosmic-settings-daemon/issues/14#issuecomment-2068140202, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMWLIWQEPLF5WGAYHCZY36TY6PYQPAVCNFSM6AAAAABFHY4OT6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRYGE2DAMRQGI . You are receiving this because you were mentioned.Message ID: @.***>

Calandracas606 commented 3 weeks ago

I was also seeing this issue when geoclue2 isn't installed.

A more useful error message would be helpful.

Is geoclue a hard requirement? It would be nice if the program didn't crash when its not available.