Refactor and rename a large amount of things to cleanup meanings

This commit is contained in:
Luke D Jones
2020-08-04 20:56:03 +12:00
parent 584ca023ad
commit 3615cff09d
18 changed files with 173 additions and 281 deletions

216
README.md
View File

@@ -1,36 +1,23 @@
# ROG-Core
# ASUS NB Ctrl
**NOTICE:**
I have completed kernel patches to move a large chunk of rog-core functionality
in to the Linux kernel. The patch is not in mainline yet, but can be found in the
`./kernel-patch/` directory. The patch enables the following in kernel:
This program requires the kernel patch in `./kernel-patch/` to be applied.
As of 04/08/2020 these have been submitted to lkml.
The patch enables the following in kernel:
- All hotkeys (FN+Key combos)
- Control of keyboard brightness using FN+Key combos (not RGB)
- FN+F5 (fan) to toggle fan modes. You can watch the path `/sys/devices/platform/asus-nb-wmi/throttle_thermal_policy`
to see which mode you are in
- FN+F5 (fan) to toggle fan modes
You will not get RGB control in kernel (yet), and rog-core is still required to
change modes and RGB settings. The current version in master and last release
still take full control of the interfaces
**work on a version of rog-core for use with the kernel patch is in another branch**
The last version of rog-core will work with any kernel with or without this patch
and provide full functions.
You will not get RGB control in kernel (yet), and asusd is still required to
change modes and RGB settings. The previous version of this program is named
`rog-core` and takes full control of the interfaces required - if you can't
apply the kernel patches then `rog-core` is still highly usable.
---
rog-core is a utility for Linux to control many aspects (eventually) of the ASUS
ROG laptops like the Zephyrus GX502GW.
One of the benefits of this app (for me at least) is that you *don't* require a
kernel with correct support for the laptop keyboard EC. The app
reads and writes direct to the device interrupts, and can be customised (in
source) quite extensively to do what you want such as directly controlling your
laptop backlight rather than emitting a key-press for the DE to handle.
Other laptop functions such as fan modes or battery charge limiting will need
kernel level support which exists in most newer kernels (higher than 5.6.10).
asusd is a utility for Linux to control many aspects of various ASUS laptops.
## Discord
@@ -38,6 +25,8 @@ kernel level support which exists in most newer kernels (higher than 5.6.10).
## SUPPORTED LAPTOPS
If your laptop is not in the following lists, it may still work with fan-mode switching and charge limit control.
**Please help test or provide info for:**
- GL703(0x1869)
@@ -47,34 +36,32 @@ kernel level support which exists in most newer kernels (higher than 5.6.10).
a little between models, e.g, some RGB modes are missing, or it's a single colour.
As far as I can see, the EC does not give us a way to find what modes are supported.
### KEYS + OTHER FUNCTIONS
### ANIME AND OTHER FUNCTIONS
Media keys are Volume -/+, Mute output, previous, next, play/pause. These keys are grouped together on one interface block on the keyboard EC
as a "Consumer Device" HID, all other fn+<key> combo are on another interface which is "Vendor Custom", this includes things like keyboard
LED brightness and mode change keys, Calc, fan-mode toggles etc.
| MODEL |Media keys| Additional FN+<KEY> | AniMe |Touchpad-Numpad| Fan Modes | Charge Limit |
|:-----:|:--------:|:-------------------:|:-----:|:-------------:|:---------:|:------------:|
| GM501 | X | X | | | X | X |
| GX502 | X | X | | | X | X |
| GX531 | X | X | | | X | X |
| GX701 | X | X | | | X | X |
| G512 | X | X | | | X | X |
| G712 | X | X | | | X | X |
| G531 | X | X | | | X | X |
| G731 | X | X | | | X | X |
| G532 | X | X | | | X | X |
| GA401 | X | X | X | | X | X |
| GA502 | X | X | X | | X | X |
| GU502 | X | X | X | | X | X |
| MODEL | AniMe |Touchpad-Numpad| Fan Modes | Charge Limit |
|:-----:|:-----:|:-------------:|:---------:|:------------:|
| GM501 | | | X | X |
| GX502 | | | X | X |
| GX531 | | | X | X |
| GX701 | | | X | X |
| G512 | | | X | X |
| G712 | | | X | X |
| G531 | | | X | X |
| G731 | | | X | X |
| G532 | | | X | X |
| GA401 | X | | X | X |
| GA502 | X | | X | X |
| GU502 | X | | X | X |
**NOTE:** GA14/GA401 and GA15/GA502/GU502, You will need kernel [patches](https://lab.retarded.farm/zappel/asus-rog-zephyrus-g14/-/tree/master/kernel_patches).
### LED MODES
**NOTE:** If charge limit or fan modes are not working, then you may require a kernel newer than 5.6.10.
### KEYBOARD BACKLIGHT MODES
Models GA401, GA502, GU502 support LED brightness change only (no RGB).
| MODEL | SINGLE | BREATHING | STROBE | RAINBOW | STAR | RAIN | HIGHLIGHT | LASER | RIPPLE | PULSE | COMET | FLASH | ZONES | PER-KEY RGB |
| MODEL | STATIC | BREATHING | STROBE | RAINBOW | STAR | RAIN | HIGHLIGHT | LASER | RIPPLE | PULSE | COMET | FLASH | ZONES | PER-KEY RGB |
|:------:|:------:|:---------:|:------:|:-------:|:----:|:----:|:---------:|:-----:|:------:|:-----:|:-----:|:-----:|:-----:|:-----------:|
| G512LI | X | X | X | X | | | | | | | | | | |
| G712LI | X | X | X | X | | | | | | | | | | |
@@ -88,26 +75,13 @@ Models GA401, GA502, GU502 support LED brightness change only (no RGB).
| G731 | X | X | X | X | X | X | X | X | X | X | X | X | X | X |
| G532 | X | X | X | X | X | X | X | X | X | X | X | X | | X |
## Implemented
- [X] Daemon
- [X] Setting/modifying built-in LED modes
- [X] Per-key LED setting
- [X] Fancy LED modes (See examples)
- [X] Daemon mode
- [X] Saving settings for reload
- [ ] System control
+ [X] ROG key custom mapping (Can be done in source)
+ [X] Fan/Performance mode
+ [ ] Screen off? Now mapped to a keycode but has no effect
+ [X] Screen brightness up/down
+ [X] Touchpad toggle
+ [X] Sleep
+ [X] Airplane mode
- [X] Capture and use hotkeys
+ [X] Aura control by Aura keys
+ [X] Volume + media controls work
+ [X] Mic mute
- [X] Logging - required for journalctl
- [X] AniMatrix display on G14 models that include it
- [X] Set battery charge limit (with kernel supporting this)
@@ -131,40 +105,22 @@ started when the device is initialised and ready.
If you are upgrading from a previous installed version, you will need to restart the service or reboot.
```
$ systemctl daemon-reload && systemctl restart rog-core
$ systemctl daemon-reload && systemctl restart asusd
```
You may also need to activate the service for debian install. If running Pop!_OS, I suggest disabling `system76-power`
gnome-shell extension, or at least limiting use of the power-management parts as `rog-core` lets you set the same things
gnome-shell extension, or at least limiting use of the power-management parts as `asusd` lets you set the same things
(one or the other will overwrite pstates). I will create a shell extension at some point similar to system76, but using
the rog-core parts. It is safe to leave `system76-power.service` enabled and use for switching between graphics modes.
the asusd parts. It is safe to leave `system76-power.service` enabled and use for switching between graphics modes.
### Ubuntu PPA
## Uninstalling
Alternatively, instead of building manually you can use the PPA.
```
sudo add-apt-repository ppa:lukedjones/rog-core
sudo apt-get update
sudo apt-get install rog-core
```
the rog-core service will run when the device is initialised.
### Gentoo ebuild
Thanks to @aspann you can grab it here [sys-power/rog-core](https://lab.retarded.farm/zappel/zGentoo/-/tree/master/sys-power/rog-core)
### Arch AUR
You can find the thingimajig [here](https://aur.archlinux.org/packages/rog-core/). If
you are using a GA14 or GA15 series, you may need kernel [patches](https://lab.retarded.farm/zappel/asus-rog-zephyrus-g14/-/tree/master/kernel_patches).
Run `sudo make uninstall` in the source repo, and remove `/etc/asusd.conf`.
## Updating
Occasionally I might break things for you by tweaking or changing the config file layout. Usually this will mean you
need to remove `/etc/rog-core.conf` and restart the daemon to create a new one. You *can* back up the old one and copy
settings back over (then restart daemon again).
Occasionally you need to remove `/etc/asusd.conf` and restart the daemon to create a new one. You *can* back up the old
one and copy settings back over (then restart daemon again).
# Usage
@@ -182,27 +138,27 @@ the daemon mode over dbus.
Commands are given by:
```
rog-core <option> <command> <command-options>
asusd <option> <command> <command-options>
```
Help is available through:
```
rog-core --help
rog-core <command> --help
asusd --help
asusd <command> --help
```
Some commands may have subcommands:
```
rog-core <command> <subcommand> --help
asusd <command> <subcommand> --help
```
### Example
```
$ rog-core --help
Usage: rog-core [OPTIONS]
$ asusd --help
Usage: asusd [OPTIONS]
Optional arguments:
-h, --help print help message
@@ -214,8 +170,8 @@ Optional arguments:
Available commands:
led-mode Set the keyboard lighting from built-in modes
$ rog-core led-mode --help
Usage: rog-core led-mode [OPTIONS]
$ asusd led-mode --help
Usage: asusd led-mode [OPTIONS]
Optional arguments:
-h, --help print help message
@@ -235,15 +191,15 @@ Available commands:
flash set a wide vertical line zooming from left
multi-static 4-zone multi-colour
$ rog-core led-mode stable --help
Usage: rog-core led-mode stable [OPTIONS]
$ asusd led-mode stable --help
Usage: asusd led-mode stable [OPTIONS]
Optional arguments:
-h, --help print help message
-c HEX set the RGB value e.g, ff00ff
$ rog-core led-mode star --help
Usage: rog-core led-mode star [OPTIONS]
$ asusd led-mode star --help
Usage: asusd led-mode star [OPTIONS]
Optional arguments:
-h, --help print help message
@@ -252,39 +208,6 @@ Optional arguments:
-s SPEED set the speed: low, med, high
```
## ROG Key
The ROG key can be customized in a limited way by use of presets:
- Power
- Sleep
- MediaRecord
- MediaFastFwd
- MediaRewind
- MediaNext
- MediaPrev
- MediaStop
- MediaPlayPause
- MediaVolMute
- MediaVolUp
- MediaVolDown
- BacklightInc
- BacklightDec
- ControlConfig
- LaunchTextEditor
- LaunchEmailApp
- LaunchNewsReader
- LaunchCalendar
- LaunchCalculator
- LaunchWebBrowser
- FileBrowser
This key can be changed in /etc/rogcore.conf, for example:
```
{
"rog_key": "FileBrowser",
```
## Daemon mode
If the daemon service is enabled then on boot the following will be reloaded from save:
@@ -316,38 +239,7 @@ TODO: see `./wireshark_data/` for some captures.
### Supporting more laptops
At a minimum it probably needs to be a Zephyrus laptop. If there is enough interest I will remove the restriction on
board names so that anyone can try the app.
From there I'll need wireshark captures from Windows using Armoury Crate if possible:
- *No* USB devices plugged in
- One action per capture, 2 or 3 times
- An action may be switching a mode or pressing a button
The real ticket items are:
- Captures from installing Armoury Crate. To do this you need to uninstall almost all ASUS junkware and such
- Byte sequence captures from hotkeys pressed in linux (which I need to make a tool for)
- lsusb output
lsusb:
First do `lsusb |grep 0b05` and check the part after `0b05:`, output looks like:
```text
Bus 001 Device 005: ID 0b05:1866 ASUSTek Computer, Inc. N-KEY Device
```
Then do `sudo lsusb -vd 0b05:1866 > ~/laptop_info` and give that to me.
Other helpful info can be gained from `sudo usbhid-dump`, for which you may need to unload kernel drivers. Please google
this.
Also required (for my book-keeping of data):
- `cat /sys/class/dmi/id/product_name`
- `cat /sys/class/dmi/id/product_family`
- `cat /sys/class/dmi/id/board_name`
Please file a support request.
## License

View File

@@ -7,12 +7,12 @@ pub static CONFIG_PATH: &str = "/etc/asusd.conf";
#[derive(Default, Deserialize, Serialize)]
pub struct Config {
pub fan_mode: u8,
pub power_profile: u8,
pub bat_charge_limit: u8,
pub brightness: u8,
pub current_mode: u8,
pub builtin_modes: Vec<AuraModes>,
pub mode_performance: FanModeSettings,
pub kbd_boot_brightness: u8,
pub kbd_backlight_mode: u8,
pub kbd_backlight_modes: Vec<AuraModes>,
pub power_profiles: FanModeProfile,
}
impl Config {
@@ -31,10 +31,10 @@ impl Config {
// create a default config here
let mut c = Config::default();
c.bat_charge_limit = 100;
c.current_mode = 0;
c.kbd_backlight_mode = 0;
for n in supported_led_modes {
c.builtin_modes.push(AuraModes::from(*n))
c.kbd_backlight_modes.push(AuraModes::from(*n))
}
// Should be okay to unwrap this as is since it is a Default
@@ -76,17 +76,17 @@ impl Config {
pub fn set_mode_data(&mut self, mode: AuraModes) {
let byte: u8 = (&mode).into();
for (index, n) in self.builtin_modes.iter().enumerate() {
for (index, n) in self.kbd_backlight_modes.iter().enumerate() {
if byte == u8::from(n) {
// Consume it, OMNOMNOMNOM
self.builtin_modes[index] = mode;
self.kbd_backlight_modes[index] = mode;
break;
}
}
}
pub fn get_led_mode_data(&self, num: u8) -> Option<&AuraModes> {
for mode in &self.builtin_modes {
for mode in &self.kbd_backlight_modes {
if u8::from(mode) == num {
return Some(mode);
}
@@ -96,22 +96,22 @@ impl Config {
}
#[derive(Default, Deserialize, Serialize)]
pub struct FanModeSettings {
pub normal: IntelPState,
pub boost: IntelPState,
pub silent: IntelPState,
pub struct FanModeProfile {
pub normal: CPUSettings,
pub boost: CPUSettings,
pub silent: CPUSettings,
}
#[derive(Deserialize, Serialize)]
pub struct IntelPState {
pub struct CPUSettings {
pub min_percentage: u8,
pub max_percentage: u8,
pub no_turbo: bool,
}
impl Default for IntelPState {
impl Default for CPUSettings {
fn default() -> Self {
IntelPState {
CPUSettings {
min_percentage: 0,
max_percentage: 100,
no_turbo: false,

View File

@@ -62,10 +62,10 @@ impl crate::Controller for CtrlFanAndCPU {
async fn reload_from_config(&mut self, config: &mut Config) -> Result<(), Box<dyn Error>> {
let mut file = OpenOptions::new().write(true).open(self.path)?;
file.write_all(format!("{:?}\n", config.fan_mode).as_bytes())
file.write_all(format!("{:?}\n", config.power_profile).as_bytes())
.unwrap_or_else(|err| error!("Could not write to {}, {:?}", self.path, err));
self.set_pstate_for_fan_mode(FanLevel::from(config.fan_mode), config)?;
info!("Reloaded fan mode: {:?}", FanLevel::from(config.fan_mode));
self.set_pstate_for_fan_mode(FanLevel::from(config.power_profile), config)?;
info!("Reloaded fan mode: {:?}", FanLevel::from(config.power_profile));
Ok(())
}
}
@@ -98,13 +98,13 @@ impl CtrlFanAndCPU {
let mut buf = [0u8; 1];
file.read_exact(&mut buf)?;
if let Some(num) = char::from(buf[0]).to_digit(10) {
if config.fan_mode != num as u8 {
config.fan_mode = num as u8;
if config.power_profile != num as u8 {
config.power_profile = num as u8;
config.write();
self.set_pstate_for_fan_mode(FanLevel::from(config.fan_mode), config)?;
self.set_pstate_for_fan_mode(FanLevel::from(config.power_profile), config)?;
info!(
"Fan mode was changed: {:?}",
FanLevel::from(config.fan_mode)
FanLevel::from(config.power_profile)
);
}
return Ok(());
@@ -123,12 +123,12 @@ impl CtrlFanAndCPU {
) -> Result<(), Box<dyn Error>> {
let mut fan_ctrl = OpenOptions::new().write(true).open(self.path)?;
config.fan_mode = n;
config.power_profile = n;
config.write();
fan_ctrl
.write_all(format!("{:?}\n", config.fan_mode).as_bytes())
.write_all(format!("{:?}\n", config.power_profile).as_bytes())
.unwrap_or_else(|err| error!("Could not write to {}, {:?}", self.path, err));
info!("Fan mode set to: {:?}", FanLevel::from(config.fan_mode));
info!("Fan mode set to: {:?}", FanLevel::from(config.power_profile));
self.set_pstate_for_fan_mode(FanLevel::from(n), config)?;
Ok(())
}
@@ -142,36 +142,36 @@ impl CtrlFanAndCPU {
if let Ok(pstate) = intel_pstate::PState::new() {
match mode {
FanLevel::Normal => {
pstate.set_min_perf_pct(config.mode_performance.normal.min_percentage)?;
pstate.set_max_perf_pct(config.mode_performance.normal.max_percentage)?;
pstate.set_no_turbo(config.mode_performance.normal.no_turbo)?;
pstate.set_min_perf_pct(config.power_profiles.normal.min_percentage)?;
pstate.set_max_perf_pct(config.power_profiles.normal.max_percentage)?;
pstate.set_no_turbo(config.power_profiles.normal.no_turbo)?;
info!(
"Intel CPU Power: min: {:?}%, max: {:?}%, turbo: {:?}",
config.mode_performance.normal.min_percentage,
config.mode_performance.normal.max_percentage,
!config.mode_performance.normal.no_turbo
config.power_profiles.normal.min_percentage,
config.power_profiles.normal.max_percentage,
!config.power_profiles.normal.no_turbo
);
}
FanLevel::Boost => {
pstate.set_min_perf_pct(config.mode_performance.boost.min_percentage)?;
pstate.set_max_perf_pct(config.mode_performance.boost.max_percentage)?;
pstate.set_no_turbo(config.mode_performance.boost.no_turbo)?;
pstate.set_min_perf_pct(config.power_profiles.boost.min_percentage)?;
pstate.set_max_perf_pct(config.power_profiles.boost.max_percentage)?;
pstate.set_no_turbo(config.power_profiles.boost.no_turbo)?;
info!(
"Intel CPU Power: min: {:?}%, max: {:?}%, turbo: {:?}",
config.mode_performance.boost.min_percentage,
config.mode_performance.boost.max_percentage,
!config.mode_performance.boost.no_turbo
config.power_profiles.boost.min_percentage,
config.power_profiles.boost.max_percentage,
!config.power_profiles.boost.no_turbo
);
}
FanLevel::Silent => {
pstate.set_min_perf_pct(config.mode_performance.silent.min_percentage)?;
pstate.set_max_perf_pct(config.mode_performance.silent.max_percentage)?;
pstate.set_no_turbo(config.mode_performance.silent.no_turbo)?;
pstate.set_min_perf_pct(config.power_profiles.silent.min_percentage)?;
pstate.set_max_perf_pct(config.power_profiles.silent.max_percentage)?;
pstate.set_no_turbo(config.power_profiles.silent.no_turbo)?;
info!(
"Intel CPU Power: min: {:?}%, max: {:?}%, turbo: {:?}",
config.mode_performance.silent.min_percentage,
config.mode_performance.silent.max_percentage,
!config.mode_performance.silent.no_turbo
config.power_profiles.silent.min_percentage,
config.power_profiles.silent.max_percentage,
!config.power_profiles.silent.no_turbo
);
}
}
@@ -187,7 +187,7 @@ impl CtrlFanAndCPU {
})?;
match mode {
FanLevel::Normal => {
let boost = if config.mode_performance.normal.no_turbo {
let boost = if config.power_profiles.normal.no_turbo {
"0"
} else {
"1"
@@ -198,7 +198,7 @@ impl CtrlFanAndCPU {
info!("AMD CPU Turbo: {:?}", boost);
}
FanLevel::Boost => {
let boost = if config.mode_performance.boost.no_turbo {
let boost = if config.power_profiles.boost.no_turbo {
"0"
} else {
"1"
@@ -209,7 +209,7 @@ impl CtrlFanAndCPU {
info!("AMD CPU Turbo: {:?}", boost);
}
FanLevel::Silent => {
let boost = if config.mode_performance.silent.no_turbo {
let boost = if config.power_profiles.silent.no_turbo {
"0"
} else {
"1"

View File

@@ -71,9 +71,9 @@ impl crate::Controller for CtrlKbdBacklight {
async fn reload_from_config(&mut self, config: &mut Config) -> Result<(), Box<dyn Error>> {
// set current mode (if any)
if self.supported_modes.len() > 1 {
if self.supported_modes.contains(&config.current_mode) {
if self.supported_modes.contains(&config.kbd_backlight_mode) {
let mode = config
.get_led_mode_data(config.current_mode)
.get_led_mode_data(config.kbd_backlight_mode)
.ok_or(RogError::NotSupported)?
.to_owned();
self.write_mode(&mode).await?;
@@ -81,19 +81,19 @@ impl crate::Controller for CtrlKbdBacklight {
} else {
warn!(
"An unsupported mode was set: {}, reset to first mode available",
<&str>::from(&<AuraModes>::from(config.current_mode))
<&str>::from(&<AuraModes>::from(config.kbd_backlight_mode))
);
for (idx, mode) in config.builtin_modes.iter_mut().enumerate() {
for (idx, mode) in config.kbd_backlight_modes.iter_mut().enumerate() {
if !self.supported_modes.contains(&mode.into()) {
config.builtin_modes.remove(idx);
config.kbd_backlight_modes.remove(idx);
config.write();
break;
}
}
config.current_mode = self.supported_modes[0];
config.kbd_backlight_mode = self.supported_modes[0];
// TODO: do a recursive call with a boxed dyn future later
let mode = config
.get_led_mode_data(config.current_mode)
.get_led_mode_data(config.kbd_backlight_mode)
.ok_or(RogError::NotSupported)?
.to_owned();
self.write_mode(&mode).await?;
@@ -102,7 +102,7 @@ impl crate::Controller for CtrlKbdBacklight {
}
// Reload brightness
let bright = config.brightness;
let bright = config.kbd_boot_brightness;
let bytes = aura_brightness_bytes(bright);
self.write_bytes(&bytes).await?;
info!("Reloaded last used brightness");
@@ -186,7 +186,7 @@ impl CtrlKbdBacklight {
AuraModes::LedBrightness(n) => {
let bytes: [u8; LED_MSG_LEN] = (&mode).into();
self.write_bytes(&bytes).await?;
config.brightness = n;
config.kbd_boot_brightness = n;
config.write();
info!("LED brightness set to {:#?}", n);
}
@@ -201,7 +201,7 @@ impl CtrlKbdBacklight {
_ => {
let mode_num: u8 = u8::from(&mode);
self.write_mode(&mode).await?;
config.current_mode = mode_num;
config.kbd_backlight_mode = mode_num;
config.set_mode_data(mode);
config.write();
}

View File

@@ -168,15 +168,15 @@ fn start_signal_task(
) {
tokio::spawn(async move {
// Some small things we need to track, without passing all sorts of stuff around
let mut last_fan_mode = config.lock().await.fan_mode;
let mut last_fan_mode = config.lock().await.power_profile;
let mut last_charge_limit = config.lock().await.bat_charge_limit;
loop {
// Use tokio sleep to not hold up other threads
tokio::time::delay_for(std::time::Duration::from_millis(500)).await;
let config = config.lock().await;
if config.fan_mode != last_fan_mode {
last_fan_mode = config.fan_mode;
if config.power_profile != last_fan_mode {
last_fan_mode = config.power_profile;
connection
.send(
fanmode_signal
@@ -210,7 +210,7 @@ async fn send_boot_signals(
let config = config.lock().await;
if let Some(data) = config.get_led_mode_data(config.current_mode) {
if let Some(data) = config.get_led_mode_data(config.kbd_backlight_mode) {
connection
.send(
led_changed_signal
@@ -224,7 +224,7 @@ async fn send_boot_signals(
.send(
fanmode_signal
.msg(&DBUS_PATH.into(), &DBUS_IFACE.into())
.append1(config.fan_mode),
.append1(config.power_profile),
)
.unwrap_or_else(|_| 0);

View File

@@ -39,8 +39,8 @@ fn get_keyboard_backlight(config: Arc<Mutex<Config>>) -> Method<MTSync, ()> {
.method("GetKeyBacklight", (), {
move |m| {
if let Ok(lock) = config.try_lock() {
for mode in &lock.builtin_modes {
if lock.current_mode == <u8>::from(mode) {
for mode in &lock.kbd_backlight_modes {
if lock.kbd_backlight_mode == <u8>::from(mode) {
let mode = serde_json::to_string(&mode).unwrap();
let mret = m.msg.method_return().append1(mode);
return Ok(vec![mret]);
@@ -63,7 +63,7 @@ fn get_keyboard_backlight_modes(config: Arc<Mutex<Config>>) -> Method<MTSync, ()
.method("GetKeyBacklightModes", (), {
move |m| {
if let Ok(lock) = config.try_lock() {
let mode = serde_json::to_string(&lock.builtin_modes).unwrap();
let mode = serde_json::to_string(&lock.kbd_backlight_modes).unwrap();
let mret = m.msg.method_return().append1(mode);
Ok(vec![mret])
} else {
@@ -124,7 +124,7 @@ fn get_fan_mode(config: Arc<Mutex<Config>>) -> Method<MTSync, ()> {
.method("GetFanMode", (), {
move |m| {
if let Ok(lock) = config.try_lock() {
let mret = m.msg.method_return().append1(lock.fan_mode);
let mret = m.msg.method_return().append1(lock.power_profile);
Ok(vec![mret])
} else {
Err(MethodErr::failed("Could not lock config for access"))

View File

@@ -1,7 +1,7 @@
use log::{info, warn};
use asus_nb::aura_modes::{
AuraModes, BREATHING, COMET, FLASH, HIGHLIGHT, LASER, MULTISTATIC, PULSE, RAIN, RAINBOW, RGB,
RIPPLE, SINGLE, STAR, STROBE,
RIPPLE, STATIC, STAR, STROBE,
};
static HELP_ADDRESS: &str = "https://gitlab.com/asus-linux/asus-nb-ctrl";
@@ -17,7 +17,7 @@ pub fn match_laptop() -> LaptopBase {
info!("Found GL753 or similar");
return LaptopBase {
usb_product: "1854".to_string(),
supported_modes: vec![SINGLE, BREATHING, STROBE],
supported_modes: vec![STATIC, BREATHING, STROBE],
};
}
_ => {}
@@ -54,12 +54,12 @@ fn select_1866_device(prod: String) -> LaptopBase {
|| board_name.starts_with("G532")
{
laptop.supported_modes = vec![
SINGLE, BREATHING, STROBE, RAINBOW, STAR, RAIN, HIGHLIGHT, LASER, RIPPLE, PULSE, COMET,
STATIC, BREATHING, STROBE, RAINBOW, STAR, RAIN, HIGHLIGHT, LASER, RIPPLE, PULSE, COMET,
FLASH, RGB,
];
} else if board_name.starts_with("G531") || board_name.starts_with("G731") {
laptop.supported_modes = vec![
SINGLE,
STATIC,
BREATHING,
STROBE,
RAINBOW,
@@ -76,14 +76,14 @@ fn select_1866_device(prod: String) -> LaptopBase {
];
// RGB, limited effects, no zones
} else if board_name.starts_with("G512LI") || board_name.starts_with("G712LI") {
laptop.supported_modes = vec![SINGLE, BREATHING, STROBE, RAINBOW, PULSE];
laptop.supported_modes = vec![STATIC, BREATHING, STROBE, RAINBOW, PULSE];
// RGB, limited effects, 4-zone RGB
} else if board_name.starts_with("GM501")
|| board_name.starts_with("GX531")
|| board_name.starts_with("G512")
|| board_name.starts_with("G712")
{
laptop.supported_modes = vec![SINGLE, BREATHING, STROBE, RAINBOW, PULSE, MULTISTATIC];
laptop.supported_modes = vec![STATIC, BREATHING, STROBE, RAINBOW, PULSE, MULTISTATIC];
} else {
warn!(
"Unsupported laptop, please request support at {}",

View File

@@ -3,7 +3,7 @@ use gumdrop::Options;
use log::LevelFilter;
use asus_nb::{
cli_options::{LedBrightness, SetAuraBuiltin},
core_dbus::AuraDbusWriter,
core_dbus::AuraDbusClient,
};
use std::io::Write;
@@ -14,11 +14,11 @@ struct CLIStart {
#[options(help = "show program version number")]
version: bool,
#[options(meta = "VAL", help = "<off, low, med, high>")]
bright: Option<LedBrightness>,
#[options(meta = "FAN", help = "<silent, normal, boost>")]
fan_mode: Option<FanLevel>,
kbd_bright: Option<LedBrightness>,
#[options(meta = "PWR", help = "<silent, normal, boost>")]
pwr_profile: Option<FanLevel>,
#[options(meta = "CHRG", help = "<20-100>")]
charge_limit: Option<u8>,
chg_limit: Option<u8>,
#[options(command)]
command: Option<Command>,
}
@@ -52,21 +52,21 @@ pub async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Version: {}", daemon::VERSION);
}
let writer = AuraDbusWriter::new()?;
let writer = AuraDbusClient::new()?;
if let Some(Command::LedMode(mode)) = parsed.command {
if let Some(command) = mode.command {
writer.write_builtin_mode(&command.into())?
}
}
if let Some(brightness) = parsed.bright {
if let Some(brightness) = parsed.kbd_bright {
writer.write_brightness(brightness.level())?;
}
if let Some(fan_level) = parsed.fan_mode {
if let Some(fan_level) = parsed.pwr_profile {
writer.write_fan_mode(fan_level.into())?;
}
if let Some(charge_limit) = parsed.charge_limit {
writer.write_charge_limit(charge_limit)?;
if let Some(chg_limit) = parsed.chg_limit {
writer.write_charge_limit(chg_limit)?;
}
Ok(())
}

View File

@@ -1,5 +1,5 @@
use asus_nb::{
core_dbus::AuraDbusWriter,
core_dbus::AuraDbusClient,
fancy::{GX502Layout, Key, KeyColourArray, KeyLayout},
};
use std::collections::LinkedList;
@@ -54,7 +54,7 @@ impl Ball {
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut writer = AuraDbusWriter::new()?;
let mut writer = AuraDbusClient::new()?;
let mut colours = KeyColourArray::new();

View File

@@ -1,10 +1,10 @@
use asus_nb::{
core_dbus::AuraDbusWriter,
core_dbus::AuraDbusClient,
fancy::{GX502Layout, KeyColourArray, KeyLayout},
};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut writer = AuraDbusWriter::new()?;
let mut writer = AuraDbusClient::new()?;
let layout = GX502Layout::default();

View File

@@ -1,10 +1,10 @@
use asus_nb::{
core_dbus::AuraDbusWriter,
core_dbus::AuraDbusClient,
fancy::{GX502Layout, Key, KeyColourArray, KeyLayout},
};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut writer = AuraDbusWriter::new()?;
let mut writer = AuraDbusClient::new()?;
let mut key_colours = KeyColourArray::new();
let layout = GX502Layout::default();

View File

@@ -1,10 +1,10 @@
use asus_nb::{
core_dbus::AuraDbusWriter,
core_dbus::AuraDbusClient,
fancy::{Key, KeyColourArray},
};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut writer = AuraDbusWriter::new()?;
let mut writer = AuraDbusClient::new()?;
let mut key_colours = KeyColourArray::new();

View File

@@ -1,10 +1,10 @@
use asus_nb::{
core_dbus::AuraDbusWriter,
core_dbus::AuraDbusClient,
fancy::{GX502Layout, KeyColourArray, KeyLayout},
};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut writer = AuraDbusWriter::new()?;
let mut writer = AuraDbusClient::new()?;
let mut key_colours = KeyColourArray::new();
let layout = GX502Layout::default();

View File

@@ -2,7 +2,7 @@ use crate::cli_options;
use crate::cli_options::SetAuraBuiltin;
use serde_derive::{Deserialize, Serialize};
pub const SINGLE: u8 = 0x00;
pub const STATIC: u8 = 0x00;
pub const BREATHING: u8 = 0x01;
pub const STROBE: u8 = 0x02;
pub const RAINBOW: u8 = 0x03;
@@ -26,7 +26,7 @@ impl From<cli_options::Colour> for Colour {
}
impl Default for Colour {
fn default() -> Self {
Colour(255, 255, 255)
Colour(128, 0, 0)
}
}
@@ -165,7 +165,7 @@ impl From<cli_options::SingleColourSpeed> for SingleColourSpeed {
#[derive(Clone, Deserialize, Serialize)]
pub enum AuraModes {
Stable(SingleColour),
Static(SingleColour),
Breathe(TwoColourSpeed),
Strobe(SingleSpeed),
Rainbow(SingleSpeedDirection),
@@ -186,7 +186,7 @@ pub enum AuraModes {
impl From<SetAuraBuiltin> for AuraModes {
fn from(mode: SetAuraBuiltin) -> Self {
match mode {
SetAuraBuiltin::Stable(x) => AuraModes::Stable(x.into()),
SetAuraBuiltin::Static(x) => AuraModes::Static(x.into()),
SetAuraBuiltin::Breathe(x) => AuraModes::Breathe(x.into()),
SetAuraBuiltin::Strobe(x) => AuraModes::Strobe(x.into()),
SetAuraBuiltin::Rainbow(x) => AuraModes::Rainbow(x.into()),
@@ -221,7 +221,7 @@ impl From<&mut AuraModes> for u8 {
impl From<&AuraModes> for u8 {
fn from(mode: &AuraModes) -> Self {
match mode {
AuraModes::Stable(_) => SINGLE,
AuraModes::Static(_) => STATIC,
AuraModes::Breathe(_) => BREATHING,
AuraModes::Strobe(_) => STROBE,
AuraModes::Rainbow(_) => RAINBOW,
@@ -243,7 +243,7 @@ impl From<&AuraModes> for u8 {
impl From<&AuraModes> for &str {
fn from(mode: &AuraModes) -> Self {
match mode {
AuraModes::Stable(_) => "Static",
AuraModes::Static(_) => "Static",
AuraModes::Breathe(_) => "Breathing",
AuraModes::Strobe(_) => "Strobing",
AuraModes::Rainbow(_) => "Rainbow",
@@ -267,7 +267,7 @@ impl From<&AuraModes> for &str {
impl From<u8> for AuraModes {
fn from(byte: u8) -> Self {
match byte {
SINGLE => AuraModes::Stable(SingleColour::default()),
STATIC => AuraModes::Static(SingleColour::default()),
BREATHING => AuraModes::Breathe(TwoColourSpeed::default()),
STROBE => AuraModes::Strobe(SingleSpeed::default()),
RAINBOW => AuraModes::Rainbow(SingleSpeedDirection::default()),

View File

@@ -178,7 +178,7 @@ pub struct SingleColourSpeed {
#[derive(Options, Deserialize, Serialize)]
pub enum SetAuraBuiltin {
#[options(help = "set a single static colour")]
Stable(SingleColour),
Static(SingleColour),
#[options(help = "pulse between one or two colours")]
Breathe(TwoColourSpeed),
#[options(help = "strobe through all colours")]
@@ -207,7 +207,7 @@ pub enum SetAuraBuiltin {
impl Default for SetAuraBuiltin {
fn default() -> Self {
SetAuraBuiltin::Stable(SingleColour {
SetAuraBuiltin::Static(SingleColour {
help: false,
colour: Colour(255, 0, 0),
})

View File

@@ -10,14 +10,14 @@ use std::sync::{
use std::{thread, time::Duration};
/// Simplified way to write a effect block
pub struct AuraDbusWriter {
pub struct AuraDbusClient {
connection: Box<Connection>,
block_time: u64,
stop: Arc<AtomicBool>,
stop_token: Token,
}
impl AuraDbusWriter {
impl AuraDbusClient {
#[inline]
pub fn new() -> Result<Self, Box<dyn Error>> {
let connection = Connection::new_system()?;
@@ -32,7 +32,7 @@ impl AuraDbusWriter {
true
})?;
Ok(AuraDbusWriter {
Ok(AuraDbusClient {
connection: Box::new(connection),
block_time: 33333,
stop,

View File

@@ -1,6 +1,6 @@
pub static DBUS_NAME: &str = "org.asus-linux.Daemon";
pub static DBUS_PATH: &str = "/org/asus-linux/Daemon";
pub static DBUS_IFACE: &str = "org.asus-linux.Daemon";
pub static DBUS_NAME: &str = "org.asuslinux.Daemon";
pub static DBUS_PATH: &str = "/org/asus/linux/Daemon";
pub static DBUS_IFACE: &str = "org.asuslinux.Daemon";
pub const LED_MSG_LEN: usize = 17;
pub mod aura_modes;
@@ -145,7 +145,7 @@ impl From<&AuraModes> for [u8; LED_MSG_LEN] {
msg[1] = 0xb3;
match mode {
AuraModes::LedBrightness(n) => return aura_brightness_bytes(*n),
AuraModes::Stable(_) => msg[3] = 0x00,
AuraModes::Static(_) => msg[3] = 0x00,
AuraModes::Breathe(_) => msg[3] = 0x01,
AuraModes::Strobe(_) => msg[3] = 0x02,
AuraModes::Rainbow(_) => msg[3] = 0x03,
@@ -192,7 +192,7 @@ impl From<&AuraModes> for [u8; LED_MSG_LEN] {
msg[6] = settings.colour.2;
msg[7] = settings.speed as u8;
}
AuraModes::Stable(settings)
AuraModes::Static(settings)
| AuraModes::Pulse(settings)
| AuraModes::Comet(settings)
| AuraModes::Flash(settings) => {

View File

@@ -3,20 +3,20 @@
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy group="adm">
<allow send_destination="org.asus-linux.Daemon"/>
<allow receive_sender="org.asus-linux.Daemon"/>
<allow send_destination="org.asuslinux.Daemon"/>
<allow receive_sender="org.asuslinux.Daemon"/>
</policy>
<policy group="sudo">
<allow send_destination="org.asus-linux.Daemon"/>
<allow receive_sender="org.asus-linux.Daemon"/>
<allow send_destination="org.asuslinux.Daemon"/>
<allow receive_sender="org.asuslinux.Daemon"/>
</policy>
<policy group="wheel">
<allow send_destination="org.asus-linux.Daemon"/>
<allow receive_sender="org.asus-linux.Daemon"/>
<allow send_destination="org.asuslinux.Daemon"/>
<allow receive_sender="org.asuslinux.Daemon"/>
</policy>
<policy user="root">
<allow own="org.asus-linux.Daemon"/>
<allow send_destination="org.asus-linux.Daemon"/>
<allow receive_sender="org.asus-linux.Daemon"/>
<allow own="org.asuslinux.Daemon"/>
<allow send_destination="org.asuslinux.Daemon"/>
<allow receive_sender="org.asuslinux.Daemon"/>
</policy>
</busconfig>