Compare commits

..

8 Commits

Author SHA1 Message Date
Luke Jones a08ca3af98 chore: update spec file version to 6.1.8 2025-02-22 12:45:20 +13:00
Luke Jones efa379e778 Add opensuse CI 2025-02-21 17:12:47 +13:00
Luke Jones 5cbf0816fe chore: update translations 2025-02-18 22:12:56 +13:00
Luke Jones 2951d3926c Update git hooks 2025-02-18 22:12:54 +13:00
Luke Jones eb19d59d52 Update distro packaging 2025-02-18 22:12:53 +13:00
guylamar2006 3e4d594b05 Fix thread 'main' panicked at asusctl/src/main.rs:85:14: 2025-02-17 21:13:42 +00:00
Luke Jones ae8ce83583 Fix slash enable 2025-02-17 11:38:29 +13:00
Luke Jones 5c3348a9f5 Add small env fixes for Ally
Signed-off-by: Luke Jones <luke@ljones.dev>
2025-02-16 23:18:58 +13:00
15 changed files with 330 additions and 162 deletions
+53
View File
@@ -0,0 +1,53 @@
#!/bin/sh
set -e
ROOT_DIR=$(git rev-parse --show-toplevel)
AURA_DATA="${ROOT_DIR}/rog-aura/data/aura_support.ron"
SPEC_FILE="${ROOT_DIR}/distro-packaging/fedora/asusctl.spec"
TRANSLATION="${ROOT_DIR}/rog-control-center/translations/en/rog-control-center.po"
VERSION=$(grep -Pm1 'version = "(\d+.\d+.\d+.*)"' "${ROOT_DIR}/Cargo.toml" | cut -d'"' -f2)
if [ -z "$VERSION" ]; then
echo "Error: Could not extract version from Cargo.toml"
exit 1
fi
if [ ! -f "$SPEC_FILE" ]; then
echo "Error: Spec file not found at ${SPEC_FILE}"
exit 1
fi
# Update spec file
sed -i "s/^%define version.*/%define version ${VERSION}/" "$SPEC_FILE"
if git diff --quiet "$SPEC_FILE"; then
echo "No changes to spec file"
else
git add "$SPEC_FILE"
git commit --no-verify -m "chore: update spec file version to ${VERSION}"
echo "Updated spec file version to ${VERSION}"
fi
# Update translations only if UI files changed
if git diff-tree -r HEAD@{1} HEAD --name-only | grep -q "^rog-control-center/ui/"; then
echo 'find -name \*.slint | xargs slint-tr-extractor -o ${TRANSLATION}'
find -name \*.slint | xargs slint-tr-extractor -o $TRANSLATION
if git diff --quiet "$TRANSLATION"; then
echo "No changes to translation file"
else
git add "$TRANSLATION"
git commit --no-verify -m "chore: update translations"
echo "Updated ${TRANSLATION}"
fi
else
echo "No changes in rog-control-center/ui/, skipping translation update"
fi
# Update aura data
cargo test --package rog_aura --lib -- aura_detection::tests::check_data_file_parse --exact
cargo test --package rog_aura --lib -- aura_detection::tests::find_data_file_groups --exact
if git diff --quiet "$AURA_DATA"; then
echo "No changes to aura data file"
else
git add "$AURA_DATA"
git commit --no-verify -m "chore: update aura data"
echo "Updated $AURA_DATA"
fi
+1 -13
View File
@@ -1,18 +1,6 @@
#!/bin/sh
set -e
echo 'find -name \*.slint | xargs slint-tr-extractor -o rog-control-center/translations/en/rog-control-center.po'
find -name \*.slint | xargs slint-tr-extractor -o rog-control-center/translations/en/rog-control-center.po
echo '+cargo +nightly fmt --all -- --check'
cargo +nightly fmt --all -- --check
echo '+cargo clippy --all -- -D warnings'
cargo clippy --all -- -D warnings
echo '+cargo test --all'
cargo test --all -- --test-threads=1
echo '+cargo cranky'
cargo cranky
git add -u
+10
View File
@@ -2,6 +2,16 @@
## [Unreleased]
## [v6.1.8]
### Changed
- Testing CI for opensuse RPM build
## [v6.1.7]
### Changed
- Fix Slash display enable
## [v6.1.6]
### Changed
Generated
+14 -14
View File
@@ -250,7 +250,7 @@ checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b"
[[package]]
name = "asusctl"
version = "6.1.6"
version = "6.1.8"
dependencies = [
"dmi_id",
"env_logger",
@@ -269,7 +269,7 @@ dependencies = [
[[package]]
name = "asusd"
version = "6.1.6"
version = "6.1.8"
dependencies = [
"cargo-husky",
"concat-idents",
@@ -296,7 +296,7 @@ dependencies = [
[[package]]
name = "asusd-user"
version = "6.1.6"
version = "6.1.8"
dependencies = [
"config-traits",
"dirs",
@@ -1084,7 +1084,7 @@ dependencies = [
[[package]]
name = "config-traits"
version = "6.1.6"
version = "6.1.8"
dependencies = [
"log",
"ron",
@@ -1476,7 +1476,7 @@ dependencies = [
[[package]]
name = "dmi_id"
version = "6.1.6"
version = "6.1.8"
dependencies = [
"log",
"udev 0.8.0",
@@ -4743,7 +4743,7 @@ dependencies = [
[[package]]
name = "rog-control-center"
version = "6.1.6"
version = "6.1.8"
dependencies = [
"asusd",
"concat-idents",
@@ -4774,7 +4774,7 @@ dependencies = [
[[package]]
name = "rog_anime"
version = "6.1.6"
version = "6.1.8"
dependencies = [
"dmi_id",
"gif 0.12.0",
@@ -4788,7 +4788,7 @@ dependencies = [
[[package]]
name = "rog_aura"
version = "6.1.6"
version = "6.1.8"
dependencies = [
"dmi_id",
"log",
@@ -4799,7 +4799,7 @@ dependencies = [
[[package]]
name = "rog_dbus"
version = "6.1.6"
version = "6.1.8"
dependencies = [
"asusd",
"rog_anime",
@@ -4813,7 +4813,7 @@ dependencies = [
[[package]]
name = "rog_platform"
version = "6.1.6"
version = "6.1.8"
dependencies = [
"concat-idents",
"inotify",
@@ -4826,7 +4826,7 @@ dependencies = [
[[package]]
name = "rog_profiles"
version = "6.1.6"
version = "6.1.8"
dependencies = [
"log",
"rog_platform",
@@ -4837,7 +4837,7 @@ dependencies = [
[[package]]
name = "rog_scsi"
version = "6.1.6"
version = "6.1.8"
dependencies = [
"ron",
"serde",
@@ -4847,7 +4847,7 @@ dependencies = [
[[package]]
name = "rog_simulators"
version = "6.1.6"
version = "6.1.8"
dependencies = [
"log",
"rog_anime",
@@ -4857,7 +4857,7 @@ dependencies = [
[[package]]
name = "rog_slash"
version = "6.1.6"
version = "6.1.8"
dependencies = [
"dmi_id",
"serde",
+1 -1
View File
@@ -1,5 +1,5 @@
[workspace.package]
version = "6.1.6"
version = "6.1.8"
rust-version = "1.82"
license = "MPL-2.0"
readme = "README.md"
+25 -7
View File
@@ -74,22 +74,36 @@ fn main() {
println!("\nError: {e}\n");
print_info();
}) {
let asusd_version = platform_proxy
.version()
.map_err(|e| {
let asusd_version = match platform_proxy.version() {
Ok(version) => version,
Err(e) => {
error!(
"Could not get asusd version: {e:?}\nIs asusd.service running? {}",
check_service("asusd")
);
})
.unwrap();
return;
}
};
if asusd_version != self_version {
println!("Version mismatch: asusctl = {self_version}, asusd = {asusd_version}");
return;
}
let supported_properties = platform_proxy.supported_properties().unwrap();
let supported_interfaces = list_iface_blocking().unwrap();
let supported_properties = match platform_proxy.supported_properties() {
Ok(props) => props,
Err(e) => {
error!("Could not get supported properties: {e:?}");
return;
}
};
let supported_interfaces = match list_iface_blocking() {
Ok(ifaces) => ifaces,
Err(e) => {
error!("Could not get supported interfaces: {e:?}");
return;
}
};
if parsed.version {
println!("asusctl v{}", env!("CARGO_PKG_VERSION"));
@@ -575,6 +589,7 @@ fn handle_slash(cmd: &SlashCommand) -> Result<(), Box<dyn std::error::Error>> {
&& cmd.show_on_sleep.is_none()
&& cmd.show_on_battery.is_none()
&& cmd.show_battery_warning.is_none()
// && cmd.show_on_lid_closed.is_none()
&& cmd.mode.is_none()
&& !cmd.list
&& !cmd.enable
@@ -620,6 +635,9 @@ fn handle_slash(cmd: &SlashCommand) -> Result<(), Box<dyn std::error::Error>> {
if let Some(show) = cmd.show_battery_warning {
proxy.set_show_battery_warning(show)?;
}
// if let Some(show) = cmd.show_on_lid_closed {
// proxy.set_show_on_lid_closed(show)?;
// }
}
if cmd.list {
let res = SlashMode::list();
+2
View File
@@ -26,6 +26,8 @@ pub struct SlashCommand {
pub show_on_sleep: Option<bool>,
#[options(short = "b", meta = "", help = "Show the animation on battery")]
pub show_on_battery: Option<bool>,
// #[options(short = "L", meta = "", help = "Show the animation on lid closed")]
// pub show_on_lid_closed: Option<bool>,
#[options(
short = "w",
meta = "",
+2
View File
@@ -18,6 +18,7 @@ pub struct SlashConfig {
pub show_on_sleep: bool,
pub show_on_battery: bool,
pub show_battery_warning: bool,
pub show_on_lid_closed: bool,
}
impl Default for SlashConfig {
@@ -33,6 +34,7 @@ impl Default for SlashConfig {
show_on_sleep: true,
show_on_battery: true,
show_battery_warning: true,
show_on_lid_closed: true,
}
}
}
+7 -8
View File
@@ -4,8 +4,7 @@ use config::SlashConfig;
use futures_util::lock::{Mutex, MutexGuard};
use rog_platform::hid_raw::HidRaw;
use rog_platform::usb_raw::USBRaw;
use rog_slash::usb::{get_options_packet, pkt_set_mode, pkts_for_init};
use rog_slash::SlashType;
use rog_slash::usb::{slash_pkt_enable, slash_pkt_init, slash_pkt_options, slash_pkt_set_mode};
use crate::error::RogError;
@@ -46,14 +45,14 @@ impl Slash {
pub async fn do_initialization(&self) -> Result<(), RogError> {
// Don't try to initialise these models as the asus drivers already did
let config = self.config.lock().await;
if !matches!(config.slash_type, SlashType::GA605 | SlashType::GU605) {
for pkt in &pkts_for_init(config.slash_type) {
self.write_bytes(pkt).await?;
}
for pkt in &slash_pkt_init(config.slash_type) {
self.write_bytes(pkt).await?;
}
self.write_bytes(&slash_pkt_enable(config.slash_type, config.enabled))
.await?;
// Apply config upon initialization
let option_packets = get_options_packet(
let option_packets = slash_pkt_options(
config.slash_type,
config.enabled,
config.brightness,
@@ -61,7 +60,7 @@ impl Slash {
);
self.write_bytes(&option_packets).await?;
let mode_packets = pkt_set_mode(config.slash_type, config.display_mode);
let mode_packets = slash_pkt_set_mode(config.slash_type, config.display_mode);
// self.node.write_bytes(&mode_packets[0])?;
self.write_bytes(&mode_packets[1]).await?;
+48 -18
View File
@@ -1,8 +1,9 @@
use config_traits::StdConfig;
use log::{debug, error, warn};
use rog_slash::usb::{
get_battery_saver_packet, get_boot_packet, get_low_battery_packet, get_options_packet,
get_shutdown_packet, get_sleep_packet, pkt_save, pkt_set_mode,
slash_pkt_battery_saver, slash_pkt_boot, slash_pkt_enable, slash_pkt_lid_closed,
slash_pkt_low_battery, slash_pkt_options, slash_pkt_save, slash_pkt_set_mode,
slash_pkt_shutdown, slash_pkt_sleep,
};
use rog_slash::{DeviceState, SlashMode};
use zbus::zvariant::OwnedObjectPath;
@@ -58,7 +59,14 @@ impl SlashZbus {
config.brightness
};
self.0
.write_bytes(&get_options_packet(
.write_bytes(&slash_pkt_enable(config.slash_type, enabled))
.await
.map_err(|err| {
warn!("ctrl_slash::enable {}", err);
})
.ok();
self.0
.write_bytes(&slash_pkt_options(
config.slash_type,
enabled,
brightness,
@@ -88,7 +96,7 @@ impl SlashZbus {
let mut config = self.0.lock_config().await;
let enabled = brightness > 0;
self.0
.write_bytes(&get_options_packet(
.write_bytes(&slash_pkt_options(
config.slash_type,
enabled,
brightness,
@@ -116,7 +124,7 @@ impl SlashZbus {
async fn set_interval(&self, interval: u8) {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_options_packet(
.write_bytes(&slash_pkt_options(
config.slash_type, config.enabled, config.brightness, interval,
))
.await
@@ -140,10 +148,12 @@ impl SlashZbus {
async fn set_mode(&self, mode: SlashMode) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
let command_packets = pkt_set_mode(config.slash_type, mode);
let command_packets = slash_pkt_set_mode(config.slash_type, mode);
// self.node.write_bytes(&command_packets[0])?;
self.0.write_bytes(&command_packets[1]).await?;
self.0.write_bytes(&pkt_save(config.slash_type)).await?;
self.0
.write_bytes(&slash_pkt_save(config.slash_type))
.await?;
config.display_mode = mode;
config.write();
@@ -167,7 +177,7 @@ impl SlashZbus {
async fn set_show_on_boot(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_boot_packet(config.slash_type, enable))
.write_bytes(&slash_pkt_boot(config.slash_type, enable))
.await?;
config.show_on_boot = enable;
config.write();
@@ -184,7 +194,7 @@ impl SlashZbus {
async fn set_show_on_sleep(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_sleep_packet(config.slash_type, enable))
.write_bytes(&slash_pkt_sleep(config.slash_type, enable))
.await?;
config.show_on_sleep = enable;
config.write();
@@ -201,7 +211,7 @@ impl SlashZbus {
async fn set_show_on_shutdown(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_shutdown_packet(config.slash_type, enable))
.write_bytes(&slash_pkt_shutdown(config.slash_type, enable))
.await?;
config.show_on_shutdown = enable;
config.write();
@@ -218,7 +228,7 @@ impl SlashZbus {
async fn set_show_on_battery(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_battery_saver_packet(config.slash_type, enable))
.write_bytes(&slash_pkt_battery_saver(config.slash_type, enable))
.await?;
config.show_on_battery = enable;
config.write();
@@ -235,12 +245,32 @@ impl SlashZbus {
async fn set_show_battery_warning(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_low_battery_packet(config.slash_type, enable))
.write_bytes(&slash_pkt_low_battery(config.slash_type, enable))
.await?;
config.show_battery_warning = enable;
config.write();
Ok(())
}
#[zbus(property)]
async fn show_on_lid_closed(&self) -> zbus::fdo::Result<bool> {
let config = self.0.lock_config().await;
Ok(config.show_on_lid_closed)
}
#[zbus(property)]
async fn set_show_on_lid_closed(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&slash_pkt_lid_closed(config.slash_type, enable))
.await?;
self.0
.write_bytes(&slash_pkt_save(config.slash_type))
.await?;
config.show_on_lid_closed = enable;
config.write();
Ok(())
}
}
impl Reloadable for SlashZbus {
@@ -248,7 +278,7 @@ impl Reloadable for SlashZbus {
debug!("reloading slash settings");
let config = self.0.lock_config().await;
self.0
.write_bytes(&get_options_packet(
.write_bytes(&slash_pkt_options(
config.slash_type,
config.enabled,
config.brightness,
@@ -272,12 +302,12 @@ impl Reloadable for SlashZbus {
};
}
write_bytes_with_warning!(get_boot_packet, show_on_boot, "show_on_boot");
write_bytes_with_warning!(get_sleep_packet, show_on_sleep, "show_on_sleep");
write_bytes_with_warning!(get_shutdown_packet, show_on_shutdown, "show_on_shutdown");
write_bytes_with_warning!(get_battery_saver_packet, show_on_battery, "show_on_battery");
write_bytes_with_warning!(slash_pkt_boot, show_on_boot, "show_on_boot");
write_bytes_with_warning!(slash_pkt_sleep, show_on_sleep, "show_on_sleep");
write_bytes_with_warning!(slash_pkt_shutdown, show_on_shutdown, "show_on_shutdown");
write_bytes_with_warning!(slash_pkt_battery_saver, show_on_battery, "show_on_battery");
write_bytes_with_warning!(
get_low_battery_packet,
slash_pkt_low_battery,
show_battery_warning,
"show_battery_warning"
);
+35 -27
View File
@@ -1,7 +1,7 @@
#
# spec file for package asus-nb-ctrl
#
# Copyright (c) 2020-2021 Luke Jones <luke@ljones.dev>
# Copyright (c) 2020-2025 Luke Jones <luke@ljones.dev>
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -20,42 +20,43 @@
%global debug_package %{nil}
%endif
%define version 6.1.8
%define specrelease %{?dist}
%define pkg_release 3%{specrelease}
%define pkg_release 8%{specrelease}
# Use hardening ldflags.
%global rustflags -Clink-arg=-Wl,-z,relro,-z,now
Name: asusctl
Version: 6.0.7
Name: asusctl
Version: %{version}
Release: %{pkg_release}
Summary: Control fan speeds, LEDs, graphics modes, and charge levels for ASUS notebooks
License: MPLv2
Summary: Control fan speeds, LEDs, graphics modes, and charge levels for ASUS notebooks
License: MPLv2
Group: System Environment/Kernel
Group: System Environment/Kernel
URL: https://gitlab.com/asus-linux/asusctl
Source: %{name}-%{version}.tar.gz
Source1: vendor_%{name}_%{version}.tar.xz
Source2: cargo-config
URL: https://gitlab.com/asus-linux/asusctl
Source: https://gitlab.com/asus-linux/asusctl/-/archive/%{version}/%{name}-%{version}.tar.gz
BuildRequires: cargo
%if %{defined fedora}
BuildRequires: rust-packaging
BuildRequires: systemd-rpm-macros
%else
BuildRequires: cargo-packaging
%endif
BuildRequires: git
BuildRequires: clang-devel
BuildRequires: cargo
BuildRequires: cmake
BuildRequires: rust
BuildRequires: rust-std-static
BuildRequires: pkgconfig(expat)
BuildRequires: pkgconfig(dbus-1)
BuildRequires: pkgconfig(gbm)
BuildRequires: pkgconfig(libinput)
BuildRequires: pkgconfig(libseat)
BuildRequires: pkgconfig(libudev)
BuildRequires: pkgconfig(xkbcommon)
BuildRequires: pkgconfig(libzstd)
BuildRequires: pkgconfig(gtk+-3.0)
BuildRequires: pkgconfig(gdk-3.0)
BuildRequires: desktop-file-utils
# expat-devel pcre2-devel
%description
asus-nb-ctrl is a utility for Linux to control many aspects of various
ASUS laptops but can also be used with non-Asus laptops with reduced features.
@@ -72,21 +73,28 @@ A one-stop-shop GUI tool for asusd/asusctl. It aims to provide most controls,
a notification service, and ability to run in the background.
%prep
# %setup -D -T -a 1 -c -n %{name}-%{version}/vendor
# %setup -D -T -a 0 -c
%autosetup
%setup -D -T -a 1
mv Cargo.lock{,.bak}
%if %{defined fedora}
%cargo_prep
mv Cargo.lock{.bak,}
sed -i 's|replace-with = "local-registry"|replace-with = "vendored-sources"|' .cargo/config
cat %{SOURCE2} >> .cargo/config
sed -i 's|offline = true|offline = false|' .cargo/config.toml
sed -i 's|source.crates-io|source.ignore_this|' .cargo/config.toml
%else
mkdir -p .cargo
cat > .cargo/config.toml << 'EOF'
[term]
verbose = true
[net]
offline = false
EOF
%endif
%build
export RUSTFLAGS="%{rustflags}"
%if %{defined fedora}
%cargo_build
#cargo build --release --frozen --offline --config .cargo/config.toml
%else
/usr/bin/cargo auditable build --release
%endif
%install
export RUSTFLAGS="%{rustflags}"
+102 -63
View File
@@ -35,10 +35,21 @@ async fn main() -> Result<()> {
// If we're running under gamescope we have to set WAYLAND_DISPLAY for winit to
// use
if let Ok(gamescope) = env::var("GAMESCOPE_WAYLAND_DISPLAY") {
dbg!(1);
if !gamescope.is_empty() {
dbg!(2);
env::set_var("WAYLAND_DISPLAY", gamescope);
}
// gamescope-0
else if let Ok(wayland) = env::var("WAYLAND_DISPLAY") {
dbg!(3);
if wayland.is_empty() {
dbg!(4);
env::set_var("WAYLAND_DISPLAY", "gamescope-0");
}
}
}
dbg!("SHITR");
// Try to open a proxy and check for app state first
{
@@ -92,7 +103,7 @@ async fn main() -> Result<()> {
let board_name = dmi.board_name;
let prod_family = dmi.product_family;
info!("Running on {board_name}, product: {prod_family}");
let is_rog_ally = prod_family == "RC71L" || prod_family == "RC72L";
let is_rog_ally = board_name == "RC71L" || board_name == "RC72L" || prod_family == "ROG Ally";
let args: Vec<String> = args().skip(1).collect();
@@ -163,73 +174,101 @@ async fn main() -> Result<()> {
thread::spawn(move || {
let mut state = AppState::StartingUp;
loop {
// save as a var, don't hold the lock the entire time or deadlocks happen
if let Ok(app_state) = app_state.lock() {
state = *app_state;
}
if is_rog_ally {
let config_copy_2 = config.clone();
let newui = setup_window(config.clone());
newui.window().on_close_requested(move || {
exit(0);
});
// This sleep is required to give the event loop time to react
sleep(Duration::from_millis(300));
if state == AppState::MainWindowShouldOpen {
if let Ok(mut app_state) = app_state.lock() {
*app_state = AppState::MainWindowOpen;
}
let config_copy = config.clone();
let app_state_copy = app_state.clone();
slint::invoke_from_event_loop(move || {
UI.with(|ui| {
let app_state_copy = app_state_copy.clone();
let mut ui = ui.borrow_mut();
if let Some(ui) = ui.as_mut() {
ui.window().show().unwrap();
ui.window().on_close_requested(move || {
if let Ok(mut app_state) = app_state_copy.lock() {
*app_state = AppState::MainWindowClosed;
}
slint::CloseRequestResponse::HideWindow
});
} else {
let config_copy_2 = config_copy.clone();
let newui = setup_window(config_copy);
newui.window().on_close_requested(move || {
if let Ok(mut app_state) = app_state_copy.lock() {
*app_state = AppState::MainWindowClosed;
}
slint::CloseRequestResponse::HideWindow
});
let ui_copy = newui.as_weak();
newui
.window()
.set_rendering_notifier(move |s, _| {
if let slint::RenderingState::RenderingSetup = s {
let config = config_copy_2.clone();
ui_copy
.upgrade_in_event_loop(move |w| {
let fullscreen =
config.lock().is_ok_and(|c| c.start_fullscreen);
if fullscreen && !w.window().is_fullscreen() {
w.window().set_fullscreen(fullscreen);
}
})
.ok();
let ui_copy = newui.as_weak();
newui
.window()
.set_rendering_notifier(move |s, _| {
if let slint::RenderingState::BeforeRendering = s {
let config = config_copy_2.clone();
ui_copy
.upgrade_in_event_loop(move |w| {
let fullscreen =
config.lock().is_ok_and(|c| c.start_fullscreen);
if fullscreen && !w.window().is_fullscreen() {
w.window().set_fullscreen(fullscreen);
}
})
.ok();
ui.replace(newui);
}
});
})
.unwrap();
} else if state == AppState::QuitApp {
slint::quit_event_loop().unwrap();
exit(0);
} else if state != AppState::MainWindowOpen {
if let Ok(config) = config.lock() {
if !config.run_in_background {
slint::quit_event_loop().unwrap();
exit(0);
})
.ok();
} else {
// save as a var, don't hold the lock the entire time or deadlocks happen
if let Ok(app_state) = app_state.lock() {
state = *app_state;
}
// This sleep is required to give the event loop time to react
sleep(Duration::from_millis(300));
if state == AppState::MainWindowShouldOpen {
if let Ok(mut app_state) = app_state.lock() {
*app_state = AppState::MainWindowOpen;
}
let config_copy = config.clone();
let app_state_copy = app_state.clone();
slint::invoke_from_event_loop(move || {
UI.with(|ui| {
let app_state_copy = app_state_copy.clone();
let mut ui = ui.borrow_mut();
if let Some(ui) = ui.as_mut() {
ui.window().show().unwrap();
ui.window().on_close_requested(move || {
if let Ok(mut app_state) = app_state_copy.lock() {
*app_state = AppState::MainWindowClosed;
}
slint::CloseRequestResponse::HideWindow
});
} else {
let config_copy_2 = config_copy.clone();
let newui = setup_window(config_copy);
newui.window().on_close_requested(move || {
if let Ok(mut app_state) = app_state_copy.lock() {
*app_state = AppState::MainWindowClosed;
}
slint::CloseRequestResponse::HideWindow
});
let ui_copy = newui.as_weak();
newui
.window()
.set_rendering_notifier(move |s, _| {
if let slint::RenderingState::RenderingSetup = s {
let config = config_copy_2.clone();
ui_copy
.upgrade_in_event_loop(move |w| {
let fullscreen = config
.lock()
.is_ok_and(|c| c.start_fullscreen);
if fullscreen && !w.window().is_fullscreen() {
w.window().set_fullscreen(fullscreen);
}
})
.ok();
}
})
.ok();
ui.replace(newui);
}
});
})
.unwrap();
} else if state == AppState::QuitApp {
slint::quit_event_loop().unwrap();
exit(0);
} else if state != AppState::MainWindowOpen {
if let Ok(config) = config.lock() {
if !config.run_in_background {
slint::quit_event_loop().unwrap();
exit(0);
}
}
}
}
@@ -2,7 +2,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2025-02-15 22:50+0000\n"
"POT-Creation-Date: 2025-02-18 09:08+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"
+6
View File
@@ -60,4 +60,10 @@ pub trait Slash {
fn show_on_sleep(&self) -> zbus::Result<bool>;
#[zbus(property)]
fn set_show_on_sleep(&self, value: bool) -> zbus::Result<()>;
/// ShowOnLidClosed property
#[zbus(property)]
fn show_on_lid_closed(&self) -> zbus::Result<bool>;
#[zbus(property)]
fn set_show_on_lid_closed(&self, value: bool) -> zbus::Result<()>;
}
+23 -10
View File
@@ -62,7 +62,7 @@ pub const fn report_id(slash_type: SlashType) -> u8 {
/// Get the two device initialization packets. These are required for device
/// start after the laptop boots.
#[inline]
pub fn pkts_for_init(slash_type: SlashType) -> [SlashUsbPacket; 2] {
pub fn slash_pkt_init(slash_type: SlashType) -> [SlashUsbPacket; 2] {
let report_id = report_id(slash_type);
let mut pkt1 = [0; PACKET_SIZE];
@@ -87,7 +87,20 @@ pub fn pkts_for_init(slash_type: SlashType) -> [SlashUsbPacket; 2] {
}
#[inline]
pub const fn pkt_save(slash_type: SlashType) -> SlashUsbPacket {
pub const fn slash_pkt_enable(slash_type: SlashType, enabled: bool) -> SlashUsbPacket {
let mut pkt = [0; PACKET_SIZE];
pkt[0] = report_id(slash_type);
pkt[1] = 0xd8;
pkt[2] = 0x02;
pkt[3] = 0x00;
pkt[4] = 0x01;
pkt[5] = if enabled { 0x00 } else { 0x80 };
pkt
}
#[inline]
pub const fn slash_pkt_save(slash_type: SlashType) -> SlashUsbPacket {
let mut pkt = [0; PACKET_SIZE];
pkt[0] = report_id(slash_type);
pkt[1] = 0xd4;
@@ -100,7 +113,7 @@ pub const fn pkt_save(slash_type: SlashType) -> SlashUsbPacket {
}
#[inline]
pub const fn pkt_set_mode(slash_type: SlashType, mode: SlashMode) -> [SlashUsbPacket; 2] {
pub const fn slash_pkt_set_mode(slash_type: SlashType, mode: SlashMode) -> [SlashUsbPacket; 2] {
let report_id = report_id(slash_type);
let mut pkt1 = [0; PACKET_SIZE];
pkt1[0] = report_id;
@@ -133,7 +146,7 @@ pub const fn pkt_set_mode(slash_type: SlashType, mode: SlashMode) -> [SlashUsbPa
]
}
pub const fn get_options_packet(
pub const fn slash_pkt_options(
slash_type: SlashType,
enabled: bool,
brightness: u8,
@@ -146,7 +159,7 @@ pub const fn get_options_packet(
]
}
pub const fn get_boot_packet(slash_type: SlashType, enabled: bool) -> [u8; 12] {
pub const fn slash_pkt_boot(slash_type: SlashType, enabled: bool) -> [u8; 12] {
let typ = report_id(slash_type);
let status = enabled as u8;
[
@@ -154,7 +167,7 @@ pub const fn get_boot_packet(slash_type: SlashType, enabled: bool) -> [u8; 12] {
]
}
pub const fn get_sleep_packet(slash_type: SlashType, enabled: bool) -> [u8; 12] {
pub const fn slash_pkt_sleep(slash_type: SlashType, enabled: bool) -> [u8; 12] {
let typ = report_id(slash_type);
let status = (!enabled) as u8;
[
@@ -162,7 +175,7 @@ pub const fn get_sleep_packet(slash_type: SlashType, enabled: bool) -> [u8; 12]
]
}
pub const fn get_low_battery_packet(slash_type: SlashType, enabled: bool) -> [u8; 12] {
pub const fn slash_pkt_low_battery(slash_type: SlashType, enabled: bool) -> [u8; 12] {
let typ = report_id(slash_type);
let status = enabled as u8;
[
@@ -170,7 +183,7 @@ pub const fn get_low_battery_packet(slash_type: SlashType, enabled: bool) -> [u8
]
}
pub const fn get_shutdown_packet(slash_type: SlashType, enabled: bool) -> [u8; 12] {
pub const fn slash_pkt_shutdown(slash_type: SlashType, enabled: bool) -> [u8; 12] {
let typ = report_id(slash_type);
let status = enabled as u8;
[
@@ -178,7 +191,7 @@ pub const fn get_shutdown_packet(slash_type: SlashType, enabled: bool) -> [u8; 1
]
}
pub const fn get_battery_saver_packet(slash_type: SlashType, enabled: bool) -> [u8; 6] {
pub const fn slash_pkt_battery_saver(slash_type: SlashType, enabled: bool) -> [u8; 6] {
let typ = report_id(slash_type);
let status = if enabled { 0x00 } else { 0x80 };
[
@@ -186,7 +199,7 @@ pub const fn get_battery_saver_packet(slash_type: SlashType, enabled: bool) -> [
]
}
pub const fn get_lid_closed_packet(slash_type: SlashType, enabled: bool) -> [u8; 7] {
pub const fn slash_pkt_lid_closed(slash_type: SlashType, enabled: bool) -> [u8; 7] {
let typ = report_id(slash_type);
let status = if enabled { 0x00 } else { 0x80 };
[