Find flatpak apps in flatpak mode (#308)

* Call flatpak-spawn when in flatpak mode

* Also test flatpak feature on unix

* Update readme with flatpak-flatpak support

* Update to version 1.7.18
This commit is contained in:
Philip Kristoffersen
2023-01-03 17:48:13 +01:00
committed by GitHub
parent 1db73bd0e7
commit f1591b7818
6 changed files with 37 additions and 10 deletions
+25 -7
View File
@@ -37,13 +37,7 @@ impl NeedsPorton<FlatpakPlatform> for FlatpakApp {
impl FlatpakPlatform {
fn get_flatpak_apps(&self) -> eyre::Result<Vec<FlatpakApp>> {
use std::process::Command;
let mut command = Command::new("flatpak");
let output = command
.arg("list")
.arg("--app")
.arg("--columns=name,application")
.output()?;
let output = get_flatpak_applications()?;
let output_string = String::from_utf8_lossy(&output.stdout).to_string();
let mut result = vec![];
for line in output_string.lines() {
@@ -61,6 +55,30 @@ impl FlatpakPlatform {
}
}
fn get_flatpak_applications() -> std::io::Result<std::process::Output> {
use std::process::Command;
#[cfg(not(feature = "flatpak"))]
{
let mut command = Command::new("flatpak");
command
.arg("list")
.arg("--app")
.arg("--columns=name,application")
.output()
}
#[cfg(feature = "flatpak")]
{
let mut command = Command::new("flatpak-spawn");
command
.arg("--host")
.arg("flatpak")
.arg("list")
.arg("--app")
.arg("--columns=name,application")
.output()
}
}
impl FromSettingsString for FlatpakPlatform {
fn from_settings_string<S: AsRef<str>>(s: S) -> Self {
FlatpakPlatform {