Fix compositor output routing and pointer hints; format imports

This commit is contained in:
Samuel Onoja committed 2026-09-30 06:39:58 +01:00
1 parent 88e4f3c135
commit 46509f880a
108 files changed
+3682 -8371

No files matched your search

+11 -24
View File
@@ -1,11 +1,9 @@
use std::{
collections::BTreeMap,
env, fs,
io::Read,
os::unix::process::CommandExt,
path::{Path, PathBuf},
process::{Command, Stdio},
};
use std::collections::BTreeMap;
use std::io::Read;
use std::os::unix::process::CommandExt;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::{env, fs};
pub(crate) fn run() -> Result<(), Box<dyn std::error::Error>> {
for key in ["WAYLAND_SOCKET", "FERESE_SHELL_CONTROL_SOCKET"] {
@@ -35,20 +33,14 @@ pub(crate) fn run() -> Result<(), Box<dyn std::error::Error>> {
if system_directories.is_empty() {
system_directories.push(PathBuf::from("/etc/xdg"));
}
let directories = std::iter::once(home)
.chain(system_directories)
.collect::<Vec<_>>();
let directories = std::iter::once(home).chain(system_directories).collect::<Vec<_>>();
let mut entries = BTreeMap::new();
for directory in directories {
let Ok(files) = fs::read_dir(directory.join("autostart")) else {
continue;
};
for file in files.flatten() {
if file
.path()
.extension()
.is_some_and(|extension| extension == "desktop")
{
if file.path().extension().is_some_and(|extension| extension == "desktop") {
entries.entry(file.file_name()).or_insert(file.path());
}
}
@@ -108,9 +100,7 @@ fn read_entry(path: &Path) -> Option<BTreeMap<String, String>> {
return None;
}
let mut source = String::new();
file.take(1024 * 1024 + 1)
.read_to_string(&mut source)
.ok()?;
file.take(1024 * 1024 + 1).read_to_string(&mut source).ok()?;
if source.len() > 1024 * 1024 {
return None;
}
@@ -152,15 +142,12 @@ fn enabled(entry: &BTreeMap<String, String>, desktop: &str) -> bool {
fn available(program: &str) -> bool {
use std::os::unix::fs::PermissionsExt;
let executable = |path: &Path| {
fs::metadata(path)
.is_ok_and(|metadata| metadata.is_file() && metadata.permissions().mode() & 0o111 != 0)
fs::metadata(path).is_ok_and(|metadata| metadata.is_file() && metadata.permissions().mode() & 0o111 != 0)
};
if program.contains('/') {
executable(Path::new(program))
} else {
env::var_os("PATH").is_some_and(|paths| {
env::split_paths(&paths).any(|path| executable(&path.join(program)))
})
env::var_os("PATH").is_some_and(|paths| env::split_paths(&paths).any(|path| executable(&path.join(program))))
}
}
+8 -17
View File
@@ -1,11 +1,10 @@
mod autostart;
use std::env;
use std::error::Error;
use std::fs;
use std::io::{self, Write};
use std::io::Write;
use std::os::unix::net::UnixStream;
use std::path::PathBuf;
use std::{env, fs, io};
use ferese_ipc::{Request, Response, VERSION, read_frame, write_frame};
use serde_json::{Value, json};
@@ -101,10 +100,9 @@ fn parse_args(args: impl IntoIterator<Item = String>) -> Result<(String, Value),
));
}
},
"toggle-floating" | "toggle-fullscreen" | "toggle-maximized" | "toggle-layout"
| "toggle-overview" | "cycle-column-width" | "center-column" | "consume" | "expel"
| "close" | "get-focused-window" | "get-windows" | "get-workspaces" | "get-outputs"
| "reload-config" | "exit" | "request-logout" => {
"toggle-floating" | "toggle-fullscreen" | "toggle-maximized" | "toggle-layout" | "toggle-overview"
| "cycle-column-width" | "center-column" | "consume" | "expel" | "close" | "get-focused-window"
| "get-windows" | "get-workspaces" | "get-outputs" | "reload-config" | "exit" | "request-logout" => {
if !positional.is_empty() {
return Err(format!("{command} does not accept arguments"));
}
@@ -152,15 +150,11 @@ mod tests {
#[test]
fn parses_direction_and_workspace_commands() {
assert_eq!(
parse_args(["focus".to_owned(), "left".to_owned()])
.unwrap()
.1,
parse_args(["focus".to_owned(), "left".to_owned()]).unwrap().1,
json!({ "direction": "left" })
);
assert_eq!(
parse_args(["workspace".to_owned(), "7".to_owned()])
.unwrap()
.1,
parse_args(["workspace".to_owned(), "7".to_owned()]).unwrap().1,
json!({ "index": 7 })
);
assert_eq!(
@@ -203,10 +197,7 @@ mod tests {
#[test]
fn rejects_unknown_or_missing_arguments() {
assert_eq!(
parse_args(["exit".to_owned()]).unwrap(),
("exit".to_owned(), json!({}))
);
assert_eq!(parse_args(["exit".to_owned()]).unwrap(), ("exit".to_owned(), json!({})));
assert!(parse_args(["exit".to_owned(), "extra".to_owned()]).is_err());
assert!(parse_args(["focus".to_owned()]).is_err());
assert!(parse_args(["reload-config".to_owned()]).is_ok());