-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add feature to get currently applied wall
- Loading branch information
1 parent
4fbc836
commit f089000
Showing
6 changed files
with
74 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use clap::ArgMatches; | ||
use colored::Colorize; | ||
|
||
use crate::functions::{get_home_dir, program_exists}; | ||
|
||
pub fn get_wallpaper(subc: &ArgMatches) { | ||
let path = subc.value_of("file").unwrap(); | ||
|
||
if !program_exists("feh") { | ||
eprintln!( | ||
"{}", | ||
"feh is not installed, install it and try again!".red() | ||
); | ||
} | ||
|
||
let fehconf = | ||
match std::fs::read_to_string(get_home_dir() + "/.fehbg") { | ||
Ok(fehconf) => fehconf, | ||
Err(_) => { | ||
eprintln!( | ||
"{}", | ||
"Couln't find feh config file.".red() | ||
); | ||
return; | ||
} | ||
}; | ||
let wallpaper_file = fehconf | ||
.split('\n') | ||
.nth(1) | ||
.unwrap() | ||
.split_whitespace() | ||
.nth_back(0) | ||
.unwrap() | ||
.replace('\'', ""); | ||
|
||
if !std::path::Path::new(&wallpaper_file).exists() { | ||
println!( | ||
"{}", | ||
"Your current wallpaper file seems missing.".red() | ||
); | ||
return; | ||
} | ||
|
||
match std::fs::copy(wallpaper_file, path) { | ||
Ok(_) => println!("{}", "Wallpaper saved to file!".green()), | ||
Err(e) => eprintln!("{}", e), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
pub mod argparse; | ||
pub mod functions; | ||
mod get; | ||
mod set; | ||
|
||
fn main() { | ||
let args = argparse::arguments().get_matches(); | ||
|
||
match args.subcommand() { | ||
Some(("set", subc)) => { | ||
set::set_wallpaper(subc).unwrap(); | ||
if let Some((name, subc)) = args.subcommand() { | ||
match name { | ||
"set" => set::set_wallpaper(subc).unwrap(), | ||
"get" => get::get_wallpaper(subc), | ||
_ => println!("Lost?? try --help"), | ||
} | ||
_ => println!("Lost?? try --help"), | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters