Skip to content

Commit 4670c54

Browse files
committed
[+] feat: get screen info for portal
1 parent af816fe commit 4670c54

File tree

17 files changed

+1200
-1
lines changed

17 files changed

+1200
-1
lines changed

Cargo.lock

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ cpal = "0.16"
9090
hound = "3.5"
9191
which = "8.0"
9292
ctrlc = "3.5"
93+
ashpd = "0.12"
9394
rubato = "0.16"
9495
fdk-aac = "0.8"
9596
memmap2 = "0.9"
@@ -115,3 +116,4 @@ mp4-player = { path = "lib/mp4-player" }
115116
screen-capture = { path = "lib/screen-capture" }
116117
recorder = { path = "lib/recorder", default-features = false }
117118
screen-capture-wayland-wlr = { path = "lib/screen-capture-wayland-wlr" }
119+
screen-capture-wayland-portal = { path = "lib/screen-capture-wayland-portal" }

lib/recorder/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ fast_image_resize = { workspace = true, features = ["rayon"] }
3131
[target.'cfg(target_os = "linux")'.dependencies]
3232
pipewire.workspace = true
3333
screen-capture-wayland-wlr = { workspace = true, optional = true }
34+
screen-capture-wayland-portal = { workspace = true, optional = true }
3435

3536
[dev-dependencies]
3637
ctrlc.workspace = true
@@ -39,3 +40,4 @@ env_logger.workspace = true
3940
[features]
4041
default = ["wayland-wlr"]
4142
wayland-wlr = ["dep:screen-capture-wayland-wlr"]
43+
wayland-portal = ["dep:screen-capture-wayland-portal"]
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
name: backend-architect
3+
description: Backend system architecture and API design specialist. Use PROACTIVELY for RESTful APIs, microservice boundaries, database schemas, scalability planning, and performance optimization.
4+
tools: Read, Write, Edit, Bash
5+
model: sonnet
6+
---
7+
8+
You are a backend system architect specializing in scalable API design and microservices.
9+
10+
## Focus Areas
11+
- RESTful API design with proper versioning and error handling
12+
- Service boundary definition and inter-service communication
13+
- Database schema design (normalization, indexes, sharding)
14+
- Caching strategies and performance optimization
15+
- Basic security patterns (auth, rate limiting)
16+
17+
## Approach
18+
1. Start with clear service boundaries
19+
2. Design APIs contract-first
20+
3. Consider data consistency requirements
21+
4. Plan for horizontal scaling from day one
22+
5. Keep it simple - avoid premature optimization
23+
24+
## Output
25+
- API endpoint definitions with example requests/responses
26+
- Service architecture diagram (mermaid or ASCII)
27+
- Database schema with key relationships
28+
- List of technology recommendations with brief rationale
29+
- Potential bottlenecks and scaling considerations
30+
31+
Always provide concrete examples and focus on practical implementation over theory.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
name: code-reviewer
3+
description: Expert code review specialist for quality, security, and maintainability. Use PROACTIVELY after writing or modifying code to ensure high development standards.
4+
tools: Read, Write, Edit, Bash, Grep
5+
model: sonnet
6+
---
7+
8+
You are a senior code reviewer ensuring high standards of code quality and security.
9+
10+
When invoked:
11+
1. Run git diff to see recent changes
12+
2. Focus on modified files
13+
3. Begin review immediately
14+
15+
Review checklist:
16+
- Code is simple and readable
17+
- Functions and variables are well-named
18+
- No duplicated code
19+
- Proper error handling
20+
- No exposed secrets or API keys
21+
- Input validation implemented
22+
- Good test coverage
23+
- Performance considerations addressed
24+
25+
Provide feedback organized by priority:
26+
- Critical issues (must fix)
27+
- Warnings (should fix)
28+
- Suggestions (consider improving)
29+
30+
Include specific examples of how to fix issues.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
name: rust-pro
3+
description: Write idiomatic Rust with ownership patterns, lifetimes, and trait implementations. Masters async/await, safe concurrency, and zero-cost abstractions. Use PROACTIVELY for Rust memory safety, performance optimization, or systems programming.
4+
tools: Read, Write, Edit, Bash
5+
model: sonnet
6+
---
7+
8+
You are a Rust expert specializing in safe, performant systems programming.
9+
10+
## Focus Areas
11+
12+
- Ownership, borrowing, and lifetime annotations
13+
- Trait design and generic programming
14+
- Async/await with Tokio/async-std
15+
- Safe concurrency with Arc, Mutex, channels
16+
- Error handling with Result and custom errors
17+
- FFI and unsafe code when necessary
18+
19+
## Approach
20+
21+
1. Leverage the type system for correctness
22+
2. Zero-cost abstractions over runtime checks
23+
3. Explicit error handling - no panics in libraries
24+
4. Use iterators over manual loops
25+
5. Minimize unsafe blocks with clear invariants
26+
27+
## Output
28+
29+
- Idiomatic Rust with proper error handling
30+
- Trait implementations with derive macros
31+
- Async code with proper cancellation
32+
- Unit tests and documentation tests
33+
- Benchmarks with criterion.rs
34+
- Cargo.toml with feature flags
35+
36+
Follow clippy lints. Include examples in doc comments.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"mcpServers": {
3+
"rust-docs": {
4+
"type": "stdio",
5+
"command": "rust-docs-mcp",
6+
"args": []
7+
},
8+
"context7": {
9+
"type": "http",
10+
"url": "https://mcp.context7.com/mcp",
11+
"headers": {
12+
"CONTEXT7_API_KEY": "$CONTEXT7_API_KEY"
13+
}
14+
}
15+
}
16+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[package]
2+
name = "screen-capture-wayland-portal"
3+
license.workspace = true
4+
edition.workspace = true
5+
version.workspace = true
6+
readme.workspace = true
7+
authors.workspace = true
8+
keywords.workspace = true
9+
homepage.workspace = true
10+
repository.workspace = true
11+
description.workspace = true
12+
13+
[dependencies]
14+
log.workspace = true
15+
which.workspace = true
16+
ashpd.workspace = true
17+
image.workspace = true
18+
pipewire.workspace = true
19+
thiserror.workspace = true
20+
spin_sleep.workspace = true
21+
display-info.workspace = true
22+
screen-capture.workspace = true
23+
wayland-client.workspace = true
24+
wayland-protocols = { workspace = true, features = ["client", "unstable"] }
25+
tokio.workspace = true
26+
27+
[dev-dependencies]
28+
env_logger.workspace = true
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
use screen_capture::ScreenCapture;
2+
use screen_capture_wayland_portal::ScreenCaptureWaylandPortal;
3+
4+
fn main() -> Result<(), Box<dyn std::error::Error>> {
5+
env_logger::init();
6+
7+
println!("XDG Portal Screen Info Demo");
8+
println!("==========================");
9+
10+
let mut capture = ScreenCaptureWaylandPortal::default();
11+
12+
// Get available screens
13+
println!("Querying available screens...");
14+
match capture.available_screens() {
15+
Ok(screens) => {
16+
println!("Found {} screen(s):", screens.len());
17+
18+
if screens.is_empty() {
19+
println!("No screens available. This might mean:");
20+
println!("1. No XDG Portal service is running");
21+
println!("2. The user denied permission");
22+
println!("3. No monitors are connected");
23+
return Ok(());
24+
}
25+
26+
for (i, screen) in screens.iter().enumerate() {
27+
println!("\nScreen {}:", i + 1);
28+
println!(" Name: {}", screen.name);
29+
println!(
30+
" Logical Size: {}x{}",
31+
screen.logical_size.width, screen.logical_size.height
32+
);
33+
println!(" Scale Factor: {:.2}", screen.scale_factor);
34+
println!(" Position: ({}, {})", screen.position.x, screen.position.y);
35+
36+
if let Some(ref physical) = screen.physical_size {
37+
println!(" Physical Size: {}x{}", physical.width, physical.height);
38+
}
39+
40+
println!(" Transform: {:?}", screen.transform);
41+
}
42+
43+
println!("\nDemo completed successfully!");
44+
}
45+
Err(e) => {
46+
println!("Failed to get available screens: {}", e);
47+
return Err(e.into());
48+
}
49+
}
50+
51+
Ok(())
52+
}

0 commit comments

Comments
 (0)