Compare commits

...

23 Commits

Author SHA1 Message Date
Luke Jones 49234af08b Merge branch 'fluke/profiles' into 'main'
Fluke/profiles

See merge request asus-linux/asusctl!71
2021-08-01 22:53:38 +00:00
Luke D. Jones 8f5717def8 Version bump, various fixes 2021-08-02 10:50:17 +12:00
Luke D. Jones 9e55c0b2ca Fix incorrect name match of Star keyboard effect 2021-08-02 10:28:50 +12:00
Luke Jones dd6ee91364 Merge branch 'main' into 'main'
Enable multizone support on Strix 513IH

See merge request asus-linux/asusctl!69
2021-08-01 22:03:30 +00:00
Luke Jones efbb838ca1 Merge branch 'G513QY-ledmodes' into 'main'
add G513QY ledmodes

See merge request asus-linux/asusctl!70
2021-08-01 21:27:59 +00:00
Sonny Piers daf7d39d41 add G513QY ledmodes 2021-08-01 23:12:59 +02:00
pshem 28b1194924 Fix multizone support on Strix 513IH 2021-08-01 18:00:04 +01:00
Luke Jones 73d95ca187 Merge branch 'fluke/profiles' into 'main'
fix: Profile select by name is correctly choosing

Closes #96 and #100

See merge request asus-linux/asusctl!68
2021-07-31 12:19:28 +00:00
Luke D. Jones 00b7c6482f fix: remove the parsing for root supported functions 2021-08-01 00:15:38 +12:00
Luke D. Jones 29c26e8c89 fix: Profile select by name is correctly choosing
Closes #100 #96
2021-08-01 00:10:11 +12:00
Luke D. Jones fb124dd228 Fix clippy warnings 2021-07-31 23:09:23 +12:00
Luke D. Jones 0599be02dc fix: remove dbg!() output 2021-07-31 23:03:17 +12:00
Luke Jones 81a88263a9 Merge branch 'fluke/cli-fixes' into 'main'
Fluke/cli fixes

See merge request asus-linux/asusctl!67
2021-07-31 11:00:43 +00:00
Luke D. Jones cea1fd2540 Fix small issues with CLI 2021-07-31 22:57:17 +12:00
Luke Jones f2ced3bc7c Merge branch 'main' into 'main'
Add Zephyrus M GM501GS

Closes #109

See merge request asus-linux/asusctl!66
2021-07-30 23:48:58 +00:00
pshem dc2a05894b Add Zephyrus M GM501GS 2021-07-30 17:45:00 +01:00
Luke D. Jones 9ee962ad09 systemd: sleep 2 after unit init 2021-07-30 14:35:44 +12:00
Luke Jones eb7ef0af4f Merge branch 'main' into 'main'
add a protection to not allow running asusd in terminal

Closes #104

See merge request asus-linux/asusctl!64
2021-07-30 00:12:17 +00:00
Luke Jones dc51120c27 Merge branch 'main' into 'main'
Add G533QR and 513IH to ledmodes

