add wayland display refresh‑rate control and Run subcommand tolaunch applications on discrete GPU #1
No files matched your search
@@ -269,6 +269,30 @@ fn fetch_state() -> Option<(Connection, AppState, wayland_client::EventQueue<App
|
||||
Some((conn, state, event_queue))
|
||||
}
|
||||
|
||||
pub fn get_active_display_info() -> Vec<String> {
|
||||
let mut infos = Vec::new();
|
||||
if let Some((_, state, _)) = fetch_state() {
|
||||
for (_, head) in state.heads.iter() {
|
||||
if !head.enabled {
|
||||
continue;
|
||||
}
|
||||
let Some(current_mode_handle) = &head.current_mode else {
|
||||
continue;
|
||||
};
|
||||
let Some((_, mode)) = state.modes.get(current_mode_handle) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let hz = (mode.refresh as f64) / 1000.0;
|
||||
infos.push(format!(
|
||||
"{} ({}): {}x{} px, {:.3} Hz",
|
||||
head.name, head.make, mode.width, mode.height, hz
|
||||
));
|
||||
}
|
||||
}
|
||||
infos
|
||||
}
|
||||
|
||||
fn show_refresh_rates() {
|
||||
if let Some((_, state, _)) = fetch_state() {
|
||||
for (head_handle, head) in state.heads.iter() {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::commands::display;
|
||||
use crate::hardware::gpu;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
@@ -179,4 +180,14 @@ pub fn execute() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Display Status
|
||||
let displays = display::get_active_display_info();
|
||||
if displays.is_empty() {
|
||||
println!("Display: Unknown / Firmware managed");
|
||||
} else {
|
||||
for d in displays {
|
||||
println!("Display: {}", d);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user