walrs
pywal but if its Fast-Minimal-Simple
git clone https://git.pi66.xyz/walrs
About | Files | Commits | Refs | License
V1.1.4 | fix some glitches and change the configuration dir to /urs/share/walrs
Author: pixel2175
Date: 2025-06-06 17:42
commit: 59b8fd46
Stat
| M | Makefile | 22 | +10 | -12 |
| M | src/create_templates.rs | 16 | +6 | -10 |
| M | src/main.rs | 4 | +2 | -2 |
| M | src/reload.rs | 4 | +2 | -2 |
| M | src/theme.rs | 4 | +2 | -2 |
| M | src/utils.rs | 14 | +10 | -4 |
Diff
diff --git a/Makefile b/Makefile
index 9bf3140..7230341 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,3 @@
-PREFIX ?= /usr
-
all: build
build:
@@ -8,22 +6,22 @@ build:
install: build
sudo install -m755 target/release/walrs /usr/bin/walrs
sudo install -m644 walrs.1 /usr/share/man/man1/
- mkdir -p ~/.cache/walrs/templates/ ~/.cache/walrs/scripts/ ~/.cache/walrs/colorschemes/
- cp -r templates/* ~/.cache/walrs/templates/
- cp -r scripts/* ~/.cache/walrs/scripts/
- cp -r colorschemes/* ~/.cache/walrs/colorschemes/
+ sudo mkdir -p /usr/share/walrs/templates/ /usr/share/walrs/scripts/ /usr/share/walrs/colorschemes/
+ sudo cp -r templates/* /usr/share/walrs/templates/
...
Show all
Show less
diff --git a/Makefile b/Makefile
index 9bf3140..7230341 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,3 @@
-PREFIX ?= /usr
-
all: build
build:
@@ -8,22 +6,22 @@ build:
install: build
sudo install -m755 target/release/walrs /usr/bin/walrs
sudo install -m644 walrs.1 /usr/share/man/man1/
- mkdir -p ~/.cache/walrs/templates/ ~/.cache/walrs/scripts/ ~/.cache/walrs/colorschemes/
- cp -r templates/* ~/.cache/walrs/templates/
- cp -r scripts/* ~/.cache/walrs/scripts/
- cp -r colorschemes/* ~/.cache/walrs/colorschemes/
+ sudo mkdir -p /usr/share/walrs/templates/ /usr/share/walrs/scripts/ /usr/share/walrs/colorschemes/
+ sudo cp -r templates/* /usr/share/walrs/templates/
...
diff --git a/Makefile b/Makefile
index 9bf3140..7230341 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,3 @@
-PREFIX ?= /usr
-
all: build
build:
@@ -8,22 +6,22 @@ build:
install: build
sudo install -m755 target/release/walrs /usr/bin/walrs
sudo install -m644 walrs.1 /usr/share/man/man1/
- mkdir -p ~/.cache/walrs/templates/ ~/.cache/walrs/scripts/ ~/.cache/walrs/colorschemes/
- cp -r templates/* ~/.cache/walrs/templates/
- cp -r scripts/* ~/.cache/walrs/scripts/
- cp -r colorschemes/* ~/.cache/walrs/colorschemes/
+ sudo mkdir -p /usr/share/walrs/templates/ /usr/share/walrs/scripts/ /usr/share/walrs/colorschemes/
+ sudo cp -r templates/* /usr/share/walrs/templates/
+ sudo cp -r scripts/* /usr/share/walrs/scripts/
+ sudo cp -r colorschemes/* /usr/share/walrs/colorschemes/
bash ./autocomplete.sh
uninstall:
- sudo rm -rf /usr/bin/walrs ~/.cache/walrs ~/.config/walrs/ /usr/share/man/man1/walrs.1
+ sudo rm -rf /usr/bin/walrs /usr/share/walrs ~/.config/walrs/ /usr/share/man/man1/walrs.1
nix:
nix build
- mkdir -p ~/.cache/walrs/templates/ ~/.cache/walrs/scripts/ ~/.cache/walrs/colorschemes/
- sudo cp ./result/bin/walrs ~/.local/bin/
- cp -r templates/* ~/.cache/walrs/templates/
- cp -r scripts/* ~/.cache/walrs/scripts/
- cp -r colorschemes/* ~/.cache/walrs/colorschemes/
+ sudo install -m755 result/bin/walrs /usr/bin/walrs
+ sudo mkdir -p /usr/share/walrs/templates/ /usr/share/walrs/scripts/ /usr/share/walrs/colorschemes/
+ sudo cp -r templates/* /usr/share/walrs/templates/
+ sudo cp -r scripts/* /usr/share/walrs/scripts/
+ sudo cp -r colorschemes/* /usr/share/walrs/colorschemes/
bash ./autocomplete.sh
clean:
cargo clean
diff --git a/src/create_templates.rs b/src/create_templates.rs
index a85af19..becf8a9 100644
--- a/src/create_templates.rs
+++ b/src/create_templates.rs
@@ -1,4 +1,4 @@
-use crate::utils::{get_cache, get_config, warning};
+use crate::utils::{get_cache, get_config, share_files, warning};
use std::{
fs::{self, create_dir_all, read_to_string, write},
process::exit,
@@ -31,11 +31,7 @@ fn fill_template(
wallpaper: &str,
send: bool,
) {
- let output_path = format!(
- "{}/wal/{}",
- get_cache(send).to_string_lossy(),
- template_name
- );
+ let output_path = get_cache(send).join("wal").join(template_name);
let alpha = colors.1;
let mut result = template
@@ -121,9 +117,9 @@ fn fill_template(
}
pub fn create_template(colors: (Vec<(u8, u8, u8)>, u8), wallpaper: &str, send: bool) {
- let system_template_path = get_cache(send).join("walrs").join("templates");
- let user_template_path = format!("{}/walrs/templates/", get_config(send).to_string_lossy());
- let cache_path = format!("{}/wal/", get_cache(send).to_string_lossy());
+ let system_template_path = share_files().join("templates");
+ let user_template_path = get_config(send).join("walrs").join("templates");
+ let cache_path = get_cache(send).join("wal");
create_dir_all(&cache_path).unwrap_or_else(|_| {
warning("Create", "can't create the cache folder", send);
exit(1)
@@ -164,7 +160,7 @@ pub fn create_template(colors: (Vec<(u8, u8, u8)>, u8), wallpaper: &str, send: b
};
// Copy template to user directory
- let user_file_path = format!("{user_template_path}{name}");
+ let user_file_path = format!("{}{name}", user_template_path.display());
let _ = write(&user_file_path, &content);
fill_template(&name, &content, &colors, wallpaper, send);
diff --git a/src/main.rs b/src/main.rs
index 87c6739..afa0e5e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -136,14 +136,14 @@ fn main() {
} else {
let colorschemes_dir = config.join("walrs").join("colorschemes");
create_dir_all(&colorschemes_dir).unwrap();
- let walrs_cache = get_cache(send);
+ let walrs_cache = share_files();
if !theme_exists(&walrs_cache) {
warning("theme", "Can't find configuration directory", send);
exit(1)
}
run(&format!(
"cp -r {}/* {}",
- walrs_cache.join("walrs").join("colorschemes").display(),
+ walrs_cache.join("colorschemes").display(),
colorschemes_dir.display()
));
set_theme(v, send);
diff --git a/src/reload.rs b/src/reload.rs
index 823e175..ce29afe 100644
--- a/src/reload.rs
+++ b/src/reload.rs
@@ -1,4 +1,4 @@
-use crate::utils::{get_cache, get_config, info, run, warning};
+use crate::utils::{get_cache, get_config, info, run, share_files, warning};
use crate::wallpaper::change_wallpaper;
use std::fs::{create_dir_all, OpenOptions};
use std::fs::{read_dir, read_to_string};
@@ -57,7 +57,7 @@ pub fn get_wallpaper(cache: &Path, send: bool) -> String {
pub fn reload(send: bool, set_wal: bool) {
let cache = get_cache(send).join("wal");
- let walrs_cache = get_cache(send).join("walrs");
+ let walrs_cache = share_files();
let file_path = cache.join("colors");
// read the colors file and load all the colors
diff --git a/src/theme.rs b/src/theme.rs
index 1b7ebcf..5d5aa55 100644
--- a/src/theme.rs
+++ b/src/theme.rs
@@ -1,7 +1,7 @@
use crate::{
create_templates::create_template,
reload::reload,
- utils::{get_cache, get_config, run, warning},
+ utils::{get_config, run, share_files, warning},
};
use std::fs::{create_dir_all, read_dir, read_to_string};
use std::path::Path;
@@ -64,7 +64,7 @@ pub fn set_theme(theme_name: String, send: bool) {
create_dir_all(&dis).unwrap();
run(&format!(
"cp -r {}/* {}",
- get_cache(send).join("walrs").join("colorschemes").display(),
+ share_files().join("colorschemes").display(),
base.join("walrs").join("colorschemes").display()
));
}
diff --git a/src/utils.rs b/src/utils.rs
index 8d61b1e..a48c45a 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -3,6 +3,10 @@ use std::path::{Path, PathBuf};
use std::process::{exit, Stdio};
use std::{fs, process::Command};
+pub fn share_files() -> PathBuf {
+ PathBuf::from("/usr").join("share").join("walrs")
+}
+
pub fn image_path(image: Option<String>, send: bool) -> String {
match image {
Some(ref v) if Path::new(v).exists() => match get_absolute_path(v) {
@@ -95,8 +99,10 @@ pub fn get_cache(send: bool) -> PathBuf {
}
pub fn get_absolute_path(path_str: &str) -> Option<String> {
- fs::canonicalize(Path::new(path_str))
- .ok()?
- .to_str()
- .map(|s| s.to_string())
+ let path = Path::new(path_str);
+ if !path.is_absolute() {
+ fs::canonicalize(path).ok()?.to_str().map(|s| s.to_string())
+ } else {
+ Some(path_str.to_string())
+ }
}