mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 17:33:19 +01:00
Add checks to rename configs if required
This commit is contained in:
128
MANUAL.md
128
MANUAL.md
@@ -117,60 +117,67 @@ I'm unsure of how many laptops this works on, so please try it.
|
|||||||
|
|
||||||
An Aura config itself is a file with contents:
|
An Aura config itself is a file with contents:
|
||||||
|
|
||||||
```json
|
```ron
|
||||||
{
|
(
|
||||||
"name": "aura-default",
|
name: "aura-default",
|
||||||
"aura": [
|
aura: (
|
||||||
{
|
effects: [
|
||||||
"Breathe": {
|
Breathe((
|
||||||
"led_type": {
|
led: W,
|
||||||
"Key": "W"
|
start_colour1: (255, 0, 20),
|
||||||
},
|
start_colour2: (20, 255, 0),
|
||||||
"start_colour1": [
|
speed: Low,
|
||||||
255,
|
)),
|
||||||
0,
|
Breathe((
|
||||||
20
|
led: A,
|
||||||
|
start_colour1: (255, 0, 20),
|
||||||
|
start_colour2: (20, 255, 0),
|
||||||
|
speed: Low,
|
||||||
|
)),
|
||||||
|
Breathe((
|
||||||
|
led: S,
|
||||||
|
start_colour1: (255, 0, 20),
|
||||||
|
start_colour2: (20, 255, 0),
|
||||||
|
speed: Low,
|
||||||
|
)),
|
||||||
|
Breathe((
|
||||||
|
led: D,
|
||||||
|
start_colour1: (255, 0, 20),
|
||||||
|
start_colour2: (20, 255, 0),
|
||||||
|
speed: Low,
|
||||||
|
)),
|
||||||
|
Breathe((
|
||||||
|
led: F,
|
||||||
|
start_colour1: (255, 0, 0),
|
||||||
|
start_colour2: (255, 0, 0),
|
||||||
|
speed: High,
|
||||||
|
)),
|
||||||
|
Static((
|
||||||
|
led: RCtrl,
|
||||||
|
colour: (0, 0, 255),
|
||||||
|
)),
|
||||||
|
Static((
|
||||||
|
led: LCtrl,
|
||||||
|
colour: (0, 0, 255),
|
||||||
|
)),
|
||||||
|
Static((
|
||||||
|
led: Esc,
|
||||||
|
colour: (0, 0, 255),
|
||||||
|
)),
|
||||||
|
DoomFlicker((
|
||||||
|
led: N9,
|
||||||
|
start_colour: (0, 0, 255),
|
||||||
|
max_percentage: 80,
|
||||||
|
min_percentage: 40,
|
||||||
|
)),
|
||||||
],
|
],
|
||||||
"start_colour2": [
|
zoned: false,
|
||||||
20,
|
),
|
||||||
255,
|
)
|
||||||
0
|
|
||||||
],
|
|
||||||
"speed": "Low"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Static": {
|
|
||||||
"led_type": {
|
|
||||||
"Key": "Esc"
|
|
||||||
},
|
|
||||||
"colour": [
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
255
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Flicker": {
|
|
||||||
"led_type": {
|
|
||||||
"Key": "N9"
|
|
||||||
},
|
|
||||||
"start_colour": [
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
255
|
|
||||||
],
|
|
||||||
"max_percentage": 80,
|
|
||||||
"min_percentage": 40
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
If your laptop supports multizone, `"led_type"` can also be `"Zone": <one of the following>`
|
If your laptop supports multizone, `"led"` can also be `"Zone": <one of the following>`
|
||||||
- `"None"`
|
- `SingleZone` // Keyboards with only one zone
|
||||||
- `ZonedKbLeft` // keyboard left
|
- `ZonedKbLeft` // keyboard left
|
||||||
- `ZonedKbLeftMid` // keyboard left-middle
|
- `ZonedKbLeftMid` // keyboard left-middle
|
||||||
- `ZonedKbRightMid` // etc
|
- `ZonedKbRightMid` // etc
|
||||||
@@ -182,6 +189,25 @@ If your laptop supports multizone, `"led_type"` can also be `"Zone": <one of the
|
|||||||
- `LightbarLeftCorner`
|
- `LightbarLeftCorner`
|
||||||
- `LightbarLeft`
|
- `LightbarLeft`
|
||||||
|
|
||||||
|
Single zone example:
|
||||||
|
|
||||||
|
```ron
|
||||||
|
(
|
||||||
|
name: "aura-default",
|
||||||
|
aura: (
|
||||||
|
effects: [
|
||||||
|
DoomFlicker((
|
||||||
|
led: SingleZone,
|
||||||
|
start_colour: (200, 40, 5),
|
||||||
|
max_percentage: 80,
|
||||||
|
min_percentage: 40,
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
zoned: true,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
At the moment there are only three effects available as shown in the example. More will come in the future
|
At the moment there are only three effects available as shown in the example. More will come in the future
|
||||||
but this may take me some time.
|
but this may take me some time.
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,46 @@ where
|
|||||||
.unwrap_or_else(|e| panic!("Could not create {:?} {e}", Self::config_dir()));
|
.unwrap_or_else(|e| panic!("Could not create {:?} {e}", Self::config_dir()));
|
||||||
}
|
}
|
||||||
config.push(self.file_name());
|
config.push(self.file_name());
|
||||||
|
let mut do_rename = !config.exists();
|
||||||
|
let mut cfg_old = config.clone();
|
||||||
|
// Migrating all configs to .ron format, so we do need to check for older ones
|
||||||
|
if do_rename {
|
||||||
|
warn!("Config {cfg_old:?} does not exist, looking for .cfg next");
|
||||||
|
cfg_old.pop();
|
||||||
|
let tmp = self.file_name();
|
||||||
|
let parts: Vec<_> = tmp.split('.').collect();
|
||||||
|
cfg_old.push(format!("{}.cfg", parts[0]));
|
||||||
|
}
|
||||||
|
if do_rename && cfg_old.exists() {
|
||||||
|
// Now we gotta rename it
|
||||||
|
warn!("Renaming {cfg_old:?} to {config:?}");
|
||||||
|
std::fs::rename(&cfg_old, &config).unwrap_or_else(|err| {
|
||||||
|
error!(
|
||||||
|
"Could not rename. Please remove {} then restart service: Error {}",
|
||||||
|
self.file_name(),
|
||||||
|
err
|
||||||
|
)
|
||||||
|
});
|
||||||
|
do_rename = false;
|
||||||
|
}
|
||||||
|
if do_rename && !cfg_old.exists() {
|
||||||
|
warn!("Config {cfg_old:?} does not exist, looking for .conf next");
|
||||||
|
cfg_old.pop();
|
||||||
|
let tmp = self.file_name();
|
||||||
|
let parts: Vec<_> = tmp.split('.').collect();
|
||||||
|
cfg_old.push(format!("{}.conf", parts[0]));
|
||||||
|
}
|
||||||
|
if do_rename && cfg_old.exists() {
|
||||||
|
// Now we gotta rename it
|
||||||
|
warn!("Renaming {cfg_old:?} to {config:?}");
|
||||||
|
std::fs::rename(&cfg_old, &config).unwrap_or_else(|err| {
|
||||||
|
error!(
|
||||||
|
"Could not rename. Please remove {} then restart service: Error {}",
|
||||||
|
self.file_name(),
|
||||||
|
err
|
||||||
|
)
|
||||||
|
});
|
||||||
|
}
|
||||||
config
|
config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ impl StdConfig for ConfigAnime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn file_name(&self) -> String {
|
fn file_name(&self) -> String {
|
||||||
format!("{}.cfg", self.name)
|
format!("{}.ron", self.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn config_dir() -> std::path::PathBuf {
|
fn config_dir() -> std::path::PathBuf {
|
||||||
@@ -180,7 +180,7 @@ impl StdConfig for ConfigAura {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn file_name(&self) -> String {
|
fn file_name(&self) -> String {
|
||||||
format!("{}.cfg", self.name)
|
format!("{}.ron", self.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn config_dir() -> std::path::PathBuf {
|
fn config_dir() -> std::path::PathBuf {
|
||||||
@@ -208,7 +208,7 @@ impl StdConfig for ConfigBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn file_name(&self) -> String {
|
fn file_name(&self) -> String {
|
||||||
"rog-user.cfg".to_owned()
|
"rog-user.ron".to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn config_dir() -> std::path::PathBuf {
|
fn config_dir() -> std::path::PathBuf {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use config_traits::{StdConfig, StdConfigLoad3};
|
use config_traits::{StdConfig, StdConfigLoad3};
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
|
|
||||||
const CONFIG_FILE: &str = "asusd.conf";
|
const CONFIG_FILE: &str = "asusd.ron";
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Default)]
|
#[derive(Deserialize, Serialize, Default)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use rog_anime::error::AnimeError;
|
|||||||
use rog_anime::{ActionData, ActionLoader, AnimTime, AnimeType, Fade, Vec2};
|
use rog_anime::{ActionData, ActionLoader, AnimTime, AnimeType, Fade, Vec2};
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
|
|
||||||
const CONFIG_FILE: &str = "anime.conf";
|
const CONFIG_FILE: &str = "anime.ron";
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
pub struct AnimeConfigV341 {
|
pub struct AnimeConfigV341 {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use rog_platform::hid_raw::HidRaw;
|
|||||||
use rog_platform::keyboard_led::KeyboardLed;
|
use rog_platform::keyboard_led::KeyboardLed;
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
|
|
||||||
const CONFIG_FILE: &str = "aura.conf";
|
const CONFIG_FILE: &str = "aura.ron";
|
||||||
|
|
||||||
/// Enable/disable LED control in various states such as
|
/// Enable/disable LED control in various states such as
|
||||||
/// when the device is awake, suspended, shutting down or
|
/// when the device is awake, suspended, shutting down or
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ use serde_derive::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::CONFIG_PATH_BASE;
|
use crate::CONFIG_PATH_BASE;
|
||||||
|
|
||||||
const CONFIG_FILE: &str = "profile.conf";
|
const CONFIG_FILE: &str = "profile.ron";
|
||||||
const CONFIG_FAN_FILE: &str = "fan_curves.conf";
|
const CONFIG_FAN_FILE: &str = "fan_curves.ron";
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Debug)]
|
#[derive(Deserialize, Serialize, Debug)]
|
||||||
pub struct ProfileConfig {
|
pub struct ProfileConfig {
|
||||||
|
|||||||
Reference in New Issue
Block a user