Skip to content
Merged
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
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI

on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]

env:
CARGO_TERM_COLOR: always

jobs:
build:
name: Build and Test
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libslint-dev libasound2-dev libpulse-dev libdbus-1-dev libbluetooth-dev libnm-dev libudev-dev

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt

- name: Check formatting
run: cargo fmt --all -- --check

- name: Linting
run: cargo clippy --all-targets --all-features -- -D warnings

- name: Run tests
run: cargo test --all-targets --all-features

- name: Build
run: cargo build --release --verbose
1 change: 1 addition & 0 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The first release will include a taskbar and a basic app launcher. It is not pla
- [ ] create crate for shared window manager communication -> 1 crate communicating with the current window manager. This crate will then share generalized data to each crate that asks for information. This means that most of the window manager information is only fetched once and updated effeciently
- [ ] create **selector for media source for media player**
- [ ] add app basic **app launcher** (directly create a standard menu for this to share other menu items)
- [ ] add systray
- [ ] add generalized config file with following configs
- show seconds
- DD/MM/YYYY or MM/DD/YYYY
Expand Down
37 changes: 37 additions & 0 deletions crates/capy-wm/src/window_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,40 @@ pub fn create_backend() -> Option<Box<dyn WindowBackend>> {
pub fn get_backend() -> Box<dyn WindowBackend> {
create_backend().expect("No supported window manager detected")
}

#[cfg(test)]
mod tests {
use super::*;
use std::env;
use std::sync::Mutex;

// Use a mutex to ensure tests that modify env vars don't race
static ENV_LOCK: Mutex<()> = Mutex::new(());

#[test]
fn test_detect_wm_hyprland_xdg() {
let _guard = ENV_LOCK.lock().unwrap();

unsafe {
env::set_var("XDG_CURRENT_DESKTOP", "Hyprland");
}
assert_eq!(detect_wm(), WmType::Hyprland);
unsafe {
env::remove_var("XDG_CURRENT_DESKTOP");
}
}

#[test]
fn test_detect_wm_unknown() {
let _guard = ENV_LOCK.lock().unwrap();

// Clear potential env vars
unsafe {
env::remove_var("XDG_CURRENT_DESKTOP");
env::remove_var("HYPRLAND_INSTANCE_SIGNATURE");
env::remove_var("SWAYSOCK");
}

assert_eq!(detect_wm(), WmType::Unknown);
}
}
Loading