Skip to content

Commit

Permalink
re-feat: rename ethylene-amd to amdhelper
Browse files Browse the repository at this point in the history
  • Loading branch information
alvindimas05 committed Oct 7, 2024
1 parent e5e6cd2 commit 41be2dc
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 270 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["ethylene-amd", "ethylene-amd-chromium", "ethylene-amd-gui", "ethylene-amd-tui"]
members = ["amdhelper", "amdhelper-chromium", "amdhelper-tui"]
resolver = "2"

[profile.release]
Expand Down
50 changes: 0 additions & 50 deletions LICENSE

This file was deleted.

8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# EthyleneAMD ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/ChefKissInc/EthyleneAMD/main.yml?branch=master&logo=github&style=for-the-badge)
# AMDHelper

Beware: dangerous to flowers!

Tool with workarounds for AMD systems running macOS.

The EthyleneAMD project is licensed under the `Thou Shalt Not Profit License version 1.5`. See [`LICENSE`](https://github.com/ChefKissInc/EthyleneAMD/blob/master/LICENSE).
Tool with workarounds for AMD systems running macOS.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "ethylene-amd-chromium"
name = "amdhelper-chromium"
version = "0.1.0"
edition = "2021"

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion ethylene-amd/Cargo.toml → amdhelper/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "ethylene-amd"
name = "amdhelper"
version = "0.1.0"
edition = "2021"

Expand Down
26 changes: 13 additions & 13 deletions ethylene-amd/src/lib.rs → amdhelper/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#![warn(clippy::nursery, unused_extern_crates)]
use std::{env, fs, path::Path};

use patch::{chromium::ChromiumPatch, EthylenePatch};
use patch::{chromium::ChromiumPatch, AMDHelperPatch};

pub mod patch;

#[derive(Clone)]
pub struct EthyleneApp {
pub struct AMDHelperApp {
pub name: String,
pub path: std::path::PathBuf,
}

pub fn get_apps(patches: &Vec<impl EthylenePatch>) -> std::io::Result<Vec<EthyleneApp>> {
pub fn get_apps(patches: &Vec<impl AMDHelperPatch>) -> std::io::Result<Vec<AMDHelperApp>> {
Ok(std::fs::read_dir("/Applications")?
.flatten()
.filter_map(|dir| {
Expand All @@ -20,7 +20,7 @@ pub fn get_apps(patches: &Vec<impl EthylenePatch>) -> std::io::Result<Vec<Ethyle
return None;
}

let app_item = EthyleneApp {
let app_item = AMDHelperApp {
name: path.file_stem()?.to_string_lossy().into_owned(),
path,
};
Expand All @@ -34,18 +34,18 @@ pub fn get_apps(patches: &Vec<impl EthylenePatch>) -> std::io::Result<Vec<Ethyle
.collect())
}

pub fn get_patches() -> Vec<impl EthylenePatch>{
pub fn get_patches() -> Vec<impl AMDHelperPatch>{
vec![ChromiumPatch]
}

pub fn apply_chromium_patch(patch: ChromiumPatch, apps: Vec<&EthyleneApp>){
pub fn apply_chromium_patch(patch: ChromiumPatch, apps: Vec<&AMDHelperApp>){
let supported_apps = apps.iter()
.filter_map(|app| if patch.supported_for(&app) { Some(app.name.as_str()) } else { None })
.collect::<Vec<&str>>().join(",");

let ethylene_chromium_path = env::current_dir().unwrap().parent().unwrap().join("target")
.join("debug").join("ethylene-amd-chromium");
if fs::copy(ethylene_chromium_path.to_str().unwrap(), CHROMIUM_GLOBAL_PATH).is_err(){
let AMDHelper_chromium_path = env::current_dir().unwrap().parent().unwrap().join("target")
.join("debug").join("amdhelper-chromium");
if fs::copy(AMDHelper_chromium_path.to_str().unwrap(), CHROMIUM_GLOBAL_PATH).is_err(){
println!("Failed to save chromium patch to global path...");
return
}
Expand All @@ -56,20 +56,20 @@ pub fn apply_chromium_patch(patch: ChromiumPatch, apps: Vec<&EthyleneApp>){
}
}

const CHROMIUM_GLOBAL_PATH: &str = "/usr/local/bin/ethylene-amd-chromium";
const CHROMIUM_PLIST_PATH: &str = "/Library/LaunchAgents/com.ChefKiss.ethylene-amd-chromium.plist";
const CHROMIUM_GLOBAL_PATH: &str = "/usr/local/bin/amdhelper-chromium";
const CHROMIUM_PLIST_PATH: &str = "/Library/LaunchAgents/org.alvindimas05.amdhelper-chromium.plist";
const CHROMIUM_PLIST_VALUE: &str = r#"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.ChefKiss.ethylene-amd-chromium</string>
<string>org.alvindimas05.amdhelper-chromium</string>
<key>LaunchOnlyOnce</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/Library/Scripts/ethylene-amd-chromium</string>
<string>/Library/Scripts/amdhelper-chromium</string>
<string>-a</string>
<string>$APPLIST</string>
</array>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::{patch::EthylenePatch, EthyleneApp};
use crate::{patch::AMDHelperPatch, AMDHelperApp};

pub struct ChromiumPatch;

impl ChromiumPatch {
fn is_chromium(app_item: &EthyleneApp) -> bool {
fn is_chromium(app_item: &AMDHelperApp) -> bool {
let fw_path = app_item.path.join("Contents").join("Frameworks");

let Ok(fw_dir) = fw_path.read_dir() else {
Expand All @@ -28,20 +28,20 @@ impl ChromiumPatch {
.unwrap_or_default()
}

fn is_electron(app_item: &EthyleneApp) -> bool {
fn is_electron(app_item: &AMDHelperApp) -> bool {
let fw_path = app_item.path.join("Contents").join("Frameworks");
std::fs::exists(fw_path.join("Electron Framework.framework")).unwrap_or_default()
|| std::fs::exists(fw_path.join("Chromium Embedded Framework.framework"))
.unwrap_or_default()
}
}

impl EthylenePatch for ChromiumPatch {
fn supported_for(&self, app_item: &EthyleneApp) -> bool {
impl AMDHelperPatch for ChromiumPatch {
fn supported_for(&self, app_item: &AMDHelperApp) -> bool {
Self::is_electron(app_item) || Self::is_chromium(app_item)
}

fn apply_to(&self, app_item: &EthyleneApp) {
fn apply_to(&self, app_item: &AMDHelperApp) {
todo!()
}
}
8 changes: 8 additions & 0 deletions amdhelper/src/patch/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use crate::AMDHelperApp;

pub mod chromium;

pub trait AMDHelperPatch: Sized {
fn supported_for(&self, app_item: &AMDHelperApp) -> bool;
fn apply_to(&self, app_item: &AMDHelperApp);
}
6 changes: 0 additions & 6 deletions ethylene-amd-gui/Cargo.toml

This file was deleted.

1 change: 0 additions & 1 deletion ethylene-amd-gui/src/main.rs

This file was deleted.

9 changes: 0 additions & 9 deletions ethylene-amd-tui/Cargo.toml

This file was deleted.

Loading

0 comments on commit 41be2dc

Please sign in to comment.