See merge request asus-linux/asusctl!65
2021-07-30 00:11:05 +00:00
pshem fc4c2c4346 Add support for 513IH led modes 2021-07-24 19:34:09 +01:00
pshem 3f6be037c1 Add G533QR to ledmodes 2021-07-24 14:39:11 +01:00
Luke Jones 0a80c97f02 Update README.md 2021-07-13 04:36:39 +00:00
dragonn 88abafc728 add a protection to not allow running asusd in terminal 2021-07-09 18:40:38 +02:00
30 changed files with 135 additions and 127 deletions
+10
View File
@@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
# [3.7.2] - 2021-08-02
### Added
- Enable multizone support on Strix 513IH
- Add G513QY ledmodes
### Changed
- Fix missing CLI command help for some supported options
- Fix incorrectly selecting profile by name, where the active profile was being copied to the selected profile
- Add `asusd` version back to `asusctl -v` report
- Fix various clippy warnings
# [3.7.1] - 2021-06-11 # [3.7.1] - 2021-06-11
### Changed ### Changed
- Refine graphics mode switching: - Refine graphics mode switching:
Generated
+5 -4
View File
@@ -43,8 +43,9 @@ dependencies = [
[[package]] [[package]]
name = "asusctl" name = "asusctl"
version = "3.5.0" version = "3.5.1"
dependencies = [ dependencies = [
"daemon",
"gif", "gif",
"glam", "glam",
"gumdrop", "gumdrop",
@@ -206,7 +207,7 @@ dependencies = [
[[package]] [[package]]
name = "daemon" name = "daemon"
version = "3.7.1" version = "3.7.2"
dependencies = [ dependencies = [
"env_logger", "env_logger",
"log", "log",
@@ -918,7 +919,7 @@ dependencies = [
[[package]] [[package]]
name = "rog_dbus" name = "rog_dbus"
version = "3.5.0" version = "3.5.1"
dependencies = [ dependencies = [
"rog_anime", "rog_anime",
"rog_aura", "rog_aura",
@@ -940,7 +941,7 @@ dependencies = [
[[package]] [[package]]
name = "rog_profiles" name = "rog_profiles"
version = "0.1.1" version = "0.1.2"
dependencies = [ dependencies = [
"intel-pstate", "intel-pstate",
"rog_fan_curve", "rog_fan_curve",
+2 -2
View File
@@ -25,7 +25,7 @@ Various patches are required for keyboard support. See [this post](https://asus-
## Discord ## Discord
[Discord server link](https://discord.gg/ngbdKabAnP) [Discord server link](https://discord.gg/4ZKGd7Un5t)
## SUPPORTED LAPTOPS ## SUPPORTED LAPTOPS
@@ -111,4 +111,4 @@ Reference to any ASUS products, services, processes, or other information and/or
The use of ROG and ASUS trademarks within this website and associated tools and libraries is only to provide a recognisable identifier to users to enable them to associate that these tools will work with ASUS ROG laptops. The use of ROG and ASUS trademarks within this website and associated tools and libraries is only to provide a recognisable identifier to users to enable them to associate that these tools will work with ASUS ROG laptops.
--- ---
+2 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "asusctl" name = "asusctl"
version = "3.5.0" version = "3.5.1"
authors = ["Luke D Jones <luke@ljones.dev>"] authors = ["Luke D Jones <luke@ljones.dev>"]
edition = "2018" edition = "2018"
@@ -12,6 +12,7 @@ rog_aura = { path = "../rog-aura" }
rog_dbus = { path = "../rog-dbus" } rog_dbus = { path = "../rog-dbus" }
rog_profiles = { path = "../rog-profiles" } rog_profiles = { path = "../rog-profiles" }
rog_types = { path = "../rog-types" } rog_types = { path = "../rog-types" }
daemon = { path = "../daemon" }
rog_fan_curve = { version = "^0.1", features = ["serde"] } rog_fan_curve = { version = "^0.1", features = ["serde"] }
gumdrop = "^0.8" gumdrop = "^0.8"
yansi-term = "^0.1" yansi-term = "^0.1"
+4 -2
View File
@@ -124,6 +124,8 @@ pub struct MultiColourSpeed {
/// Byte value for setting the built-in mode. /// Byte value for setting the built-in mode.
/// ///
/// Enum corresponds to the required integer value /// Enum corresponds to the required integer value
///
// NOTE: The option names here must match those in rog-aura crate
#[derive(Options)] #[derive(Options)]
pub enum SetAuraBuiltin { pub enum SetAuraBuiltin {
#[options(help = "set a single static colour")] #[options(help = "set a single static colour")]
@@ -135,7 +137,7 @@ pub enum SetAuraBuiltin {
#[options(help = "rainbow cycling in one of four directions")] #[options(help = "rainbow cycling in one of four directions")]
Rainbow(SingleSpeedDirection), Rainbow(SingleSpeedDirection),
#[options(help = "rain pattern mimicking raindrops")] #[options(help = "rain pattern mimicking raindrops")]
Star(TwoColourSpeed), Stars(TwoColourSpeed),
#[options(help = "rain pattern of three preset colours")] #[options(help = "rain pattern of three preset colours")]
Rain(SingleSpeed), Rain(SingleSpeed),
#[options(help = "pressed keys are highlighted to fade")] #[options(help = "pressed keys are highlighted to fade")]
@@ -233,7 +235,7 @@ impl From<&SetAuraBuiltin> for AuraEffect {
data.mode = AuraModeNum::Rainbow; data.mode = AuraModeNum::Rainbow;
data data
} }
SetAuraBuiltin::Star(x) => { SetAuraBuiltin::Stars(x) => {
let mut data: AuraEffect = x.into(); let mut data: AuraEffect = x.into();
data.mode = AuraModeNum::Star; data.mode = AuraModeNum::Star;
data data
+24 -68
View File
@@ -14,7 +14,6 @@ use rog_types::{
gfx_vendors::{GfxRequiredUserAction, GfxVendors}, gfx_vendors::{GfxRequiredUserAction, GfxVendors},
supported::{ supported::{
FanCpuSupportedFunctions, LedSupportedFunctions, RogBiosSupportedFunctions, FanCpuSupportedFunctions, LedSupportedFunctions, RogBiosSupportedFunctions,
SupportedFunctions,
}, },
}; };
use std::{env::args, path::Path}; use std::{env::args, path::Path};
@@ -133,16 +132,16 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let supported = dbus.proxies().supported().get_supported_functions()?; let supported = dbus.proxies().supported().get_supported_functions()?;
if parsed.help {
print_supported_help(&supported, &parsed);
println!("\nSee https://asus-linux.org/faq/ for additional help");
std::process::exit(1);
}
if parsed.version { if parsed.version {
println!(" asusctl v{}", env!("CARGO_PKG_VERSION")); println!("\nApp and daemon versions:");
println!(" rog-dbus v{}", rog_dbus::VERSION); println!(" asusctl v{}", env!("CARGO_PKG_VERSION"));
println!("rog-types v{}", rog_types::VERSION); println!(" asusd v{}", daemon::VERSION);
println!("\nComponent crate versions:");
println!(" rog-anime v{}", rog_anime::VERSION);
println!(" rog-aura v{}", rog_aura::VERSION);
println!(" rog-dbus v{}", rog_dbus::VERSION);
println!("rog-profiles v{}", rog_profiles::VERSION);
println!(" rog-types v{}", rog_types::VERSION);
return Ok(()); return Ok(());
} }
@@ -224,8 +223,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
} }
if parsed.show_supported { if parsed.show_supported {
let dat = dbus.proxies().supported().get_supported_functions()?; println!("Supported laptop functions:\n\n{}", supported);
println!("Supported laptop functions:\n\n{}", dat);
} }
if let Some(chg_limit) = parsed.chg_limit { if let Some(chg_limit) = parsed.chg_limit {
@@ -235,57 +233,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Ok(()) Ok(())
} }
fn print_supported_help(supported: &SupportedFunctions, parsed: &CliStart) {
// As help option don't work with `parse_args_default`
// we will call `parse_args_default_or_exit` instead
let usage: Vec<String> = parsed.self_usage().lines().map(|s| s.to_string()).collect();
for line in usage.iter().filter(|line| {
if line.contains("--fan-mode") && !supported.fan_cpu_ctrl.stock_fan_modes {
return false;
}
if line.contains("--chg-limit") && !supported.charge_ctrl.charge_level_set {
return false;
}
true
}) {
println!("{}", line);
}
// command strings are in order of the struct
let commands: Vec<String> = CliCommand::usage().lines().map(|s| s.to_string()).collect();
println!("\nCommands available");
for line in commands.iter().filter(|line| {
if line.contains("profile")
&& !supported.fan_cpu_ctrl.stock_fan_modes
&& !supported.fan_cpu_ctrl.fan_curve_set
{
return false;
}
if line.contains("led-mode") && !supported.keyboard_led.stock_led_modes.is_empty() {
return false;
}
if line.contains("bios")
&& (!supported.rog_bios_ctrl.dedicated_gfx_toggle
|| !supported.rog_bios_ctrl.post_sound_toggle)
{
return false;
}
if line.contains("anime") && !supported.anime_ctrl.0 {
return false;
}
true
}) {
println!("{}", line);
}
if !supported.fan_cpu_ctrl.stock_fan_modes {
println!("Note: Fan mode control is not supported by this laptop");
}
if !supported.charge_ctrl.charge_level_set {
println!("Note: Charge control is not supported by this laptop");
}
}
fn do_gfx( fn do_gfx(
dbus: &RogDbusClient, dbus: &RogDbusClient,
supported: &RogBiosSupportedFunctions, supported: &RogBiosSupportedFunctions,
@@ -369,7 +316,7 @@ fn handle_led_mode(
.collect(); .collect();
for command in commands.iter().filter(|command| { for command in commands.iter().filter(|command| {
for mode in &supported.stock_led_modes { for mode in &supported.stock_led_modes {
if command.contains(<&str>::from(mode)) { if command.contains(&<&str>::from(mode).to_lowercase()) {
return true; return true;
} }
} }
@@ -494,12 +441,21 @@ fn handle_profile(
} }
let mut set_profile = false; let mut set_profile = false;
let mut profile; let mut profile = Profile::default();
if cmd.create { if cmd.create {
profile = Profile::default();
set_profile = true; set_profile = true;
} else { } else if let Some(ref name) = cmd.profile {
profile = dbus.proxies().profile().active_data()?; let profiles = dbus.proxies().profile().all_profile_data()?;
for p in profiles {
if p.name == *name {
profile = p;
break;
}
}
if profile.name != *name {
println!("The requested profile doesn't exist, you may need to create it");
std::process::exit(-1);
}
} }
if let Some(turbo) = cmd.turbo { if let Some(turbo) = cmd.turbo {
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "daemon" name = "daemon"
version = "3.7.1" version = "3.7.2"
license = "MPL-2.0" license = "MPL-2.0"
readme = "README.md" readme = "README.md"
authors = ["Luke <luke@ljones.dev>"] authors = ["Luke <luke@ljones.dev>"]
+3 -3
View File
@@ -90,7 +90,7 @@ impl AuraConfig {
let mut buf = String::new(); let mut buf = String::new();
if let Ok(read_len) = file.read_to_string(&mut buf) { if let Ok(read_len) = file.read_to_string(&mut buf) {
if read_len == 0 { if read_len == 0 {
return AuraConfig::create_default(&mut file, &supported_led_modes); return AuraConfig::create_default(&mut file, supported_led_modes);
} else { } else {
if let Ok(data) = serde_json::from_str(&buf) { if let Ok(data) = serde_json::from_str(&buf) {
return data; return data;
@@ -109,7 +109,7 @@ impl AuraConfig {
panic!("Please remove {} then restart asusd", AURA_CONFIG_PATH); panic!("Please remove {} then restart asusd", AURA_CONFIG_PATH);
} }
} }
AuraConfig::create_default(&mut file, &supported_led_modes) AuraConfig::create_default(&mut file, supported_led_modes)
} }
fn create_default(file: &mut File, support_data: &LaptopLedData) -> Self { fn create_default(file: &mut File, support_data: &LaptopLedData) -> Self {
@@ -153,7 +153,7 @@ impl AuraConfig {
.unwrap_or_else(|err| error!("Could not write config: {}", err)); .unwrap_or_else(|err| error!("Could not write config: {}", err));
} }
/// Multipurpose, will accecpt AuraEffect with zones and put in the correct store /// Multipurpose, will accept AuraEffect with zones and put in the correct store
pub fn set_builtin(&mut self, effect: AuraEffect) { pub fn set_builtin(&mut self, effect: AuraEffect) {
match effect.zone() { match effect.zone() {
AuraZone::None => { AuraZone::None => {
+8 -9
View File
@@ -8,7 +8,6 @@ use logind_zbus::{
ManagerProxy, SessionProxy, ManagerProxy, SessionProxy,
}; };
use rog_types::gfx_vendors::{GfxPower, GfxRequiredUserAction, GfxVendors}; use rog_types::gfx_vendors::{GfxPower, GfxRequiredUserAction, GfxVendors};
use std::iter::FromIterator;
use std::{io::Write, ops::Add, path::Path, time::Instant}; use std::{io::Write, ops::Add, path::Path, time::Instant};
use std::{process::Command, thread::sleep, time::Duration}; use std::{process::Command, thread::sleep, time::Duration};
use std::{str::FromStr, sync::mpsc}; use std::{str::FromStr, sync::mpsc};
@@ -79,20 +78,20 @@ impl CtrlGraphics {
match dev.vendor()? { match dev.vendor()? {
0x1002 => { 0x1002 => {
info!("GFX: {}: AMD graphics", dev.id()); info!("GFX: {}: AMD graphics", dev.id());
amd.push(GraphicsDevice::new(dev.id().to_owned(), functions(&dev))); amd.push(GraphicsDevice::new(dev.id().to_owned(), functions(dev)));
} }
0x10DE => { 0x10DE => {
info!("GFX: {}: NVIDIA graphics", dev.id()); info!("GFX: {}: NVIDIA graphics", dev.id());
dev.set_runtime_pm(sysfs_class::RuntimePowerManagement::On)?; dev.set_runtime_pm(sysfs_class::RuntimePowerManagement::On)?;
nvidia.push(GraphicsDevice::new(dev.id().to_owned(), functions(&dev))); nvidia.push(GraphicsDevice::new(dev.id().to_owned(), functions(dev)));
} }
0x8086 => { 0x8086 => {
info!("GFX: {}: Intel graphics", dev.id()); info!("GFX: {}: Intel graphics", dev.id());
intel.push(GraphicsDevice::new(dev.id().to_owned(), functions(&dev))); intel.push(GraphicsDevice::new(dev.id().to_owned(), functions(dev)));
} }
vendor => { vendor => {
info!("GFX: {}: Other({:X}) graphics", dev.id(), vendor); info!("GFX: {}: Other({:X}) graphics", dev.id(), vendor);
other.push(GraphicsDevice::new(dev.id().to_owned(), functions(&dev))); other.push(GraphicsDevice::new(dev.id().to_owned(), functions(dev)));
} }
} }
} }
@@ -265,13 +264,13 @@ impl CtrlGraphics {
let unbinds = devices.iter().map(|dev| dev.unbind()); let unbinds = devices.iter().map(|dev| dev.unbind());
// Remove NVIDIA graphics devices and their functions // Remove NVIDIA graphics devices and their functions
let removes = devices.iter().map(|dev| dev.remove()); let removes = devices.iter().map(|dev| dev.remove());
Result::from_iter(unbinds.chain(removes)) unbinds.chain(removes).collect::<Result<_, _>>()
.map_err(|err| RogError::Command("device unbind error".into(), err)) .map_err(|err| RogError::Command("device unbind error".into(), err))
} }
fn unbind_only(devices: &[GraphicsDevice]) -> Result<(), RogError> { fn unbind_only(devices: &[GraphicsDevice]) -> Result<(), RogError> {
let unbinds = devices.iter().map(|dev| dev.unbind()); let unbinds = devices.iter().map(|dev| dev.unbind());
Result::from_iter(unbinds) unbinds.collect::<Result<_, _>>()
.map_err(|err| RogError::Command("device unbind error".into(), err)) .map_err(|err| RogError::Command("device unbind error".into(), err))
} }
@@ -462,7 +461,7 @@ impl CtrlGraphics {
for driver in NVIDIA_DRIVERS.iter() { for driver in NVIDIA_DRIVERS.iter() {
Self::do_driver_action(driver, "rmmod")?; Self::do_driver_action(driver, "rmmod")?;
} }
Self::unbind_only(&devices)?; Self::unbind_only(devices)?;
Self::do_driver_action("vfio-pci", "modprobe")?; Self::do_driver_action("vfio-pci", "modprobe")?;
} else { } else {
return Err(GfxError::VfioDisabled.into()); return Err(GfxError::VfioDisabled.into());
@@ -478,7 +477,7 @@ impl CtrlGraphics {
for driver in NVIDIA_DRIVERS.iter() { for driver in NVIDIA_DRIVERS.iter() {
Self::do_driver_action(driver, "rmmod")?; Self::do_driver_action(driver, "rmmod")?;
} }
Self::unbind_remove_nvidia(&devices)?; Self::unbind_remove_nvidia(devices)?;
} }
} }
Ok(()) Ok(())
+2 -2
View File
@@ -83,7 +83,7 @@ impl GraphicsDevice {
Ok(driver) => { Ok(driver) => {
info!("{}: Unbinding {}", driver.id(), func.id()); info!("{}: Unbinding {}", driver.id(), func.id());
unsafe { unsafe {
driver.unbind(&func).map_err(|err| { driver.unbind(func).map_err(|err| {
error!("gfx unbind: {}", err); error!("gfx unbind: {}", err);
err err
})?; })?;
@@ -109,7 +109,7 @@ impl GraphicsDevice {
Ok(driver) => { Ok(driver) => {
info!("{}: Binding {}", driver.id(), func.id()); info!("{}: Binding {}", driver.id(), func.id());
unsafe { unsafe {
driver.bind(&func).map_err(|err| { driver.bind(func).map_err(|err| {
error!("gfx bind: {}", err); error!("gfx bind: {}", err);
err err
})?; })?;
+2 -2
View File
@@ -370,7 +370,7 @@ impl CtrlKbdLed {
self.config.read(); self.config.read();
if let Some(data) = self.config.builtins.get(&next) { if let Some(data) = self.config.builtins.get(&next) {
self.write_mode(&data)?; self.write_mode(data)?;
self.config.current_mode = next; self.config.current_mode = next;
} }
self.config.write(); self.config.write();
@@ -381,7 +381,7 @@ impl CtrlKbdLed {
#[inline] #[inline]
fn write_mode(&self, mode: &AuraEffect) -> Result<(), RogError> { fn write_mode(&self, mode: &AuraEffect) -> Result<(), RogError> {
if !self.supported_modes.standard.contains(&mode.mode()) { if !self.supported_modes.standard.contains(mode.mode()) {
return Err(RogError::NotSupported); return Err(RogError::NotSupported);
} }
let bytes: [u8; LED_MSG_LEN] = mode.into(); let bytes: [u8; LED_MSG_LEN] = mode.into();
+23 -8
View File
@@ -1,6 +1,6 @@
use crate::error::RogError; use crate::error::RogError;
use crate::{config::Config, GetSupported}; use crate::{config::Config, GetSupported};
use log::info; use log::{info, warn};
use rog_profiles::profiles::Profile; use rog_profiles::profiles::Profile;
use rog_types::supported::FanCpuSupportedFunctions; use rog_types::supported::FanCpuSupportedFunctions;
use std::sync::Arc; use std::sync::Arc;
@@ -23,12 +23,12 @@ impl GetSupported for CtrlFanAndCpu {
} }
impl crate::Reloadable for CtrlFanAndCpu { impl crate::Reloadable for CtrlFanAndCpu {
/// Fetcht he active profile and use that to set all related components up
fn reload(&mut self) -> Result<(), RogError> { fn reload(&mut self) -> Result<(), RogError> {
if let Ok(mut cfg) = self.config.clone().try_lock() { if let Ok(mut cfg) = self.config.clone().try_lock() {
let active = cfg.active_profile.clone(); let active = cfg.active_profile.clone();
if let Some(existing) = cfg.power_profiles.get_mut(&active) { if let Some(existing) = cfg.power_profiles.get_mut(&active) {
existing.set_system_all()?; existing.set_system_all()?;
cfg.write();
} }
} }
Ok(()) Ok(())
@@ -38,31 +38,38 @@ impl crate::Reloadable for CtrlFanAndCpu {
impl CtrlFanAndCpu { impl CtrlFanAndCpu {
pub fn new(config: Arc<Mutex<Config>>) -> Result<Self, RogError> { pub fn new(config: Arc<Mutex<Config>>) -> Result<Self, RogError> {
Profile::get_fan_path()?; Profile::get_fan_path()?;
info!("Device has thermal throttle control"); info!("Device has fan control available");
Ok(CtrlFanAndCpu { config }) Ok(CtrlFanAndCpu { config })
} }
/// Toggle to next profile in list /// Toggle to next profile in list
pub(super) fn do_next_profile(&mut self) -> Result<(), RogError> { pub(super) fn do_next_profile(&mut self) -> Result<(), RogError> {
if let Ok(mut config) = self.config.clone().try_lock() { if let Ok(mut config) = self.config.clone().try_lock() {
// Read first just incase the user has modified the config before calling this
config.read(); config.read();
let mut i = config let mut toggle_index = config
.toggle_profiles .toggle_profiles
.binary_search(&config.active_profile) .binary_search(&config.active_profile)
.unwrap_or(0) .unwrap_or(0)
+ 1; + 1;
if i >= config.toggle_profiles.len() { if toggle_index >= config.toggle_profiles.len() {
i = 0; toggle_index = 0;
} }
let profile = config.toggle_profiles[i].clone(); let profile = config.toggle_profiles[toggle_index].clone();
if let Some(existing) = config.power_profiles.get(&profile) { if let Some(existing) = config.power_profiles.get(&profile) {
existing.set_system_all()?; existing.set_system_all()?;
config.active_profile = existing.name.clone(); config.active_profile = existing.name.clone();
config.write(); config.write();
info!("Profile was changed to: {}", profile); info!("Profile was changed to: {}", &profile);
} else {
warn!(
"toggle_profile {} does not exist in power_profiles",
&profile
);
return Err(RogError::MissingProfile(profile.to_string()));
} }
} }
Ok(()) Ok(())
@@ -70,17 +77,25 @@ impl CtrlFanAndCpu {
pub(super) fn set_active(&mut self, profile: &str) -> Result<(), RogError> { pub(super) fn set_active(&mut self, profile: &str) -> Result<(), RogError> {
if let Ok(mut config) = self.config.clone().try_lock() { if let Ok(mut config) = self.config.clone().try_lock() {
// Read first just incase the user has modified the config before calling this
config.read(); config.read();
if let Some(existing) = config.power_profiles.get(profile) { if let Some(existing) = config.power_profiles.get(profile) {
existing.set_system_all()?; existing.set_system_all()?;
config.active_profile = existing.name.clone(); config.active_profile = existing.name.clone();
config.write(); config.write();
info!("Profile was changed to: {}", profile); info!("Profile was changed to: {}", profile);
} else {
warn!(
"toggle_profile {} does not exist in power_profiles",
profile
);
return Err(RogError::MissingProfile(profile.to_string()));
} }
} }
Ok(()) Ok(())
} }
/// Create a new profile if the requested name doesn't exist, or modify existing
pub(super) fn new_or_modify(&mut self, profile: &Profile) -> Result<(), RogError> { pub(super) fn new_or_modify(&mut self, profile: &Profile) -> Result<(), RogError> {
if let Ok(mut config) = self.config.clone().try_lock() { if let Ok(mut config) = self.config.clone().try_lock() {
config.read(); config.read();
+1 -1
View File
@@ -139,7 +139,7 @@ impl FanAndCpuZbus {
if let Ok(ctrl) = self.inner.try_lock() { if let Ok(ctrl) = self.inner.try_lock() {
if let Ok(cfg) = ctrl.config.clone().try_lock() { if let Ok(cfg) = ctrl.config.clone().try_lock() {
if let Some(profile) = cfg.power_profiles.get(&cfg.active_profile) { if let Some(profile) = cfg.power_profiles.get(&cfg.active_profile) {
self.notify_profile(&profile) self.notify_profile(profile)
.unwrap_or_else(|err| warn!("{}", err)); .unwrap_or_else(|err| warn!("{}", err));
} }
} }
+13
View File
@@ -20,6 +20,7 @@ use std::error::Error;
use std::io::Write; use std::io::Write;
use std::sync::Arc; use std::sync::Arc;
use std::sync::Mutex; use std::sync::Mutex;
use std::env;
use daemon::ctrl_rog_bios::CtrlRogBios; use daemon::ctrl_rog_bios::CtrlRogBios;
use std::convert::Into; use std::convert::Into;
@@ -35,6 +36,18 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
.filter(None, LevelFilter::Info) .filter(None, LevelFilter::Info)
.init(); .init();
let is_service = match env::var_os("IS_SERVICE") {
Some(val) => val == "1",
None => false,
};
if !is_service {
println!("asusd schould be only run from the right systemd service");
println!("do not run in your terminal, if you need an logs please use journalctl -b -u asusd");
println!("asusd will now exit");
return Ok(());
}
info!(" daemon v{}", daemon::VERSION); info!(" daemon v{}", daemon::VERSION);
info!(" rog-anime v{}", rog_anime::VERSION); info!(" rog-anime v{}", rog_anime::VERSION);
info!(" rog-aura v{}", rog_aura::VERSION); info!(" rog-aura v{}", rog_aura::VERSION);
-2
View File
@@ -8,7 +8,6 @@ use crate::ctrl_gfx::error::GfxError;
#[derive(Debug)] #[derive(Debug)]
pub enum RogError { pub enum RogError {
ParseFanLevel,
ParseVendor, ParseVendor,
ParseLed, ParseLed,
MissingProfile(String), MissingProfile(String),
@@ -36,7 +35,6 @@ impl fmt::Display for RogError {
// This trait requires `fmt` with this exact signature. // This trait requires `fmt` with this exact signature.
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self { match self {
RogError::ParseFanLevel => write!(f, "Parse profile error"),
RogError::ParseVendor => write!(f, "Parse gfx vendor error"), RogError::ParseVendor => write!(f, "Parse gfx vendor error"),
RogError::ParseLed => write!(f, "Parse LED error"), RogError::ParseLed => write!(f, "Parse LED error"),
RogError::MissingProfile(profile) => write!(f, "Profile does not exist {}", profile), RogError::MissingProfile(profile) => write!(f, "Profile does not exist {}", profile),
+1
View File
@@ -3,6 +3,7 @@ Description=ASUS Notebook Control
After=basic.target syslog.target After=basic.target syslog.target
[Service] [Service]
Environment=IS_SERVICE=1
ExecStart=/usr/bin/asusd ExecStart=/usr/bin/asusd
Restart=on-failure Restart=on-failure
Type=dbus Type=dbus
+16 -2
View File
@@ -12,6 +12,13 @@ standard = ["Static", "Breathe", "Strobe", "Rainbow", "Star", "Rain", "Highlight
multizone = false multizone = false
per_key = true per_key = true
[[led_data]]
prod_family = "Zephyrus M"
board_names = ["GM501GS"]
standard = ["Static", "Breathe", "Strobe", "Rainbow", "Pulse"]
multizone = true
per_key = false
[[led_data]] [[led_data]]
prod_family = "ROG Zephyrus M15" prod_family = "ROG Zephyrus M15"
board_names = ["GU502LW"] board_names = ["GU502LW"]
@@ -35,14 +42,14 @@ per_key = false
[[led_data]] [[led_data]]
prod_family = "ROG Strix" prod_family = "ROG Strix"
board_names = ["G531GW", "G733QS", "G733QR"] board_names = ["G531GW", "G533QR", "G733QS", "G733QR"]
standard = ["Static", "Breathe", "Strobe", "Rainbow", "Star", "Rain", "Highlight", "Laser", "Ripple", "Pulse", "Comet", "Flash"] standard = ["Static", "Breathe", "Strobe", "Rainbow", "Star", "Rain", "Highlight", "Laser", "Ripple", "Pulse", "Comet", "Flash"]
multizone = false multizone = false
per_key = true per_key = true
[[led_data]] [[led_data]]
prod_family = "ROG Strix" prod_family = "ROG Strix"
board_names = ["GX531", "G512LV", "G712LV", "G712LW"] board_names = ["GX531", "G512LV", "G712LV", "G712LW", "G513QY"]
standard = ["Static", "Breathe", "Strobe", "Rainbow", "Pulse"] standard = ["Static", "Breathe", "Strobe", "Rainbow", "Pulse"]
multizone = true multizone = true
per_key = false per_key = false
@@ -54,6 +61,13 @@ standard = ["Static", "Breathe", "Strobe", "Rainbow", "Pulse"]
multizone = false multizone = false
per_key = false per_key = false
[[led_data]]
prod_family = "ROG Strix"
board_names = ["G513IH"]
standard = ["Static", "Breathe", "Strobe", "Rainbow", "Star", "Pulse"]
multizone = true
per_key = false
[[led_data]] [[led_data]]
prod_family = "Strix" prod_family = "Strix"
board_names = ["G731GV", "G731GW", "G531GV"] board_names = ["G731GV", "G731GW", "G531GV"]
+2
View File
@@ -5,6 +5,8 @@ StartLimitBurst=2
Before=display-manager.service Before=display-manager.service
[Service] [Service]
Environment=IS_SERVICE=1
ExecStartPre=/bin/sleep 2
ExecStart=/usr/bin/asusd ExecStart=/usr/bin/asusd
Restart=on-failure Restart=on-failure
Restart=always Restart=always
+6 -6
View File
@@ -64,7 +64,7 @@ impl ActionData {
time: duration, time: duration,
brightness, brightness,
} => ActionData::Animation(AnimeGif::create_diagonal_gif( } => ActionData::Animation(AnimeGif::create_diagonal_gif(
&file, file,
*duration, *duration,
*brightness, *brightness,
)?), )?),
@@ -79,7 +79,7 @@ impl ActionData {
if let Some(ext) = file.extension() { if let Some(ext) = file.extension() {
if ext.to_string_lossy().to_lowercase() == "png" { if ext.to_string_lossy().to_lowercase() == "png" {
return Ok(ActionData::Animation(AnimeGif::create_png_static( return Ok(ActionData::Animation(AnimeGif::create_png_static(
&file, file,
*scale, *scale,
*angle, *angle,
*translation, *translation,
@@ -89,7 +89,7 @@ impl ActionData {
} }
} }
ActionData::Animation(AnimeGif::create_png_gif( ActionData::Animation(AnimeGif::create_png_gif(
&file, file,
*scale, *scale,
*angle, *angle,
*translation, *translation,
@@ -107,7 +107,7 @@ impl ActionData {
} => { } => {
if let Some(time) = time { if let Some(time) = time {
return Ok(ActionData::Animation(AnimeGif::create_png_static( return Ok(ActionData::Animation(AnimeGif::create_png_static(
&file, file,
*scale, *scale,
*angle, *angle,
*translation, *translation,
@@ -116,7 +116,7 @@ impl ActionData {
)?)); )?));
} }
// If no time then create a plain static image // If no time then create a plain static image
let image = AnimeImage::from_png(&file, *scale, *angle, *translation, *brightness)?; let image = AnimeImage::from_png(file, *scale, *angle, *translation, *brightness)?;
let data = <AnimeDataBuffer>::from(&image); let data = <AnimeDataBuffer>::from(&image);
ActionData::Image(Box::new(data)) ActionData::Image(Box::new(data))
} }
@@ -157,7 +157,7 @@ impl Sequences {
pub fn iter(&self) -> ActionIterator { pub fn iter(&self) -> ActionIterator {
ActionIterator { ActionIterator {
actions: &self, actions: self,
next_idx: 0, next_idx: 0,
} }
} }
+1 -1
View File
@@ -39,7 +39,7 @@ impl Sequences {
pub fn iter(&self) -> ActionIterator { pub fn iter(&self) -> ActionIterator {
ActionIterator { ActionIterator {
actions: &self, actions: self,
next_idx: 0, next_idx: 0,
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "rog_dbus" name = "rog_dbus"
version = "3.5.0" version = "3.5.1"
license = "MPL-2.0" license = "MPL-2.0"
readme = "README.md" readme = "README.md"
authors = ["Luke <luke@ljones.dev>"] authors = ["Luke <luke@ljones.dev>"]
+1 -1
View File
@@ -37,7 +37,7 @@ pub struct AnimeProxy<'a>(DaemonProxy<'a>);
impl<'a> AnimeProxy<'a> { impl<'a> AnimeProxy<'a> {
#[inline] #[inline]
pub fn new(conn: &Connection) -> Result<Self> { pub fn new(conn: &Connection) -> Result<Self> {
Ok(AnimeProxy(DaemonProxy::new(&conn)?)) Ok(AnimeProxy(DaemonProxy::new(conn)?))
} }
#[inline] #[inline]
+1 -1
View File
@@ -44,7 +44,7 @@ pub struct ChargeProxy<'a>(DaemonProxy<'a>);
impl<'a> ChargeProxy<'a> { impl<'a> ChargeProxy<'a> {
#[inline] #[inline]
pub fn new(conn: &Connection) -> Result<Self> { pub fn new(conn: &Connection) -> Result<Self> {
Ok(ChargeProxy(DaemonProxy::new(&conn)?)) Ok(ChargeProxy(DaemonProxy::new(conn)?))
} }
#[inline] #[inline]
+1 -1
View File
@@ -52,7 +52,7 @@ pub struct GfxProxy<'a>(DaemonProxy<'a>);
impl<'a> GfxProxy<'a> { impl<'a> GfxProxy<'a> {
#[inline] #[inline]
pub fn new(conn: &Connection) -> Result<Self> { pub fn new(conn: &Connection) -> Result<Self> {
Ok(GfxProxy(DaemonProxy::new(&conn)?)) Ok(GfxProxy(DaemonProxy::new(conn)?))
} }
#[inline] #[inline]
+1 -1
View File
@@ -81,7 +81,7 @@ pub struct LedProxy<'a>(DaemonProxy<'a>);
impl<'a> LedProxy<'a> { impl<'a> LedProxy<'a> {
#[inline] #[inline]
pub fn new(conn: &Connection) -> Result<Self> { pub fn new(conn: &Connection) -> Result<Self> {
Ok(LedProxy(DaemonProxy::new(&conn)?)) Ok(LedProxy(DaemonProxy::new(conn)?))
} }
#[inline] #[inline]
+1 -1
View File
@@ -60,7 +60,7 @@ pub struct ProfileProxy<'a>(DaemonProxy<'a>);
impl<'a> ProfileProxy<'a> { impl<'a> ProfileProxy<'a> {
#[inline] #[inline]
pub fn new(conn: &Connection) -> Result<Self> { pub fn new(conn: &Connection) -> Result<Self> {
Ok(ProfileProxy(DaemonProxy::new(&conn)?)) Ok(ProfileProxy(DaemonProxy::new(conn)?))
} }
#[inline] #[inline]
+1 -1
View File
@@ -54,7 +54,7 @@ pub struct RogBiosProxy<'a>(DaemonProxy<'a>);
impl<'a> RogBiosProxy<'a> { impl<'a> RogBiosProxy<'a> {
#[inline] #[inline]
pub fn new(conn: &Connection) -> Result<Self> { pub fn new(conn: &Connection) -> Result<Self> {
Ok(RogBiosProxy(DaemonProxy::new(&conn)?)) Ok(RogBiosProxy(DaemonProxy::new(conn)?))
} }
#[inline] #[inline]
+1 -1
View File
@@ -36,7 +36,7 @@ pub struct SupportProxy<'a>(DaemonProxy<'a>);
impl<'a> SupportProxy<'a> { impl<'a> SupportProxy<'a> {
#[inline] #[inline]
pub fn new(conn: &Connection) -> Result<Self> { pub fn new(conn: &Connection) -> Result<Self> {
Ok(SupportProxy(DaemonProxy::new(&conn)?)) Ok(SupportProxy(DaemonProxy::new(conn)?))
} }
#[inline] #[inline]
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "rog_profiles" name = "rog_profiles"
version = "0.1.1" version = "0.1.2"
authors = ["Luke D. Jones <luke@ljones.dev>"] authors = ["Luke D. Jones <luke@ljones.dev>"]
edition = "2018" edition = "2018"
-4
View File
@@ -6,7 +6,6 @@ use rog_fan_curve::CurveError;
#[derive(Debug)] #[derive(Debug)]
pub enum ProfileError { pub enum ProfileError {
ParseFanLevel, ParseFanLevel,
MissingProfile(String),
Path(String, std::io::Error), Path(String, std::io::Error),
Read(String, std::io::Error), Read(String, std::io::Error),
Write(String, std::io::Error), Write(String, std::io::Error),
@@ -23,9 +22,6 @@ impl fmt::Display for ProfileError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self { match self {
ProfileError::ParseFanLevel => write!(f, "Parse profile error"), ProfileError::ParseFanLevel => write!(f, "Parse profile error"),
ProfileError::MissingProfile(profile) => {
write!(f, "Profile does not exist {}", profile)
}
ProfileError::Path(path, error) => write!(f, "Path {}: {}", path, error), ProfileError::Path(path, error) => write!(f, "Path {}: {}", path, error),
ProfileError::Read(path, error) => write!(f, "Read {}: {}", path, error), ProfileError::Read(path, error) => write!(f, "Read {}: {}", path, error),
ProfileError::Write(path, error) => write!(f, "Write {}: {}", path, error), ProfileError::Write(path, error) => write!(f, "Write {}: {}", path, error),