Coder Social home page Coder Social logo

bilelmoussaoui / ashpd Goto Github PK

View Code? Open in Web Editor NEW
230.0 7.0 43.0 2.16 MB

A Rust wrapper around XDG portals DBus interfaces

Home Page: https://bilelmoussaoui.github.io/ashpd/ashpd/

License: MIT License

Rust 98.45% Shell 0.33% Meson 1.12% CSS 0.10%
libportal flatpak xdg portals rust zbus wrapper

ashpd's People

Contributors

a6gibkm avatar alatiera avatar apricotbucket28 avatar baarkerlounger avatar bertob avatar bilelmoussaoui avatar carlosmn avatar cogitri avatar d2weber avatar dependabot[bot] avatar feschber avatar finefindus avatar hfiguiere avatar hofer-julian avatar ids1024 avatar jimmac avatar jneem avatar jtojnar avatar msizanoen1 avatar newbytee avatar olivierlemasle avatar polymeilex avatar seadve avatar sophie-h avatar t0b1-ios avatar tom-a-wagner avatar wash2 avatar whot avatar wjt avatar zeenix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ashpd's Issues

Release v0.1

  • Desktop portals:
  • account.rs
  • background.rs
  • camera.rs
  • device.rs
  • email.rs
  • file_chooser.rs
  • game_mode.rs
  • inhibit.rs
  • location.rs
  • memory_monitor.rs
  • network_monitor.rs
  • notification.rs
  • open_uri.rs
  • print.rs
  • remote_desktop.rs
  • screencast.rs
  • screenshot.rs
  • secret.rs
  • settings.rs
  • trash.rs
  • wallpaper.rs
  • Documents
  • documents.rs
  • file_transfer.rs
  • Flatpak
  • flatpak.rs
  • update_monitor.rs

Sometimes get `Invalid client serial`

It is very hard to reproduce as it happens very rarely. Although, it is reproducible from the demo through screencast by creating a session. (Haven't tested other)

The log shows the following:
** (process:43167): WARNING **: 14:41:02.960: Invalid client serial

The process 43167, according to system monitor, is xdg-dbus-proxy.

I'll add some additional information, ill try to debug

Provide server side of the portals interfaces

This would allow people to write a portals implementations in rust.

Very low priority, just in case might want to work on this

  • org.freedesktop.impl.portal.Access — Interface for presenting an access dialog
  • org.freedesktop.impl.portal.Account — Backend for the portal for obtaining user information
  • org.freedesktop.impl.portal.AppChooser — Interface for choosing an application
  • org.freedesktop.impl.portal.Background — Background portal backend interface
  • org.freedesktop.impl.portal.Email — Email portal backend interface
  • org.freedesktop.impl.portal.FileChooser — File chooser portal backend interface
  • org.freedesktop.impl.portal.GlobalShortcuts
  • org.freedesktop.impl.portal.Inhibit — Inhibit portal backend interface
  • org.freedesktop.impl.portal.Lockdown — Lockdown backend interface
  • org.freedesktop.impl.portal.Notification — Notification portal backend interface
  • org.freedesktop.impl.portal.PermissionStore — Database to store permissions
  • org.freedesktop.impl.portal.Print — Print portal backend interface
  • org.freedesktop.impl.portal.RemoteDesktop — Remote desktop portal backend interface
  • org.freedesktop.impl.portal.Request — Shared request interface
  • org.freedesktop.impl.portal.ScreenCast — Screen cast portal backend interface
  • org.freedesktop.impl.portal.Screenshot — Screenshot portal backend interface
  • org.freedesktop.impl.portal.Secret — Secret portal backend interface
  • org.freedesktop.impl.portal.Session — Shared session interface
  • org.freedesktop.impl.portal.Settings — Settings portal backend interface
  • org.freedesktop.impl.portal.Wallpaper — Portal for setting the desktop's Wallpaper

Issue when reading color-scheme key

I'm getting the following error when trying to use the color_scheme() method or trying to read it directly with the read() method.

Error: ZBus Error: incorrect type

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let connection = ashpd::zbus::Connection::session().await?;
    let proxy = ashpd::desktop::settings::SettingsProxy::new(&connection).await?;
    let color_scheme = proxy.color_scheme().await?;
    match color_scheme {
        ashpd::desktop::settings::ColorScheme::PreferDark => println!("Dark"),
        ashpd::desktop::settings::ColorScheme::PreferLight => println!("Light"),
        ashpd::desktop::settings::ColorScheme::NoPreference => println!("Default"),
    };
    Ok(())
}

