mirror of
https://github.com/neosubhamoy/pytubepp-helper.git
synced 2026-02-04 11:22:22 +05:30
(feat): added support for macOS
This commit is contained in:
11
src/App.tsx
11
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 } from "./lib/utils";
|
||||
import { compareVersions, extractVersion, isInstalled, sendStreamInfo, detectWindows, detectDistro, extractDistroId, detectDistroBase, detectMacOs, registerMacFiles } from "./lib/utils";
|
||||
import { CircleCheck, TriangleAlert, CircleAlert } from 'lucide-react';
|
||||
|
||||
function App() {
|
||||
@@ -234,7 +234,14 @@ function App() {
|
||||
<div className="container">
|
||||
<div className={clsx("topbar flex justify-between items-center mt-5", !isWindows && "mx-3")}>
|
||||
<h1 className="text-xl font-bold">PytubePP Helper</h1>
|
||||
<Button size="sm" onClick={checkAllPrograms}>Refresh</Button>
|
||||
<div>
|
||||
{ isMacOs && macOsVersion && compareVersions(macOsVersion, '10.13') > 0 ?
|
||||
<Button size="sm" onClick={registerMacFiles}>Register</Button>
|
||||
:
|
||||
null
|
||||
}
|
||||
<Button className="ml-3" size="sm" onClick={checkAllPrograms}>Refresh</Button>
|
||||
</div>
|
||||
</div>
|
||||
{ distroId && distroBase && distroBase === 'debian' ? /* Section for Debian */
|
||||
<div className="programstats mt-5 mx-3">
|
||||
|
||||
@@ -2,6 +2,8 @@ import { type ClassValue, clsx } from "clsx"
|
||||
import { twMerge } from "tailwind-merge"
|
||||
import { Command } from '@tauri-apps/api/shell';
|
||||
import { invoke } from "@tauri-apps/api";
|
||||
import { fs } from '@tauri-apps/api';
|
||||
import { join, resourceDir, homeDir } from '@tauri-apps/api/path';
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
@@ -141,4 +143,37 @@ export function compareVersions (v1: string, v2: string) {
|
||||
if (part1 < part2) return -1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
};
|
||||
|
||||
export async function registerMacFiles() {
|
||||
try {
|
||||
const filesToCopy = [
|
||||
{ source: 'pytubepp-helper-autostart.plist', destination: 'Library/LaunchAgents/com.neosubhamoy.pytubepp.helper.plist', dir: 'Library/LaunchAgents/' },
|
||||
{ source: 'pytubepp-helper-msghost.json', destination: 'Library/Application Support/Google/Chrome/NativeMessagingHosts/com.neosubhamoy.pytubepp.helper.json', dir: 'Library/Application Support/Google/Chrome/NativeMessagingHosts/' },
|
||||
{ source: 'pytubepp-helper-msghost.json', destination: 'Library/Application Support/Chromium/NativeMessagingHosts/com.neosubhamoy.pytubepp.helper.json', dir: 'Library/Application Support/Chromium/NativeMessagingHosts/' },
|
||||
{ source: 'pytubepp-helper-msghost-moz.json', destination: 'Library/Application Support/Mozilla/NativeMessagingHosts/com.neosubhamoy.pytubepp.helper.json', dir: 'Library/Application Support/Mozilla/NativeMessagingHosts/' },
|
||||
];
|
||||
|
||||
const resourceDirPath = await resourceDir();
|
||||
const homeDirPath = await homeDir();
|
||||
|
||||
for (const file of filesToCopy) {
|
||||
const sourcePath = await join(resourceDirPath, file.source);
|
||||
const destinationDir = await join(homeDirPath, file.dir);
|
||||
const destinationPath = await join(homeDirPath, file.destination);
|
||||
|
||||
const dirExists = await fs.exists(destinationDir);
|
||||
if (dirExists) {
|
||||
await fs.copyFile(sourcePath, destinationPath);
|
||||
console.log(`File ${file.source} copied successfully to ${destinationPath}`);
|
||||
} else {
|
||||
await fs.createDir(destinationDir, { recursive: true })
|
||||
console.log(`Created dir ${destinationDir}`);
|
||||
await fs.copyFile(sourcePath, destinationPath);
|
||||
console.log(`File ${file.source} copied successfully to ${destinationPath}`);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error copying files:', error);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user