Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y clang libbpf-dev libudev-dev pkg-config gcc-multilib libegl1-mesa-dev libvulkan-dev libglvnd-dev libwayland-dev libxkbcommon-dev libx11-dev libxcb1-dev libx11-xcb-dev
run: sudo apt-get update && sudo apt-get install -y clang libbpf-dev libudev-dev pkg-config gcc-multilib libegl1-mesa-dev libvulkan-dev libglvnd-dev libwayland-dev libxkbcommon-dev libx11-dev libxcb1-dev libx11-xcb-dev dbus-daemon
- name: Install Nightly Rust (for aya-ebpf)
uses: dtolnay/rust-toolchain@nightly
with:
Expand All @@ -117,6 +117,9 @@ jobs:
run: cargo binstall bpf-linker
- name: Test code
run: cargo test
- name: Test GUI instance ownership on an isolated bus
run: >-
dbus-run-session -- cargo test --locked -p cardwire-gui helpers::dbus::tests:: -- --ignored
rust-format:
name: Rust Format
runs-on: ubuntu-latest
Expand Down Expand Up @@ -151,6 +154,17 @@ jobs:
persist-credentials: false
- uses: determinateSystems/nix-installer-action@ef8a148080ab6020fd15196c2084a2eea5ff2d25 # v22
- run: nix build .#checks.x86_64-linux.${{ matrix.vm }}
gui-dbus-test:
name: GUI D-Bus Test
runs-on: ubuntu-latest
needs: [prepare]
if: needs.prepare.outputs.run_rust_checks == 'true' || needs.prepare.outputs.run_nix_vm == 'true'
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: determinateSystems/nix-installer-action@ef8a148080ab6020fd15196c2084a2eea5ff2d25 # v22
- run: nix build .#checks.x86_64-linux.gui-dbus
mdbook-test:
runs-on: ubuntu-latest
needs: [prepare]
Expand All @@ -169,4 +183,5 @@ jobs:
id: pages
uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0
- name: Test with mdBook
run: mdbook test
run: mdbook test

1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ CIs must pass before merging, this includes:
- Nix VM 2 GPUs (Laptop conf)
- Nix VM 3 GPUs
- Nix VM 15 GPUs
- Nix GUI D-Bus Test

If none of these CIs passes, the PR won't be merged

Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/cardwire-gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ license.workspace = true
description = "GUI for cardwire GPU management"

[dependencies]
thiserror.workspace = true
tokio.workspace = true
tokio-stream.workspace = true
zbus.workspace = true
Expand Down
18 changes: 12 additions & 6 deletions crates/cardwire-gui/src/app.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use clap::Parser;
use iced::{
Alignment, Element, Length::{Fill, Fixed}, Subscription, Task, widget::{column, container, row, stack}, window
};
use log::error;
use std::collections::BTreeMap;

use crate::{
args::CardwireArgs, gui_config::{GuiConfig, PrimaryClickAction}, helpers::{CardwireDbus, GpuDevice}, message::Message, models::{
args::CardwireArgs, gui_config::{GuiConfig, PrimaryClickAction}, helpers::{AppInstance, CardwireDbus, GpuDevice}, message::Message, models::{
DaemonSettings, LogState, MainState, Mode, Page, PciDevice, SettingState, SmartState
}, tray::{self, TrayAction, TrayHandle}, ui::{self, daemon_setting_page, error_bar, info_bar, pci_page}
};
Expand Down Expand Up @@ -37,15 +36,14 @@ fn default_window_settings() -> window::Settings {
}

impl AppState {
pub fn new() -> (Self, Task<Message>) {
pub fn new(args: &CardwireArgs) -> (Self, Task<Message>) {
let (gui_config, error) = match GuiConfig::load() {
Ok(config) => (config, None),
Err(error) => (
GuiConfig::default(),
Some(format!("Could not load GUI settings: {error}")),
),
};
let args = CardwireArgs::parse();
// Hide the GUI if launched with --background, or if the start_in_tray setting is set
let (window_id, open_window) = if args.background.is_some_and(|b| b)
|| (args.background.is_none() && gui_config.start_in_tray)
Expand Down Expand Up @@ -89,6 +87,7 @@ impl AppState {
| Message::GpuBlockResult(_)
);
match message {
Message::Activate => return self.open_or_focus_window(),
// Switch to a new page, clearing the pop-ups at the same time
Message::SwitchPage(page) => {
self.current_tab = page;
Expand Down Expand Up @@ -537,10 +536,11 @@ impl AppState {
}
}

pub fn subscription(&self) -> Subscription<Message> {
pub fn subscription(&self, instance: &AppInstance) -> Subscription<Message> {
Subscription::batch([
crate::subscription::dbus_sub(),
crate::subscription::tray_sub(),
crate::subscription::activation_sub(instance),
window::close_events().map(Message::WindowClosed),
])
}
Expand Down Expand Up @@ -571,7 +571,13 @@ impl AppState {

fn open_or_focus_window(&mut self) -> Task<Message> {
if let Some(id) = self.window_id {
window::gain_focus(id)
// Wayland does not implement gain_focus; request activation
// through the compositor's attention protocol as well.
// source: iced_runtime::window::Action::GainFocus(Id)
window::minimize(id, false).chain(window::request_user_attention(
id,
Some(window::UserAttention::Informational),
))
} else {
let (id, task) = window::open(default_window_settings());
self.window_id = Some(id);
Expand Down
15 changes: 15 additions & 0 deletions crates/cardwire-gui/src/errors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use thiserror::Error;

#[derive(Debug, Error)]
pub enum CardwireGuiError {
#[error("iced error: {0}")]
Iced(#[from] iced::Error),

#[error("zbus error: {0}")]
Zbus(#[from] zbus::Error),

#[error("IO error: {0}")]
Io(#[from] std::io::Error),
}

pub type Result<T> = std::result::Result<T, CardwireGuiError>;
Loading