From 0763564eedc459a98e63a65f7ffee8ad37100fe7 Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Tue, 10 Sep 2019 20:57:55 -0300 Subject: use dirs crate --- src/main.rs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index b0b5b9b..fab737a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,6 +8,7 @@ extern crate libc; extern crate x11; #[macro_use] extern crate lazy_static; +extern crate dirs; pub mod safe_x11; pub mod command; @@ -16,29 +17,26 @@ pub mod event; pub mod socket; pub mod desktop; -use dotwm::DotWM; -use command::*; -use event::{Event,select_event}; -use socket::parser; - use std::collections::HashMap; use std::mem::uninitialized; - -use x11::xlib; -use x11::keysym; - use std::fs; -use std::env; use std::path::{PathBuf}; use std::io::{Read,Write}; use std::os::unix::net::UnixListener; +use x11::xlib; +use x11::keysym; + +use dotwm::DotWM; +use command::*; +use event::{Event,select_event}; +use socket::parser; + fn dotwm_dir() -> PathBuf { - let mut path = env::home_dir().unwrap(); - path.push(".config"); + let mut path = dirs::config_dir().unwrap(); path.push("dotwm"); - if !path.exists() && !path.is_dir() { + println!("Creating config directory in {:?}", path); fs::create_dir(&path).unwrap(); } @@ -55,6 +53,7 @@ fn run_autostart() { let mut autostart = dotwm_dir(); autostart.push("autostart"); + println!("Trying to exec {:?}", autostart); let found = exec_cmd(autostart, &[]).is_ok(); if !found { -- cgit v1.2.3-70-g09d2