I'm able to get the key using qdbus

qdbus org.freedesktop.portal.Desktop /org/freedesktop/portal/desktop org.freedesktop.portal.Settings.Read "org.freedesktop.appearance" "color-scheme"

Output: 1

Backtrace

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Zbus(Variant(IncorrectType))', examples/color_scheme.rs:5:51
stack backtrace:
   0:     0x55bd3181d350 - std::backtrace_rs::backtrace::libunwind::trace::he615646ea344481f
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x55bd3181d350 - std::backtrace_rs::backtrace::trace_unsynchronized::h6ea8eaac68705b9c
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x55bd3181d350 - std::sys_common::backtrace::_print_fmt::h7ac486a935ce0bf7
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x55bd3181d350 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1b5a095d3db2e28f
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x55bd3183d60e - core::fmt::write::h445545b92224a1cd
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/fmt/mod.rs:1209:17
   5:     0x55bd31818155 - std::io::Write::write_fmt::h55a43474c6520b00
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/io/mod.rs:1682:15
   6:     0x55bd3181d115 - std::sys_common::backtrace::_print::h65d20526fdb736b0
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x55bd3181d115 - std::sys_common::backtrace::print::h6555fbe12a1cc41b
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x55bd3181e9cf - std::panicking::default_hook::{{closure}}::hbdf58083140e7ac6
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:267:22
   9:     0x55bd3181e70a - std::panicking::default_hook::haef8271c56b74d85
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:286:9
  10:     0x55bd3181f0c8 - std::panicking::rust_panic_with_hook::hfd45b6b6c12d9fa5
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:688:13
  11:     0x55bd3181ee67 - std::panicking::begin_panic_handler::{{closure}}::hf591e8609a75bd4b
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:579:13
  12:     0x55bd3181d7fc - std::sys_common::backtrace::__rust_end_short_backtrace::h81899558795e4ff7
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:137:18
  13:     0x55bd3181eb82 - rust_begin_unwind
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:575:5
  14:     0x55bd312dc8e3 - core::panicking::panic_fmt::h4235fa9b4675b332
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/panicking.rs:65:14
  15:     0x55bd312dcba3 - core::result::unwrap_failed::ha17dbf463031a5e1
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/result.rs:1791:5
  16:     0x55bd312e0565 - core::result::Result<T,E>::unwrap::hc76bc8ef087a958f
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/result.rs:1113:23
  17:     0x55bd312e7beb - color_scheme::main::{{closure}}::h676b74a31767720a
                               at /home/eduardo/Developer/GitHub/edfloreshz/rust-dark-light/examples/color_scheme.rs:5:24
  18:     0x55bd312e718c - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h9c10be68a6c43cf0
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/future/mod.rs:91:19
  19:     0x55bd312e9b50 - tokio::runtime::park::CachedParkThread::block_on::{{closure}}::ha9c0fb5922d248b9
                               at /home/eduardo/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.23.0/src/runtime/park.rs:283:63
  20:     0x55bd312e9959 - tokio::runtime::coop::with_budget::h374a6eb4c304d124
                               at /home/eduardo/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.23.0/src/runtime/coop.rs:102:5
  21:     0x55bd312e9959 - tokio::runtime::coop::budget::hb7696c2b75afcb45
                               at /home/eduardo/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.23.0/src/runtime/coop.rs:68:5
  22:     0x55bd312e9959 - tokio::runtime::park::CachedParkThread::block_on::h881e06b99f70fb52
                               at /home/eduardo/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.23.0/src/runtime/park.rs:283:31
  23:     0x55bd312e82f5 - tokio::runtime::context::BlockingRegionGuard::block_on::h08783a21d0edfcfe
                               at /home/eduardo/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.23.0/src/runtime/context.rs:295:13
  24:     0x55bd312e9fd5 - tokio::runtime::scheduler::multi_thread::MultiThread::block_on::h3159921632df782c
                               at /home/eduardo/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.23.0/src/runtime/scheduler/multi_thread/mod.rs:66:9
  25:     0x55bd312eb449 - tokio::runtime::runtime::Runtime::block_on::h084150448d13be7b
                               at /home/eduardo/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.23.0/src/runtime/runtime.rs:284:45
  26:     0x55bd312ea1a7 - color_scheme::main::h9b8b51354d52e12e
                               at /home/eduardo/Developer/GitHub/edfloreshz/rust-dark-light/examples/color_scheme.rs:6:5
  27:     0x55bd312df37b - core::ops::function::FnOnce::call_once::hf3dbfc3dd1633528
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/ops/function.rs:251:5
  28:     0x55bd312e454e - std::sys_common::backtrace::__rust_begin_short_backtrace::h93f5f078ce0a1b23
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:121:18
  29:     0x55bd312e8871 - std::rt::lang_start::{{closure}}::h6b8a395c99773c0f
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/rt.rs:166:18
  30:     0x55bd3181432b - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h072eb4cd8da964ba
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/ops/function.rs:286:13
  31:     0x55bd3181432b - std::panicking::try::do_call::h8eca204fe9266946
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:483:40
  32:     0x55bd3181432b - std::panicking::try::h12574e1b7b2cbacb
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:447:19
  33:     0x55bd3181432b - std::panic::catch_unwind::hf71522d4448329d6
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panic.rs:137:14
  34:     0x55bd3181432b - std::rt::lang_start_internal::{{closure}}::h65b66ac9bff580f8
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/rt.rs:148:48
  35:     0x55bd3181432b - std::panicking::try::do_call::hfff61e33ca3db9f1
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:483:40
  36:     0x55bd3181432b - std::panicking::try::he48c8ecead279cad
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:447:19
  37:     0x55bd3181432b - std::panic::catch_unwind::hd510a26bfc950ccc
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panic.rs:137:14
  38:     0x55bd3181432b - std::rt::lang_start_internal::hc680b25eab888da9
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/rt.rs:148:20
  39:     0x55bd312e884a - std::rt::lang_start::hd05f42c2454c1d0c
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/rt.rs:165:17
  40:     0x55bd312ea25e - main
  41:     0x7f1363629d90 - <unknown>
  42:     0x7f1363629e40 - __libc_start_main
  43:     0x55bd312dcd85 - _start
  44:                0x0 - <unknown>

