@@ -569,13 +569,16 @@ class Linux {
569569 if ((softwareManager == null ||
570570 softwareManager == SOFTWARE_MANAGERS .FLATPAK ) &&
571571 isFlatpakInstalled) {
572- commandQueue.add (
573- LinuxCommand (
574- userId: currentenvironment.currentUserId,
575- command:
576- "${getExecutablePathOfSoftwareManager (SOFTWARE_MANAGERS .FLATPAK )} remove $appCode -y --noninteractive" ,
577- ),
578- );
572+ commandQueue.add (LinuxCommand (
573+ userId: currentenvironment.currentUserId,
574+ command:
575+ "${getExecutablePathOfSoftwareManager (SOFTWARE_MANAGERS .FLATPAK )} remove $appCode -y --noninteractive" ,
576+ ));
577+ commandQueue.add (LinuxCommand (
578+ userId: 0 ,
579+ command:
580+ "${getExecutablePathOfSoftwareManager (SOFTWARE_MANAGERS .FLATPAK )} uninstall $appCode -y --noninteractive --system" ,
581+ ));
579582 }
580583 }
581584
@@ -1484,6 +1487,53 @@ class Linux {
14841487 return results;
14851488 }
14861489
1490+ static Future <List <ActionEntry >> getInstallableFlatpakPackagesForKeyword (
1491+ String keyword) async {
1492+ if (keyword.length <= 3 ) {
1493+ return [];
1494+ }
1495+ String output = await runCommandWithCustomArguments (
1496+ getExecutablePathOfSoftwareManager (SOFTWARE_MANAGERS .FLATPAK ),
1497+ ["search" , keyword, "--columns=application,name,description" ]);
1498+ output = output.trim ();
1499+ List <String > lines = output.split ("\n " );
1500+
1501+ if (output.contains ("No matches found" )) {
1502+ return [];
1503+ }
1504+
1505+ print (output);
1506+ print (lines.length);
1507+
1508+ if (lines.length > 100 ) {
1509+ return [];
1510+ }
1511+
1512+ List <ActionEntry > results = [];
1513+ for (String line in lines) {
1514+ List <String > lineParts = line.split ("\t " );
1515+ if (lineParts.length < 3 ) {
1516+ continue ;
1517+ }
1518+ String appID = lineParts[0 ].trim ();
1519+ String appName = lineParts[1 ].trim ();
1520+ String appDescription = lineParts[2 ].trim ();
1521+ results.add (ActionEntry (
1522+ iconWidget: Icon (
1523+ Icons .archive,
1524+ size: 48 ,
1525+ color: MintY .currentColor,
1526+ ),
1527+ name: "Install $appName (Flatpak)" ,
1528+ description: appDescription,
1529+ action: "flatpak-install:$appID " ,
1530+ priority: - 20 ,
1531+ ));
1532+ }
1533+
1534+ return results;
1535+ }
1536+
14871537 /// Only returns results if keyword is longer than 3 and there are under 100 results.
14881538 static Future <List <ActionEntry >> getInstallableZypperPackagesForKeyword (
14891539 String keyword) async {
@@ -2179,44 +2229,6 @@ class Linux {
21792229 Linux .runCommand ("/sbin/shutdown $minutes " );
21802230 }
21812231
2182- static Future <List <ActionEntry >> getAvailableFlatpaks (
2183- BuildContext context) async {
2184- String homeDir = Linux .getHomeDirectory ();
2185-
2186- List <ActionEntry > returnValue = [];
2187- try {
2188- String installedFlatpaks = await Linux .runCommandWithCustomArguments (
2189- "/usr/bin/flatpak" , ["list" , "--app" , "--columns=application" ]);
2190-
2191- File flathubIndexFile =
2192- File ("$homeDir .config/linux-assistant/flathub_index.json" );
2193- List <dynamic > responseMap =
2194- json.decode (flathubIndexFile.readAsStringSync ());
2195- for (Map <String , dynamic > app in responseMap) {
2196- if (! installedFlatpaks
2197- .contains (app["flatpakAppId" ].toString ().trim ())) {
2198- ActionEntry entry = ActionEntry (
2199- name: AppLocalizations .of (context)!
2200- .installX ("${app ["name" ]} (Flatpak)" ),
2201- description: app["summary" ],
2202- action: "flatpak-install:${app ["flatpakAppId" ]}" ,
2203- priority: - 19.0 ,
2204- iconWidget: Icon (
2205- Icons .archive_rounded,
2206- size: 48 ,
2207- color: MintY .currentColor,
2208- ),
2209- excludeFromSearchProposal: true ,
2210- );
2211- returnValue.add (entry);
2212- }
2213- }
2214- } catch (e) {
2215- print (e.toString ());
2216- }
2217- return returnValue;
2218- }
2219-
22202232 static Future <String > getUsername () async {
22212233 final int id = currentenvironment.currentUserId;
22222234 return (await runCommand ("id -nu $id " )).trim ();
0 commit comments