Skip to content

Commit

Permalink
Manage pinned flatpak runtimes
Browse files Browse the repository at this point in the history
This patch series attempts to add support to
manage the pinned runtimes of flatpak.

Signed-off-by: innocentzero <[email protected]>
  • Loading branch information
InnocentZero committed Nov 2, 2024
1 parent e1e1ef0 commit 4457cdf
Showing 1 changed file with 34 additions and 19 deletions.
53 changes: 34 additions & 19 deletions src/backends/flatpak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl Backend for Flatpak {
return Ok(BTreeMap::new());
}

let sys_explicit_btree = run_command_for_stdout(
let sys_explicit_out = run_command_for_stdout(
[
"flatpak",
"list",
Expand All @@ -42,12 +42,12 @@ impl Backend for Flatpak {
"--columns=application",
],
Perms::Same,
)?
.lines()
.map(String::from)
.collect::<BTreeSet<_>>();
)?;
let sys_explicit = sys_explicit_out
.lines()
.map(|x| (x.trim().to_owned(), FlatpakQueryInfo { systemwide: true }));

let user_explicit_btree = run_command_for_stdout(
let user_explicit_out = run_command_for_stdout(
[
"flatpak",
"list",
Expand All @@ -56,19 +56,34 @@ impl Backend for Flatpak {
"--columns=application",
],
Perms::Same,
)?
.lines()
.map(String::from)
.collect::<BTreeSet<_>>();

let sys_explicit = sys_explicit_btree
.iter()
.map(|x| (x.clone(), FlatpakQueryInfo { systemwide: true }));
let user_explicit = user_explicit_btree
.iter()
.map(|x| (x.clone(), FlatpakQueryInfo { systemwide: false }));

let all = sys_explicit.chain(user_explicit).collect();
)?;
let user_explicit = user_explicit_out
.lines()
.map(|x| (x.trim().to_owned(), FlatpakQueryInfo { systemwide: false }));

let sys_explicit_runtimes_out =
run_command_for_stdout(["flatpak", "pin", "--system"], Perms::Same)?;
let sys_explicit_runtimes = sys_explicit_runtimes_out.lines().skip(1).map(|x| {
(
x.trim().split('/').nth(1).unwrap().to_owned(),
FlatpakQueryInfo { systemwide: true },
)
});

let user_explicit_runtimes_out =
run_command_for_stdout(["flatpak", "pin", "--user"], Perms::Same)?;
let user_explicit_runtimes = user_explicit_runtimes_out.lines().skip(1).map(|x| {
(
x.trim().split('/').nth(1).unwrap().to_owned(),
FlatpakQueryInfo { systemwide: false },
)
});

let all = sys_explicit
.chain(user_explicit)
.chain(sys_explicit_runtimes)
.chain(user_explicit_runtimes)
.collect();

Ok(all)
}
Expand Down

0 comments on commit 4457cdf

Please sign in to comment.