Screencast request fails with Other

image
This is just running the demo, same thing happens if I try to actually write/use code, the error is throne at the

let session = proxy.create_session();

for when trying to do this in code. Error: Portal request didn't succeed: Other

Make response fields selectable

I am playing with SaveFile, and want to copy the response uri to the 'current file' field for another request.

Making data selectable is always a good idea.

`Documents::add_full` errors with `InvalidAppID` if `app_id` is empty string

This function is supposed to take an app ID or an empty string, but TryFrom<String> calls is_valid_app_id, which returns false for empty strings.

This should also apply to add_named_full and list.

Would it be better to skip using a TryFrom generic here, and accept Option<AppId>? That would probably be more idiomatic, and let the caller deal with (fallible) conversion.

Better OpenURI support

From irc:

trying openuri, I added a file:/// uri for a pdf file, and then I click request
ashpd tells me "success", but nothing happens
and looking at the verbose portal output, it tells me that it refuses to handle file:// uris
it would be nice if a) ashpd didn't lie about the success and b) it used OpenFile instead of OpenUri for file uris

Demo: Is Camera Available label

The label gets updated when one tries to start streaming. The flow should be something like

  • Initial state: 'Unknown'
  • Once the stack page is visible call is_camera_available and set the label as "Yes" or "No" depending on the output.

Provide a wrapper for GIcon

The notification/dynamic launcher portals expect a serialized GIcon, currently there is no easy way for apps to provide that if they are not using gtk and even then you can't easily pass the result of a g_icon_serialize as a zvariant::Value.

