Compare commits
2 Commits
fd3863c0d4
...
9bdbb3672a
Author | SHA1 | Date | |
---|---|---|---|
9bdbb3672a | |||
15b544da52 |
@ -8,25 +8,40 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
target:
|
||||||
|
- x86_64-pc-windows-gnu
|
||||||
|
- x86_64-unknown-linux-gnu
|
||||||
|
include:
|
||||||
|
- target: x86_64-pc-windows-gnu
|
||||||
|
os: windows
|
||||||
|
extension: .exe
|
||||||
|
- target: x86_64-unknown-linux-gnu
|
||||||
|
os: linux
|
||||||
|
extension: ""
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install rust
|
- name: Install rust
|
||||||
uses: dtolnay/rust-toolchain@stable
|
uses: dtolnay/rust-toolchain@stable
|
||||||
with:
|
with:
|
||||||
targets: "x86_64-pc-windows-gnu"
|
targets: ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Install cross compilation tools
|
- name: Install cross compilation tools
|
||||||
|
if: matrix.target == 'x86_64-pc-windows-gnu'
|
||||||
run: sudo apt-get update && sudo apt-get install mingw-w64 -y
|
run: sudo apt-get update && sudo apt-get install mingw-w64 -y
|
||||||
|
|
||||||
- name: Setup Cache
|
- name: Setup Cache
|
||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
|
with:
|
||||||
|
key: ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Build release
|
- name: Build release
|
||||||
run: cargo build --verbose --locked --release --target x86_64-pc-windows-gnu
|
run: cargo build --verbose --locked --release --target ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Archive build
|
- name: Archive build
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: alt_enter_fix
|
name: alt_enter_fix-${{ matrix.os }}
|
||||||
path: target/x86_64-pc-windows-gnu/release/alt_enter_fix.exe
|
path: target/${{ matrix.target }}/release/alt_enter_fix${{ matrix.extension }}
|
119
src/main.rs
119
src/main.rs
@ -3,13 +3,22 @@ use std::{env, fs, io::{self, stdin, Read, Write}, path::{Path, PathBuf}};
|
|||||||
|
|
||||||
const UNLIMITED_FPS_CAP_NUM: i32 = i32::max_value();
|
const UNLIMITED_FPS_CAP_NUM: i32 = i32::max_value();
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
enum Platform {
|
||||||
|
Windows(PathBuf),
|
||||||
|
Linux(PathBuf),
|
||||||
|
}
|
||||||
|
|
||||||
fn main() -> io::Result<()> {
|
fn main() -> io::Result<()> {
|
||||||
let roblox_path = find_roblox_path().ok_or_else(|| {
|
let platform = find_platform_path().ok_or_else(|| {
|
||||||
println!("Roblox not found (Die)");
|
println!("Neither Roblox (Windows) nor Sober (Linux) installation found");
|
||||||
io::Error::new(io::ErrorKind::NotFound, "Roblox installation not found")
|
io::Error::new(io::ErrorKind::NotFound, "No supported installation found")
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
println!("Found path: {}", roblox_path.display());
|
match &platform {
|
||||||
|
Platform::Windows(path) => println!("Found Roblox installation: {}", path.display()),
|
||||||
|
Platform::Linux(path) => println!("Found Sober installation: {}", path.display()),
|
||||||
|
}
|
||||||
|
|
||||||
println!("What FPS would you like to cap the fps to? (0 for no cap at all)");
|
println!("What FPS would you like to cap the fps to? (0 for no cap at all)");
|
||||||
io::stdout().flush()?;
|
io::stdout().flush()?;
|
||||||
@ -42,7 +51,7 @@ fn main() -> io::Result<()> {
|
|||||||
"FFlagDebugDisableTelemetryV2Stat": "True"
|
"FFlagDebugDisableTelemetryV2Stat": "True"
|
||||||
});
|
});
|
||||||
|
|
||||||
update_client_settings(&roblox_path, required_settings)?;
|
update_settings(platform, required_settings)?;
|
||||||
|
|
||||||
println!("Press enter to exit");
|
println!("Press enter to exit");
|
||||||
let _ = io::stdin().read(&mut [0u8])?;
|
let _ = io::stdin().read(&mut [0u8])?;
|
||||||
@ -50,6 +59,20 @@ fn main() -> io::Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn find_platform_path() -> Option<Platform> {
|
||||||
|
// Try Windows (Roblox) first
|
||||||
|
if let Some(roblox_path) = find_roblox_path() {
|
||||||
|
return Some(Platform::Windows(roblox_path));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try Linux (Sober)
|
||||||
|
if let Some(sober_path) = find_sober_path() {
|
||||||
|
return Some(Platform::Linux(sober_path));
|
||||||
|
}
|
||||||
|
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
fn find_roblox_path() -> Option<PathBuf> {
|
fn find_roblox_path() -> Option<PathBuf> {
|
||||||
if let Some(local_app_data) = env::var("LOCALAPPDATA").ok() {
|
if let Some(local_app_data) = env::var("LOCALAPPDATA").ok() {
|
||||||
let path = PathBuf::from(local_app_data).join("Roblox");
|
let path = PathBuf::from(local_app_data).join("Roblox");
|
||||||
@ -69,6 +92,24 @@ fn find_roblox_path() -> Option<PathBuf> {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn find_sober_path() -> Option<PathBuf> {
|
||||||
|
if let Some(home) = env::var("HOME").ok() {
|
||||||
|
let config_path = PathBuf::from(home)
|
||||||
|
.join(".var")
|
||||||
|
.join("app")
|
||||||
|
.join("org.vinegarhq.Sober")
|
||||||
|
.join("config")
|
||||||
|
.join("sober")
|
||||||
|
.join("config.json");
|
||||||
|
|
||||||
|
if config_path.exists() {
|
||||||
|
return Some(config_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
fn read_fps_input() -> io::Result<i32> {
|
fn read_fps_input() -> io::Result<i32> {
|
||||||
let mut input = String::new();
|
let mut input = String::new();
|
||||||
stdin().read_line(&mut input)?;
|
stdin().read_line(&mut input)?;
|
||||||
@ -80,7 +121,14 @@ fn read_fps_input() -> io::Result<i32> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_client_settings(roblox_path: &Path, required_settings: Value) -> io::Result<()> {
|
fn update_settings(platform: Platform, required_settings: Value) -> io::Result<()> {
|
||||||
|
match platform {
|
||||||
|
Platform::Windows(roblox_path) => update_roblox_settings(&roblox_path, required_settings),
|
||||||
|
Platform::Linux(sober_config_path) => update_sober_settings(&sober_config_path, required_settings),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update_roblox_settings(roblox_path: &Path, required_settings: Value) -> io::Result<()> {
|
||||||
let versions_path = roblox_path.join("Versions");
|
let versions_path = roblox_path.join("Versions");
|
||||||
|
|
||||||
for entry in fs::read_dir(versions_path)? {
|
for entry in fs::read_dir(versions_path)? {
|
||||||
@ -102,7 +150,7 @@ fn update_client_settings(roblox_path: &Path, required_settings: Value) -> io::R
|
|||||||
}
|
}
|
||||||
|
|
||||||
let settings_file = client_settings_dir.join("ClientAppSettings.json");
|
let settings_file = client_settings_dir.join("ClientAppSettings.json");
|
||||||
update_settings_file(&settings_file, &required_settings)?;
|
update_roblox_settings_file(&settings_file, &required_settings)?;
|
||||||
println!("Updated ClientAppSettings.json in {}", path.display());
|
println!("Updated ClientAppSettings.json in {}", path.display());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,7 +159,62 @@ fn update_client_settings(roblox_path: &Path, required_settings: Value) -> io::R
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_settings_file(file_path: &Path, required_settings: &Value) -> io::Result<()> {
|
fn update_sober_settings(config_path: &Path, required_settings: Value) -> io::Result<()> {
|
||||||
|
let mut config = if config_path.exists() {
|
||||||
|
match fs::read_to_string(config_path) {
|
||||||
|
Ok(content) if !content.trim().is_empty() => {
|
||||||
|
match serde_json::from_str::<Value>(&content) {
|
||||||
|
Ok(existing) => existing,
|
||||||
|
Err(e) => {
|
||||||
|
println!("Warning: Could not parse existing Sober config ({}), creating new structure", e);
|
||||||
|
json!({})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_ => json!({})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
json!({})
|
||||||
|
};
|
||||||
|
|
||||||
|
// Ensure config is an object
|
||||||
|
if !config.is_object() {
|
||||||
|
config = json!({});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get or create the fflags field
|
||||||
|
let mut fflags = config.get("fflags").cloned().unwrap_or_else(|| json!({}));
|
||||||
|
|
||||||
|
// Ensure fflags is an object
|
||||||
|
if !fflags.is_object() {
|
||||||
|
fflags = json!({});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add our required settings to fflags
|
||||||
|
if let Some(required_obj) = required_settings.as_object() {
|
||||||
|
if let Some(fflags_obj) = fflags.as_object_mut() {
|
||||||
|
for (key, value) in required_obj {
|
||||||
|
println!("Adding FFlag {}: {}", key, value);
|
||||||
|
fflags_obj.insert(key.clone(), value.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the config with the modified fflags
|
||||||
|
if let Some(config_obj) = config.as_object_mut() {
|
||||||
|
config_obj.insert("fflags".to_string(), fflags);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write back to file
|
||||||
|
let formatted = serde_json::to_string_pretty(&config)?;
|
||||||
|
fs::write(config_path, formatted)?;
|
||||||
|
|
||||||
|
println!("Updated Sober config at {}", config_path.display());
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update_roblox_settings_file(file_path: &Path, required_settings: &Value) -> io::Result<()> {
|
||||||
// Funky code to edit or create the ClientAppSettings.json file (shoutout claude for the help with the object stuff (json sucks))
|
// Funky code to edit or create the ClientAppSettings.json file (shoutout claude for the help with the object stuff (json sucks))
|
||||||
let mut settings = if file_path.exists() {
|
let mut settings = if file_path.exists() {
|
||||||
match fs::read_to_string(file_path) {
|
match fs::read_to_string(file_path) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user