Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 171 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pacfetch"
version = "1.0.0"
version = "1.1.0"
edition = "2024"
authors = ["camtisocial thompsonca99@gmail.com"]
license = "GPL-3.0"
Expand Down Expand Up @@ -28,3 +28,5 @@ nix = { version = "0.29", features = ["fs"] }
reqwest = { version = "0.12", features = ["blocking"] }
serde = { version = "1", features = ["derive"] }
toml = "0.8"
onefetch-image = "2"
image = { version = "0.25", default-features = false, features = ["png", "jpeg", "webp"] }
3 changes: 3 additions & 0 deletions default_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
ascii = "PACMAN_DEFAULT"
ascii_color = "yellow"

# Image takes precedence when set
# image = "~/.config/pacfetch/logo.png"

# Available stats: installed, upgradable, last_update, download_size, installed_size,
# net_upgrade_size, orphaned_packages, cache_size, disk, mirror_url, mirror_health
stats = [
Expand Down
4 changes: 4 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ pub struct DisplayConfig {
#[serde(default = "default_ascii_color")]
pub ascii_color: String,

#[serde(default)]
pub image: String,

#[serde(default)]
pub glyph: GlyphConfig,

Expand Down Expand Up @@ -246,6 +249,7 @@ impl Default for DisplayConfig {
stats: default_stats(),
ascii: default_ascii(),
ascii_color: default_ascii_color(),
image: String::new(),
glyph: GlyphConfig::default(),
colors: ColorsConfig::default(),
labels: HashMap::new(),
Expand Down
14 changes: 2 additions & 12 deletions src/ui/ascii.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::fs;
use std::path::{Path, PathBuf};
use std::path::Path;

use crate::util;

Expand Down Expand Up @@ -48,17 +48,7 @@ fn normalize_width(lines: Vec<String>) -> Vec<String> {
}

fn load_from_file(path: &str) -> Vec<String> {
let expanded = if path.starts_with('~') {
// When running via sudo, use the original user's home
let home = if let Ok(sudo_user) = std::env::var("SUDO_USER") {
PathBuf::from(format!("/home/{}", sudo_user))
} else {
dirs::home_dir().unwrap_or_default()
};
path.replacen('~', &home.to_string_lossy(), 1)
} else {
path.to_string()
};
let expanded = crate::util::expand_path(path);

let path = Path::new(&expanded);

Expand Down
Loading