The idea is to provide an enum that implements Serialize/Deserialize in a similar way how g_icon_serialize/ g_icon_deserialize works

Make use of PortalError

Some of the method calls should make use of that as an error type internally so that we map the dbus errors to their actual rust counterparts

use a URI type from a library instead of plain Strings

The D-Bus API makes use of URIs in several places, for example FileChooser. ashpd currently treats these URIs as std::string::Strings. It could be helpful to downstream developers to use a URI type from another crate for these URIs instead of simple Strings. I ran into an issue where I was not properly handling URI encoding which would have been easier to prevent if ashpd encoded more information about the data from the D-Bus API than treating it as a generic String.

conversion from WindowIdentifier to raw_window_handle::RawWindowHandle

raw_window_handle is a cross platform library abstracting over window handles for various windowing systems, including Wayland and X11. For cross platform code using ashpd, for example rfd, it would be helpful for ashpd to provide an API to convert its WindowIdentifier type to raw_window_handle's RawWindowHandle type. Alternatively, perhaps ashpd could switch to using RawWindowHandle in its own API.

desktop::background: Example does not work

The output looks fine

true
true

but nothing happens, nothing in the logs. I am currently running this outside of flatpak. I also tried logger test to get a syslog entry, but also doesn't work.

$ flatpak --version
Flatpak 1.10.1

Handle activation_token

Some of the portals that requires a user interaction makes use of the wayland activation_token to activate/focus the window that requires the interaction.

We will need some way of automatically fetching that, maybe by making WindowIdentifier handle that as well

Deadlock inside gtk3/gtk4 WindowIdentifier backends

I was trying Kooha on Plasma Wayland and observed that it doesn't do anything after (kooha:2265): Gdk-WARNING **: 20:42:02.271: Server is missing xdg_foreign support. Looking at

top_level.export_handle(clone!(@strong sender => move |_, handle| {
let ctx = glib::MainContext::default();
let handle = handle.to_owned();
ctx.spawn_local(clone!(@strong sender, @strong handle => async move {
if let Some(m) = sender.lock().await.take() {
let _ = m.send(handle);
}
}));
}));
let handle = receiver.await.ok();
wayland_win.export_handle(clone!(@strong sender => move |_, handle| {
let ctx = glib::MainContext::default();
let handle = handle.to_owned();
ctx.spawn_local(clone!(@strong sender, @strong handle => async move {
if let Some(m) = sender.lock().await.take() {
let _ = m.send(handle);
}
}));
}));
let handle = receiver.await.ok();
I believe it deadlocks as the callback is never called. According to https://gtk-rs.org/gtk4-rs/stable/latest/docs/gdk4_wayland/struct.WaylandToplevel.html#method.export_handle and https://gtk-rs.org/gtk3-rs/stable/latest/docs/gdkwayland/struct.WaylandWindow.html#method.export_handle, export_handle has return argument that can be checked to know whether the call succeeded.

Open things on the correct `$DISPLAY`.

This may be an upstream issue, but here it is anyway: if I'm running multiple X servers on different ttys, there's a chance that the file dialog I request pops up on the wrong X server. I'm running arch linux, and it uses per-user (as opposed to per-session) dbus daemons.

Steps to reproduce:

  1. Clone the repo here
  2. Run two X servers on different ttys.
  3. Go to one of the ttys, cd to your git clone, run cargo run. If the file dialog shows up, switch to the other tty and repeat. At least one of them will show the file dialog on the other tty.

`--filesystem=xdg-run/pipewire-0` reduces security

ashpd/src/desktop/camera.rs

Lines 121 to 122 in e082795

/// *Note* using this method requires access to `xdg-run/pipewire-0` which sandboxed applications don't have access to.
/// In the case of Flatpak, make sure to add `--filesystem=xdg-run/pipewire-0` to your `finish-args`.

The portal doesn't return a node ID, but you can use the file descriptor returned by the portal to iterate the camera node IDs, making exposing xdg-run/pipewire-0 unneccesary. The portal sets up security restrictions on the socket before returning the socket to the application, but always ensures that the application can iterate and access camera devices.
--filesystem=xdg-run/pipewire-0 is insecure as it allows the application to effectively bypass the permission prompt.

