Add -c / --config argument to eww daemon (#104)

This commit is contained in:
undefinedDarkness 2021-02-03 00:29:30 +05:30 committed by GitHub
parent ebb8fc065d
commit 66bfe25d87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 5 deletions

View file

@ -82,7 +82,7 @@ fn main() {
}
}
opts::Action::Daemon => {
opts::Action::Daemon { config } => {
// make sure that there isn't already a Eww daemon running.
if check_server_running(&*IPC_SOCKET_PATH) {
eprintln!("Eww server already running.");
@ -90,8 +90,10 @@ fn main() {
} else {
log::info!("Initializing Eww server.");
let _ = std::fs::remove_file(&*crate::IPC_SOCKET_PATH);
println!("Run `eww logs` to see any errors, warnings or information while editing your configuration.");
server::initialize_server()?;
server::initialize_server(config)?;
}
}
}

View file

@ -29,7 +29,11 @@ struct RawOpt {
pub enum Action {
/// Start the Eww daemon.
#[structopt(name = "daemon")]
Daemon,
Daemon {
/// Custom Config Path
#[structopt(short, long)]
config: Option<std::path::PathBuf>,
},
#[structopt(flatten)]
ClientOnly(ActionClientOnly),

View file

@ -8,7 +8,7 @@ use std::{
};
use tokio::sync::mpsc::*;
pub fn initialize_server() -> Result<()> {
pub fn initialize_server(config_dir_override: Option<std::path::PathBuf>) -> Result<()> {
do_detach()?;
simple_signal::set_handler(&[simple_signal::Signal::Int, simple_signal::Signal::Term], move |_| {
@ -20,7 +20,8 @@ pub fn initialize_server() -> Result<()> {
});
let (ui_send, mut ui_recv) = tokio::sync::mpsc::unbounded_channel();
let config_file_path = crate::CONFIG_DIR.join("eww.xml");
let config_file_path = config_dir_override.unwrap_or(crate::CONFIG_DIR.join("eww.xml"));
let config_dir = config_file_path
.parent()
.context("config file did not have a parent?!")?