Skip to content

Commit

Permalink
improve chromium browsers detection
Browse files Browse the repository at this point in the history
  • Loading branch information
alvindimas05 committed Sep 26, 2024
1 parent aa33203 commit b2338e1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/commandline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class CommandLine {
console.log(`(C) ${global.commandlineChromiumMode ? "Exit" : "Enter"} Chromium apps mode (${chalk.rgb(255,99,71)("EXPERIMENTAL")})`)

const ryzenadj = new Ryzenadj();
console.log(`(O) ${ryzenadj.enabled() ? "Remove" : "Apply"} battery optimization (${chalk.rgb(255,99,71)("REQUIRES PASSWORD")})`)
console.log(`(O) ${ryzenadj.enabled() ? "Remove" : "Apply"} battery optimization (${chalk.rgb(255,99,71)("May cause lag and REQUIRES PASSWORD")})`)

console.log("(Q) Quit")

Expand Down
20 changes: 15 additions & 5 deletions src/patches/chromium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface ChromiumConfig {
}
}

const chromiumBrowsers = ["Chromium", "Google Chrome", "Arc", "Microsoft Edge", "Brave"];
const chromiumBrowsers = ["Chromium", "Google Chrome", "Arc", "Microsoft Edge", "Brave Browser"];
export const bashPath = path.join("/", "Library", "amdhelper", amdhelperChromiumBashName);
export const plistPath = path.join("/", "Library", "LaunchAgents", amdhelperChromiumPlistName);

Expand Down Expand Up @@ -57,12 +57,22 @@ export default class Chromium extends AppPatch {
this.config = JSON.parse(fs.readFileSync(this.configPath).toString("utf8"));
}
supported() {
return (chromiumBrowsers.includes(this.appName) && this.configPath != null) ||
this.supportElectron();
return chromiumBrowsers.includes(this.appName) || this.isChromiumBrowser() || this.supportElectron();
}
supportElectron(){
return fs.existsSync(path.join("/Applications", `${this.appName}.app`, "Contents", "Frameworks", "Electron Framework.framework"))
|| fs.existsSync(path.join("/Applications", `${this.appName}.app`, "Contents", "Frameworks", "Chromium Embedded Framework.framework"));
return fs.existsSync(path.join(this.appPath, "Contents", "Frameworks", "Electron Framework.framework"))
|| fs.existsSync(path.join(this.appPath, "Contents", "Frameworks", "Chromium Embedded Framework.framework"));
}
isChromiumBrowser(): boolean {
if (!fs.existsSync(path.join(this.appPath, "Contents", "Frameworks"))) return false;

const frameworks = fs.readdirSync(path.join(this.appPath, "Contents", "Frameworks"))
for(const framework of frameworks){
if (!framework.startsWith(this.appName) || !framework.endsWith(".framework")) continue;
return fs.existsSync(path.join(this.appPath, "Contents", "Frameworks", framework, "Helpers",
`${this.appName} Helper (GPU).app`));
}
return false
}
selected(): boolean {
return global.chromiumApps.findIndex(fapp => fapp.name === this.appName) !== -1
Expand Down
12 changes: 8 additions & 4 deletions src/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ interface UpdateResponse {
}

export async function check_update(){
const res = await fetch(process.env.RELEASE_URL);
const data : UpdateResponse[] = await res.json();
if(data[0].tag_name === process.env.VERSION) return;
console.log(`New update version ${data[0].tag_name}! Run "amdhelper -u" to update.`);
try {
const res = await fetch(process.env.RELEASE_URL);
const data : UpdateResponse[] = await res.json();
if(data[0].tag_name === process.env.VERSION) return;
console.log(`New update version ${data[0].tag_name}! Run "amdhelper -u" to update.`);
} catch {
console.log("Can't check AMDHelper update...")
}
}

export async function update(){
Expand Down

0 comments on commit b2338e1

Please sign in to comment.