WindowIdentifier::from_native() may only be called once for Wayland GTK windows

Hello,

it seems like WindowIndentifier::from_native() can only be called once, otherwise the following GCritical is emitted:

(dev.Cogitri.Health:21): Gdk-CRITICAL **: 12:22:08.835: gdk_wayland_toplevel_export_handle: assertion '!impl->display_server.xdg_exported' failed

This GCritical origins from gdk_wayland_toplevel_export_handle. The documentation for that function says:

* gdk_wayland_toplevel_export_handle:
[...]
* It is an error to call this function on a surface that is already
* exported.

Not sure what would be the best way to handle this, should we just put a notice in the docs?

Account crashes when user does not have an icon

In GNOME 43 on NixOS, I tried requesting an account but the app crashed with the following:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { domain: g-file-error-quark, code: 4, message: "Failed to open file “/home/jtojnar/.face”: No such file or directory" }', src/portals/desktop/account.rs:84:66

Add more Portals to demo

The Demo does currently not support all Portals. Would be nice, if you could add the missing Portals to the Demo.

Consider making X11 integration optional

I build GTK 4 without X11 support, as I exclusively use Wayland on my systems, and this prevents this crate from building, with the given error log:

The following warnings were emitted during compilation:                                                                                                                                           
                                                                                                                                                                                                  
warning: `"pkg-config" "--libs" "--cflags" "gtk4-x11" "gtk4-x11 >= 4.0.0"` did not exit successfully: exit status: 1                                                                              
                                                                                                                                                                                                  
error: failed to run custom build command for `gdk4-x11-sys v0.4.2`                                                                                                                               
                                                                                                                                                                                                  
