-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Flatpak < 1.15.6 for permissions (#992)
- Loading branch information
Showing
7 changed files
with
90 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import GLib from "gi://GLib"; | ||
|
||
let flatpak_info; | ||
export function getFlatpakInfo() { | ||
if (flatpak_info) return flatpak_info; | ||
flatpak_info = new GLib.KeyFile(); | ||
try { | ||
flatpak_info.load_from_file("/.flatpak-info", GLib.KeyFileFlags.NONE); | ||
} catch (err) { | ||
if (!err.matches(GLib.FileError, GLib.FileError.NOENT)) { | ||
console.error(err); | ||
} | ||
return null; | ||
} | ||
return flatpak_info; | ||
} | ||
|
||
export function getFlatpakId() { | ||
return getFlatpakInfo().get_string("Application", "name"); | ||
} | ||
|
||
// https://repology.org/project/flatpak/versions | ||
export function isDeviceInputOverrideAvailable(flatpak_version) { | ||
flatpak_version ??= getFlatpakInfo().get_string( | ||
"Instance", | ||
"flatpak-version", | ||
); | ||
|
||
// https://github.com/flatpak/flatpak/releases/tag/1.15.6 | ||
return ( | ||
flatpak_version.localeCompare("1.15.6", undefined, { | ||
numeric: true, | ||
sensitivity: "base", | ||
}) > -1 | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import "../src/init.js"; | ||
|
||
import tst, { assert } from "../troll/tst/tst.js"; | ||
|
||
import { isDeviceInputOverrideAvailable } from "../src/flatpak.js"; | ||
|
||
const test = tst("isDeviceInputOverrideAvailable"); | ||
|
||
test("returns a boolean", () => { | ||
assert.equal(typeof isDeviceInputOverrideAvailable(), "boolean"); | ||
}); | ||
|
||
test("returns true if Flatpak version is equal to 1.15.6", () => { | ||
assert.equal(isDeviceInputOverrideAvailable("1.15.6"), true); | ||
}); | ||
|
||
test("returns true if Flatpak version is higher than 1.15.6", () => { | ||
assert.equal(isDeviceInputOverrideAvailable("1.15.7"), true); | ||
assert.equal(isDeviceInputOverrideAvailable("1.16.5"), true); | ||
assert.equal(isDeviceInputOverrideAvailable("2.15.4"), true); | ||
}); | ||
|
||
test("returns false if Flatpak version is lower than 1.15.6", () => { | ||
assert.equal(isDeviceInputOverrideAvailable("1.15.5"), false); | ||
assert.equal(isDeviceInputOverrideAvailable("1.14.7"), false); | ||
assert.equal(isDeviceInputOverrideAvailable("0.16.7"), false); | ||
}); | ||
|
||
export default test; |