Fix up colour sliders

- Fixup colour sliders for UI
- Correctly drop tokio runtime
This commit is contained in:
Luke D. Jones
2024-05-08 22:28:22 +12:00
parent 1b023d0f5f
commit a18692ef1e
9 changed files with 134 additions and 143 deletions

View File

@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [v6.0.3]
### NOTE
- Xorg is not supported any longer. All major desktops and distros are Wayland.
### Changed
- Add a check to prevent non-TUF laptops with screwed up method return from TUF acpi methods from trying to add a TUF aura device without actually being a TUF laptop.
- Make the G834JZ entry in aura db generic for all G834J
## [v6.0.2]
### Changed

30
Cargo.lock generated
View File

@@ -117,7 +117,7 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
[[package]]
name = "asusctl"
version = "6.0.2"
version = "6.0.3"
dependencies = [
"asusd",
"cargo-husky",
@@ -135,14 +135,14 @@ dependencies = [
[[package]]
name = "asusd"
version = "6.0.2"
version = "6.0.3"
dependencies = [
"cargo-husky",
"concat-idents",
"config-traits",
"dmi_id",
"env_logger",
"futures-lite 2.3.0",
"futures-lite 1.13.0",
"inotify",
"log",
"logind-zbus",
@@ -161,7 +161,7 @@ dependencies = [
[[package]]
name = "asusd-user"
version = "6.0.2"
version = "6.0.3"
dependencies = [
"cargo-husky",
"config-traits",
@@ -828,7 +828,7 @@ dependencies = [
[[package]]
name = "config-traits"
version = "6.0.2"
version = "6.0.3"
dependencies = [
"cargo-husky",
"log",
@@ -934,7 +934,7 @@ checksum = "7704b5fdd17b18ae31c4c1da5a2e0305a2bf17b5249300a9ee9ed7b72114c636"
[[package]]
name = "cpuctl"
version = "6.0.2"
version = "6.0.3"
[[package]]
name = "cpufeatures"
@@ -1134,7 +1134,7 @@ dependencies = [
[[package]]
name = "dmi_id"
version = "6.0.2"
version = "6.0.3"
dependencies = [
"log",
"udev 0.8.0",
@@ -3309,7 +3309,7 @@ dependencies = [
[[package]]
name = "rog-control-center"
version = "6.0.2"
version = "6.0.3"
dependencies = [
"asusd",
"betrayer",
@@ -3341,7 +3341,7 @@ dependencies = [
[[package]]
name = "rog_anime"
version = "6.0.2"
version = "6.0.3"
dependencies = [
"cargo-husky",
"dmi_id",
@@ -3358,7 +3358,7 @@ dependencies = [
[[package]]
name = "rog_aura"
version = "6.0.2"
version = "6.0.3"
dependencies = [
"cargo-husky",
"dmi_id",
@@ -3372,7 +3372,7 @@ dependencies = [
[[package]]
name = "rog_dbus"
version = "6.0.2"
version = "6.0.3"
dependencies = [
"asusd",
"cargo-husky",
@@ -3386,7 +3386,7 @@ dependencies = [
[[package]]
name = "rog_platform"
version = "6.0.2"
version = "6.0.3"
dependencies = [
"cargo-husky",
"concat-idents",
@@ -3401,7 +3401,7 @@ dependencies = [
[[package]]
name = "rog_profiles"
version = "6.0.2"
version = "6.0.3"
dependencies = [
"cargo-husky",
"log",
@@ -3415,7 +3415,7 @@ dependencies = [
[[package]]
name = "rog_simulators"
version = "6.0.2"
version = "6.0.3"
dependencies = [
"log",
"rog_anime",
@@ -3425,7 +3425,7 @@ dependencies = [
[[package]]
name = "rog_slash"
version = "6.0.2"
version = "6.0.3"
dependencies = [
"cargo-husky",
"dmi_id",

View File

@@ -25,7 +25,7 @@ default-members = [
resolver = "2"
[workspace.package]
version = "6.0.2"
version = "6.0.3"
rust-version = "1.77"
license = "MPL-2.0"
readme = "README.md"

View File

@@ -1,6 +1,7 @@
use std::collections::{BTreeMap, HashSet};
use config_traits::{StdConfig, StdConfigLoad};
use dmi_id::DMIID;
use inotify::Inotify;
use log::{debug, info, warn};
use rog_aura::aura_detection::LedSupportData;
@@ -123,16 +124,24 @@ impl CtrlKbdLed {
// Check for a TUF laptop LED. Assume there is only ever one.
if let Ok(kbd_backlight) = KeyboardLed::new() {
if kbd_backlight.has_kbd_rgb_mode() {
info!("AuraControl found a TUF laptop keyboard");
let ctrl = CtrlKbdLed {
led_type: AuraDeviceType::LaptopTuf,
led_node: LEDNode::KbdLed(kbd_backlight),
supported_data: LedSupportData::get_data("tuf"),
per_key_mode_active: false,
config: Self::init_config("tuf"),
dbus_path: dbus_path_for_tuf(),
};
devices.push(ctrl);
// Extra sure double-check that this isn't a laptop with crap
// ACPI with borked return on the TUF rgb methods
let dmi = DMIID::new().unwrap_or_default();
info!("Found a TUF with product family: {}", dmi.product_family);
info!("and board name: {}", dmi.board_name);
if dmi.product_family.contains("TUF") {
info!("AuraControl found a TUF laptop keyboard");
let ctrl = CtrlKbdLed {
led_type: AuraDeviceType::LaptopTuf,
led_node: LEDNode::KbdLed(kbd_backlight),
supported_data: LedSupportData::get_data("tuf"),
per_key_mode_active: false,
config: Self::init_config("tuf"),
dbus_path: dbus_path_for_tuf(),
};
devices.push(ctrl);
}
}
}

View File

@@ -27,7 +27,7 @@
power_zones: [Keyboard],
),
(
device_name: "FX505D",
device_name: "FX505",
product_id: "",
layout_name: "fx505d",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
@@ -36,25 +36,7 @@
power_zones: [Keyboard],
),
(
device_name: "FX505G",
product_id: "",
layout_name: "fx505d",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [],
advanced_type: None,
power_zones: [Keyboard],
),
(
device_name: "FX506H",
product_id: "",
layout_name: "fa506i",
basic_modes: [Static, Breathe, Strobe, Pulse],
basic_zones: [],
advanced_type: None,
power_zones: [Keyboard],
),
(
device_name: "FX506L",
device_name: "FX506",
product_id: "",
layout_name: "fa506i",
basic_modes: [Static, Breathe, Strobe, Pulse],
@@ -98,15 +80,6 @@
advanced_type: None,
power_zones: [Keyboard],
),
(
device_name: "G512LV",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [Key1, Key2, Key3, Key4],
advanced_type: None,
power_zones: [Keyboard],
),
(
device_name: "G513I",
product_id: "",
@@ -126,16 +99,7 @@
power_zones: [Keyboard],
),
(
device_name: "G513QM",
product_id: "",
layout_name: "g513i",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
advanced_type: PerKey,
power_zones: [Keyboard],
),
(
device_name: "G513QR",
device_name: "G513Q",
product_id: "",
layout_name: "g513i-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
@@ -153,16 +117,7 @@
power_zones: [Keyboard],
),
(
device_name: "G513RC",
product_id: "",
layout_name: "g513i",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [],
advanced_type: Zoned([ZonedKbLeft, ZonedKbLeftMid, ZonedKbRightMid, ZonedKbRight, LightbarRight, LightbarRightCorner, LightbarRightBottom, LightbarLeftBottom, LightbarLeftCorner, LightbarLeft]),
power_zones: [Keyboard, Lightbar],
),
(
device_name: "G513RM",
device_name: "G513R",
product_id: "",
layout_name: "g513i",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
@@ -188,15 +143,6 @@
advanced_type: PerKey,
power_zones: [Keyboard],
),
(
device_name: "G531",
product_id: "",
layout_name: "g513i-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [Key1, Key2, Key3, Key4],
advanced_type: PerKey,
power_zones: [Keyboard],
),
(
device_name: "G531GD",
product_id: "",
@@ -468,7 +414,7 @@
power_zones: [Keyboard],
),
(
device_name: "G814JI",
device_name: "G814J",
product_id: "",
layout_name: "g814ji-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
@@ -477,16 +423,7 @@
power_zones: [Keyboard, Lightbar],
),
(
device_name: "G814JZ",
product_id: "",
layout_name: "g814ji-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
advanced_type: PerKey,
power_zones: [Keyboard, Lightbar],
),
(
device_name: "G834JZ",
device_name: "G834J",
product_id: "",
layout_name: "g814ji-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
@@ -540,7 +477,7 @@
power_zones: [Keyboard],
),
(
device_name: "GA403UI",
device_name: "GA403U",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse],
@@ -647,15 +584,6 @@
advanced_type: PerKey,
power_zones: [Keyboard],
),
(
device_name: "GU502G",
product_id: "",
layout_name: "gx502",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
advanced_type: PerKey,
power_zones: [Keyboard],
),
(
device_name: "GU502L",
product_id: "",
@@ -684,7 +612,7 @@
power_zones: [Keyboard],
),
(
device_name: "GU603VV",
device_name: "GU603V",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],

View File

@@ -22,8 +22,6 @@ use rog_control_center::{
get_ipc_file, on_tmp_dir_exists, print_versions, MainWindow, QUIT_APP, SHOWING_GUI, SHOW_GUI,
};
use tokio::runtime::Runtime;
// use winit::monitor::VideoMode;
// use winit::window::{Fullscreen, WindowLevel};
#[tokio::main]
async fn main() -> Result<()> {
@@ -73,11 +71,6 @@ async fn main() -> Result<()> {
.format_timestamp(None)
.init();
// start tokio
let rt = Runtime::new().expect("Unable to create Runtime");
// Enter the runtime so that `tokio::spawn` is available immediately.
let _enter = rt.enter();
let supported_properties = match proxy.supported_properties() {
Ok(s) => s,
Err(_e) => {
@@ -117,7 +110,13 @@ async fn main() -> Result<()> {
let enable_tray_icon = config.enable_tray_icon;
let startup_in_background = config.startup_in_background;
let config = Arc::new(Mutex::new(config));
start_notifications(config.clone())?;
// start tokio
let rt = Runtime::new().expect("Unable to create Runtime");
// Enter the runtime so that `tokio::spawn` is available immediately.
let _enter = rt.enter();
start_notifications(config.clone(), &rt)?;
if enable_tray_icon {
init_tray(supported_properties, config.clone());
}
@@ -208,6 +207,7 @@ async fn main() -> Result<()> {
});
slint::run_event_loop_until_quit().unwrap();
rt.shutdown_background();
Ok(())
}

View File

@@ -18,6 +18,8 @@ use serde::{Deserialize, Serialize};
use supergfxctl::actions::UserActionRequired as GfxUserAction;
use supergfxctl::pci_device::{GfxMode, GfxPower};
use supergfxctl::zbus_proxy::DaemonProxy as SuperProxy;
use tokio::runtime::Runtime;
use tokio::task::JoinHandle;
use tokio::time::sleep;
use zbus::export::futures_util::StreamExt;
@@ -44,10 +46,13 @@ impl Default for EnabledNotifications {
}
}
pub fn start_notifications(config: Arc<Mutex<Config>>) -> Result<()> {
pub fn start_notifications(
config: Arc<Mutex<Config>>,
rt: &Runtime,
) -> Result<Vec<JoinHandle<()>>> {
// Setup the AC/BAT commands that will run on power status change
let config_copy = config.clone();
tokio::task::spawn_blocking(move || {
let blocking = rt.spawn_blocking(move || {
let power = AsusPower::new()
.map_err(|e| {
error!("AsusPower: {e}");
@@ -217,7 +222,7 @@ pub fn start_notifications(config: Arc<Mutex<Config>>) -> Result<()> {
};
});
Ok(())
Ok(vec![blocking])
}
fn convert_gfx_mode(gfx: GfxMode) -> GpuMode {

View File

@@ -2,7 +2,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-05-08 04:26+0000\n"
"POT-Creation-Date: 2024-05-08 10:28+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@@ -6,6 +6,7 @@ export component ColourSlider inherits VerticalLayout {
property <string> hex: "#FF0000";
in-out property <float> c1value <=> c1.value;
in-out property <float> c2value <=> c2.value;
in-out property <float> c3value <=> c3.value;
property <color> base_colour: Colors.red;
in-out property <color> final_colour: Colors.red;
in-out property <brush> colourbox: final_colour;
@@ -53,39 +54,52 @@ export component ColourSlider inherits VerticalLayout {
hsv(350, 1, 1),
hsv(360, 1, 1),
];
property <[color]> base_shade: [
blend_lightness(base_colour, 1.0),
blend_lightness(base_colour, 0.9),
blend_lightness(base_colour, 0.8),
blend_lightness(base_colour, 0.7),
blend_lightness(base_colour, 0.6),
blend_lightness(base_colour, 0.5),
blend_lightness(base_colour, 0.4),
blend_lightness(base_colour, 0.3),
blend_lightness(base_colour, 0.2),
blend_lightness(base_colour, 0.1),
blend_lightness(base_colour, 0.0)
property <[color]> base_saturation: [
hsv(base_colour.to-hsv().hue, 1, 1),
hsv(base_colour.to-hsv().hue, 0.9, 1),
hsv(base_colour.to-hsv().hue, 0.8, 1),
hsv(base_colour.to-hsv().hue, 0.7, 1),
hsv(base_colour.to-hsv().hue, 0.6, 1),
hsv(base_colour.to-hsv().hue, 0.5, 1),
hsv(base_colour.to-hsv().hue, 0.4, 1),
hsv(base_colour.to-hsv().hue, 0.3, 1),
hsv(base_colour.to-hsv().hue, 0.2, 1),
hsv(base_colour.to-hsv().hue, 0.1, 1),
hsv(base_colour.to-hsv().hue, 0, 1),
];
function blend_lightness(c1: color,f: float) -> color {
rgb(c1.red * f, c1.green * f, c1.blue * f)
}
//
property <[color]> base_value: [
hsv(base_colour.to-hsv().hue, 1, 1),
hsv(base_colour.to-hsv().hue, 1, 0.9),
hsv(base_colour.to-hsv().hue, 1, 0.8),
hsv(base_colour.to-hsv().hue, 1, 0.7),
hsv(base_colour.to-hsv().hue, 1, 0.6),
hsv(base_colour.to-hsv().hue, 1, 0.5),
hsv(base_colour.to-hsv().hue, 1, 0.4),
hsv(base_colour.to-hsv().hue, 1, 0.3),
hsv(base_colour.to-hsv().hue, 1, 0.2),
hsv(base_colour.to-hsv().hue, 1, 0.1),
hsv(base_colour.to-hsv().hue, 1, 0),
];
function set_base_colour(){
root.base_colour = base_colours[c1.value].mix(base_colours[c1.value + 1], c1.value - Math.floor(c1.value));
root.final_colour = blend_lightness(base_colour, ((base_shade.length - c2.value) / base_shade.length));
root.base_colour = hsv(c1.value / base_colours.length * 360, 1, 1);
root.final_colour = hsv(base_colour.to-hsv().hue, ((base_saturation.length - c2.value) / base_saturation.length), ((base_value.length - c3.value) / base_value.length));
root.colourbox = root.final_colour;
}
//
callback external_colour_change();
external_colour_change => {
if (root.final_colour.to-hsv().hue < 0) {
c1.value = (root.base_colours.length - 1) * ((root.final_colour.to-hsv().hue + 360) / 360);
c1.value = root.base_colours.length * (root.final_colour.to-hsv().hue + 360) / 360;
} else {
c1.value = (root.base_colours.length - 1) * (root.final_colour.to-hsv().hue / 360);
c1.value = root.base_colours.length * root.final_colour.to-hsv().hue / 360;
}
c2.value = root.base_shade.length - (root.base_shade.length * root.final_colour.to-hsv().value);
// c1.value = root.base_colours.length * 360 / root.final_colour.to-hsv().hue;
c2.value = root.base_saturation.length - root.base_saturation.length * root.final_colour.to-hsv().saturation;
c3.value = root.base_value.length - root.base_value.length * root.final_colour.to-hsv().value;
root.set_base_colour();
hex = set_hex_from_colour(final_colour);
}
Rectangle {
height: 32px;
@@ -100,7 +114,7 @@ export component ColourSlider inherits VerticalLayout {
width: parent.width;
height: parent.height;
minimum: 0;
maximum: root.base_colours.length - 1;
maximum: root.base_colours.length;
// One less than the array length
changed => {
set_base_colour();
@@ -118,14 +132,38 @@ export component ColourSlider inherits VerticalLayout {
border-radius: 7px;
border-color: Palette.border;
// 11 colours
background: !root.enabled ? Palette.alternate-background : @linear-gradient(90deg, base_shade[0], base_shade[1], base_shade[2], base_shade[3], base_shade[4], base_shade[5], base_shade[6], base_shade[7], base_shade[8], base_shade[9], base_shade[10]);
background: !root.enabled ? Palette.alternate-background : @linear-gradient(90deg, base_saturation[0], base_saturation[1], base_saturation[2], base_saturation[3], base_saturation[4], base_saturation[5], base_saturation[6], base_saturation[7], base_saturation[8], base_saturation[9], base_saturation[10]);
clip: true;
c2 := Slider {
enabled <=> root.enabled;
width: parent.width;
height: parent.height;
minimum: 0;
maximum: 11;
maximum: root.base_saturation.length;
changed => {
set_base_colour();
hex = set_hex_from_colour(final_colour);
}
released => {
root.released();
}
}
}
Rectangle {
height: 32px;
border-width: 2px;
border-radius: 7px;
border-color: Palette.border;
// 11 colours
background: !root.enabled ? Palette.alternate-background : @linear-gradient(90deg, base_value[0], base_value[1], base_value[2], base_value[3], base_value[4], base_value[5], base_value[6], base_value[7], base_value[8], base_value[9], base_value[10]);
clip: true;
c3 := Slider {
enabled <=> root.enabled;
width: parent.width;
height: parent.height;
minimum: 0;
maximum: root.base_value.length;
changed => {
set_base_colour();
hex = set_hex_from_colour(final_colour);