Remove WalkDir

This commit is contained in:
Ottatop 2023-09-20 17:20:48 -05:00
parent 4cffb28e25
commit c06cb5b776
5 changed files with 26 additions and 13 deletions

View file

@ -32,7 +32,6 @@ clap = { version = "4.4.2", features = ["derive"] }
xkbcommon = "0.6.0"
xdg = "2.5.2"
lazy_static = "1.4.0"
walkdir = "2.4.0"
sysinfo = "0.29.10"

View file

@ -18,6 +18,11 @@ use crate::{
tag::TagId,
};
use self::api::msg::{
window_rules::{WindowRule, WindowRuleCondition},
CallbackId,
};
#[derive(serde::Deserialize, Debug)]
pub struct Metaconfig {
pub command: String,
@ -107,6 +112,12 @@ pub enum Key {
Escape = keysyms::KEY_Escape,
}
#[derive(Default, Debug)]
pub struct Config {
window_rules: Vec<(WindowRuleCondition, WindowRule)>,
output_callback_ids: Vec<CallbackId>,
}
fn parse(config_dir: &Path) -> anyhow::Result<Metaconfig> {
let config_dir = config_dir.join("metaconfig.toml");

View file

@ -47,7 +47,6 @@ use smithay::reexports::calloop::{
self, channel::Sender, generic::Generic, EventSource, Interest, Mode, PostAction,
};
use sysinfo::{ProcessRefreshKind, RefreshKind, SystemExt};
use walkdir::WalkDir;
use self::msg::{Msg, OutgoingMsg};
@ -93,6 +92,8 @@ impl PinnacleSocketSource {
/// Create a loop source that listens for connections to the provided socket_dir.
/// This will also set PINNACLE_SOCKET for use in API implementations.
pub fn new(sender: Sender<Msg>, socket_dir: &Path) -> anyhow::Result<Self> {
tracing::debug!("Creating socket source for dir {socket_dir:?}");
let system = sysinfo::System::new_with_specifics(
RefreshKind::new().with_processes(ProcessRefreshKind::new()),
);
@ -128,15 +129,17 @@ impl PinnacleSocketSource {
}
} else {
// If there are, remove them all
for entry in WalkDir::new(socket_dir)
.contents_first(true)
.into_iter()
.filter_entry(|entry| entry.file_name().to_string_lossy().starts_with(SOCKET_NAME))
.filter_map(|e| e.ok())
for file in std::fs::read_dir(socket_dir)?
.filter_map(|entry| entry.ok())
.filter(|entry| entry.file_name().to_string_lossy().starts_with(SOCKET_NAME))
{
std::fs::remove_file(entry.path()).context(format!(
tracing::debug!(
"trying to remove socket at {}",
file.path().to_string_lossy()
);
std::fs::remove_file(file.path()).context(format!(
"Failed to remove old socket at {}",
entry.path().to_string_lossy()
file.path().to_string_lossy()
))?;
}
}

View file

@ -230,8 +230,6 @@ impl State {
},
);
self.move_mode = move_mode;
match action {
Some(KeyAction::CallCallback(callback_id)) => {
if let Some(stream) = self.api_state.stream.as_ref() {

View file

@ -87,15 +87,18 @@ impl Backend {
/// The main state of the application.
pub struct State {
/// Which backend is currently running
pub backend: Backend,
/// A loop signal used to stop the compositor
pub loop_signal: LoopSignal,
/// A handle to the event loop
pub loop_handle: LoopHandle<'static, CalloopData>,
pub display_handle: DisplayHandle,
pub clock: Clock<Monotonic>,
pub space: Space<WindowElement>,
pub move_mode: bool,
/// The name of the Wayland socket
pub socket_name: String,
pub seat: Seat<State>,
@ -321,7 +324,6 @@ impl State {
dnd_icon: None,
move_mode: false,
socket_name: socket_name.to_string_lossy().to_string(),
popup_manager: PopupManager::default(),