diff --git a/src-tauri/tauri.linux.conf.json b/src-tauri/tauri.linux.conf.json index 58c46c8..539d162 100644 --- a/src-tauri/tauri.linux.conf.json +++ b/src-tauri/tauri.linux.conf.json @@ -32,6 +32,11 @@ "cmd": "grep", "args": ["^ID=", "/etc/os-release"] }, + { + "name": "detect-pkgmngr", + "cmd": "sh", + "args": ["-c", "command -v apt || command -v dnf || command -v pacman"] + }, { "name": "is-apt-installed", "cmd": "apt", @@ -128,7 +133,7 @@ "icons/icon.ico" ], "deb": { - "depends": ["python3-pip", "ffmpeg"], + "depends": ["python3-pip", "ffmpeg", "gnome-terminal"], "files": { "/etc/opt/chrome/native-messaging-hosts/com.neosubhamoy.pytubepp.helper.json": "./msghost-manifest/linux/chrome/com.neosubhamoy.pytubepp.helper.json", "/etc/chromium/native-messaging-hosts/com.neosubhamoy.pytubepp.helper.json": "./msghost-manifest/linux/chrome/com.neosubhamoy.pytubepp.helper.json", @@ -141,7 +146,7 @@ "epoch": 0, "release": "1", "license": "MIT", - "depends": ["python3-pip", "ffmpeg-free"], + "depends": ["python3-pip", "ffmpeg-free", "gnome-terminal"], "files": { "/etc/opt/chrome/native-messaging-hosts/com.neosubhamoy.pytubepp.helper.json": "./msghost-manifest/linux/chrome/com.neosubhamoy.pytubepp.helper.json", "/etc/chromium/native-messaging-hosts/com.neosubhamoy.pytubepp.helper.json": "./msghost-manifest/linux/chrome/com.neosubhamoy.pytubepp.helper.json", diff --git a/src-tauri/tauri.macos.conf.json b/src-tauri/tauri.macos.conf.json index 2a1bac9..8bb4af5 100644 --- a/src-tauri/tauri.macos.conf.json +++ b/src-tauri/tauri.macos.conf.json @@ -32,6 +32,11 @@ "cmd": "grep", "args": ["^ID=", "/etc/os-release"] }, + { + "name": "detect-pkgmngr", + "cmd": "sh", + "args": ["-c", "command -v apt || command -v dnf || command -v pacman"] + }, { "name": "is-apt-installed", "cmd": "apt", diff --git a/src-tauri/tauri.windows.conf.json b/src-tauri/tauri.windows.conf.json index f0b2369..a5cc3f5 100644 --- a/src-tauri/tauri.windows.conf.json +++ b/src-tauri/tauri.windows.conf.json @@ -32,6 +32,11 @@ "cmd": "grep", "args": ["^ID=", "/etc/os-release"] }, + { + "name": "detect-pkgmngr", + "cmd": "sh", + "args": ["-c", "command -v apt || command -v dnf || command -v pacman"] + }, { "name": "is-apt-installed", "cmd": "apt", diff --git a/src/App.tsx b/src/App.tsx index a4065f7..55e374a 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -9,7 +9,7 @@ import { ThemeProvider } from "@/components/theme-provider"; import { Button } from "@/components/ui/button"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert" import { InstalledPrograms, WebSocketMessage, } from "./types"; -import { compareVersions, extractVersion, isInstalled, sendStreamInfo, detectWindows, detectDistro, extractDistroId, detectDistroBase, detectMacOs, registerMacFiles } from "./lib/utils"; +import { compareVersions, extractVersion, isInstalled, sendStreamInfo, detectWindows, detectDistro, extractDistroId, detectMacOs, registerMacFiles, detectPackageManager, extractPkgMngrName } from "./lib/utils"; import { CircleCheck, TriangleAlert, CircleAlert } from 'lucide-react'; function App() { @@ -27,7 +27,7 @@ function App() { const [isMacOs, setIsMacOs] = useState(false) const [macOsVersion, setMacOsVersion] = useState(null) const [distroId, setDistroId] = useState(null) - const [distroBase, setDistroBase] = useState(null) + const [distroPkgMngr, setDistroPkgMngr] = useState(null) const [installedPrograms, setInstalledPrograms] = useState({ winget: { installed: false, @@ -218,7 +218,10 @@ function App() { const distroResult = await detectDistro(); if (distroResult) { setDistroId(extractDistroId(distroResult)); - setDistroBase(detectDistroBase(extractDistroId(distroResult))); + const distroPkgMngrResult = await detectPackageManager(); + if (distroPkgMngrResult) { + setDistroPkgMngr(extractPkgMngrName(distroPkgMngrResult)); + } } break; @@ -243,7 +246,7 @@ function App() { - { distroId && distroBase && distroBase === 'debian' ? /* Section for Debian */ + { distroId && distroPkgMngr && distroPkgMngr === 'apt' ? /* Section for Debian */

Python: {installedPrograms.python3.installed ? 'installed' : 'not installed'} {installedPrograms.python3.version ? `(${installedPrograms.python3.version})` : ''}

@@ -285,7 +288,7 @@ function App() { : null}
- : distroId && distroBase && distroBase === 'rhel' ? /* Section for RHEL */ + : distroId && distroPkgMngr && distroPkgMngr === 'dnf' ? /* Section for RHEL */

Python: {installedPrograms.python3.installed ? 'installed' : 'not installed'} {installedPrograms.python3.version ? `(${installedPrograms.python3.version})` : ''}

diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 4c4f5c5..9821f80 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -65,20 +65,27 @@ export async function detectDistro(): Promise { } } -export function detectDistroBase(distro: string | null): string | null{ - if(distro) { - if(['debian', 'ubuntu', 'pop', 'kali'].includes(distro)) { - return 'debian'; - } else if (['rhel', 'fedora', 'centos', 'rocky'].includes(distro)) { - return 'rhel'; +export async function detectPackageManager(): Promise { + try{ + const output = await new Command('detect-pkgmngr', ['-c', 'command -v apt || command -v dnf || command -v pacman']).execute(); + if (output.code === 0) { + return output.stdout; } else { - return 'other'; + return output.stdout; } - } else { + } catch (error) { + console.error(error); return null; } } +export function extractPkgMngrName(path: string): string | null { + const pattern = /^\s*(.*\/)?([^\/\s]+)\s*$/; + const match = path.trim().match(pattern); + if (!match) return null; + return match[2]; +} + export function extractDistroId(input: string): string | null { const regex = /ID=([a-zA-Z]+)/; const match = input.match(regex);