Caused by:                                                                                                                                                                                        
  process didn't exit successfully: `/home/linkmauve/dev/rust/amberol/build/target/debug/build/gdk4-x11-sys-eae7525ab06d408a/build-script-build` (exit status: 1)                                 
  --- stdout                                                                                                                                                                                      
  cargo:rerun-if-env-changed=GTK4_X11_NO_PKG_CONFIG                                                                                                                                               
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu                                                                                                                                  
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu                                                                                                                                  
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG                                                                                                                                                      
  cargo:rerun-if-env-changed=PKG_CONFIG                                                                                                                                                           
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu                                                                                                                             
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu                                                                                                                             
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH                                                                                                                                                 
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH                                                                                                                                                      
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu                                                                                                                           
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu                                                                                                                           
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR                                                                                                                                               
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR                                                                                                                                                    
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu                                                                                                                      
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu                                                                                                                      
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR                                                                                                                                          
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR                                                                                                                                               
  cargo:warning=`"pkg-config" "--libs" "--cflags" "gtk4-x11" "gtk4-x11 >= 4.0.0"` did not exit successfully: exit status: 1                                           
  error: could not find system library 'gtk4-x11' required by the 'gdk4-x11-sys' crate                                                                                                            
                                                                                                                                                                                                  
  --- stderr                                                                                                                                                                                      
  Package gtk4-x11 was not found in the pkg-config search path.                                                                                                                                   
  Perhaps you should add the directory containing `gtk4-x11.pc'                                                                                                                                   
  to the PKG_CONFIG_PATH environment variable                                                                                                                                                     
  Package 'gtk4-x11', required by 'virtual:world', not found                                                                                                                                      
  Package 'gtk4-x11', required by 'virtual:world', not found                                                                                                                                      

warning: build failed, waiting for other jobs to finish...

Trash Portal fails inside a Flatpak

When I try to use trash::trash_file() inside a Flatpak, it fails.

Heres the error I get with my small test program when its running inside a Flatpak.

An error occured while trying to trash the test file: Portal request failed: org.freedesktop.portal.Error.Failed: no description

Examples don't work properly

Hi, I'm currently trying to use ashpd to get a PipeWire video stream to extract the mouse metadata (position, specifically).

However, when I try the examples given in the README, it fails on the use ashpd:: portion:

  |
1 | use ashpd::desktop::screenshot::ColorResponse;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `ColorResponse` in `desktop::screenshot`

Is there some other way I'm supposed to use this?

Convenient and dependency-minimal WindowIdentifier creation

If I have an XID or a wayland surface, I can convert it to WindowIdentifier using from_raw_handle. But, it requires the "raw_handle" feature (including potentially unnecessary dependencies) and a side-trip through RawWindowHandle. It would be nice to have a more direct path.

#51 has a quick fix for x11, but a wayland version would be nice too (and maybe there's a better way to organize them? #51 was literally just the first thing that I thought of)

How to run the example

Is there any way of running the example?

I got this error when trying to start screen sharing when I ran the flat pack example and I wanted to try to troubleshoot it.

2022-03-01T21:00:51.806977Z ERROR ashpd_demo::portals::desktop::screencast: Zbus(
    Variant(
        Message(
            "missing field `streams`",
        ),
    ),
)

ashpd-demo failed to start a screen cast session when org.freedesktop.portal.Desktop is not launched already

Env: the lastest archlinux with GNOME

This is the error message.

Sep 14 21:26:59.638 ERROR ashpd_demo::portals::desktop::screencast: Portal(
    ZBus(
        FDO(
            NameHasNoOwner(
                "Could not get owner of name 'org.freedesktop.portal.Desktop': no such name",
            ),
        ),
    ),
)

It seems that the org.freedesktop.portal.Desktop service is not start automatically. ashpd-demo works fine after I launch the service manually.

Can't create a FileFilter with no name

Creating a FileFilter with an empty name (FileFilter::new("")) makes the OpenFile portal to error out. I think it is generally possible to create an unnamed filter, or at least this seems possible with GtkFileChooserNative, so I guess this is a bug.

Feature: function that tells if inside flatpak

As we have seen with the background portal, there are cases where it is required to know if an app is run inside a flatpak or not. Maybe this would fit for ashpd?

xdg-open uses the existence of $XDG_RUNTIME_DIR/flatpak-info as indicator. I also spotted

FLATPAK_ID=...
container=flatpak

which might be better because they can be overwritten?

Demo: Selecting the select sources window itself cause weird issues

When you select a window in select sources window, and pick the select sources window itself from the selection. It sometimes crash, and when it doesn't, it will make the parts of the demo, where the window identifier needs to be exported unusable, unless you restart the demo.

Kooha.08-04-2021.17.48.12.mp4

Support camera rotation in the demo Gstreamer pipeline

The ashpd-demo is an awesome example for how to use the camera portal, however it currently lacks rotation support which is needed on many mobile devices as their cameras are often mounted rotated and the drivers don't support transparently per-rotating the image. Here's an example from the Pinephone Pro:
many-camera-apps

On the right side you see the output from https://gitlab.gnome.org/-/snippets/4781, providing a simple example for how to enable it with a Gstreamer element that supports rotate-method=auto. That property doesn't have to be supported by the sink though - other possible elements that could do the job include glvideoflip and videoflip.


Related:

Blocking API

If I want to wait for a result (using the non-async API), it looks something like:

    let connection = Connection::new_session()?;
    let proxy = FileChooserProxy::new(&connection);
    let req = proxy.open_file(Default::default(), "Title", Default::default())?;

    req.connect_response(|r: Response<SelectedFiles>| {
        // Do something
        Ok(())
    })?;
    while reply.next_signal()?.is_some() {}

Would you consider adding (or accepting a PR to add) an API that just blocks until a response is ready? Like:

    let connection = Connection::new_session()?;
    let proxy = FileChooserProxy::new(&connection);
    let selected: SelectedFiles = proxy.open_file(Default::default(), "Title", Default::default())?;

Or maybe something in between, which would still allow for cancellation:

    let connection = Connection::new_session()?;
    let proxy = FileChooserProxy::new(&connection);
    let req = proxy.open_file(Default::default(), "Title", Default::default())?;
    let selected: SelectedFiles = req.response()?;

It would be even cooler if the type of req encoded the fact that the response has to be of type SelectedFiles. Although from what I can tell, doing this would involve some changes to the dbus_proxy macro...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.