Pi66

Home | Repos | About | Blog | Gaza

pind
Simple Rust hotkey daemon.
git clone https://git.pi66.xyz/pind

About | Files | Commits | Refs | License


fix: support add support for user paths in config file.

Author: pi66
Date: 2025-08-31 23:15
commit: 686ce573

Stat

M src/main.rs 7 +4 -3

Diff

diff --git a/src/main.rs b/src/main.rs
index 86d0bcf..58beb9e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -26,10 +26,11 @@

use evdev::{AttributeSet, Device, KeyCode, enumerate}; -use std::{env::{var,args},fs::read_to_string, path::PathBuf, process::{exit,Command, Stdio}, sync::{Arc, OnceLock}, thread}; +use std::{env::{var,args},fs::{read_to_string,canonicalize}, path::PathBuf, process::{exit,Command, Stdio}, sync::{Arc, OnceLock}, thread};

const DELAY :u64 = 25; // 25ms -const CONFIG :&str = "/etc/pind/pindrc"; +const CONFIG :&str = "/etc/pind/pindrc"; // You can use ~/ for user path + // like ~/.config/pind/pindrc static BINDINGS: OnceLock<Arc<Vec<(AttributeSet<KeyCode>, String)>>> = OnceLock::new();

fn get_bindings() -> Arc<Vec<(AttributeSet<KeyCode>, String)>> @@ -138,7 +139,7 @@ fn keyboards() -> Vec<PathBuf>

...
Show all
diff --git a/src/main.rs b/src/main.rs
index 86d0bcf..58beb9e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -26,10 +26,11 @@

use evdev::{AttributeSet, Device, KeyCode, enumerate}; -use std::{env::{var,args},fs::read_to_string, path::PathBuf, process::{exit,Command, Stdio}, sync::{Arc, OnceLock}, thread}; +use std::{env::{var,args},fs::{read_to_string,canonicalize}, path::PathBuf, process::{exit,Command, Stdio}, sync::{Arc, OnceLock}, thread};

const DELAY :u64 = 25; // 25ms -const CONFIG :&str = "/etc/pind/pindrc"; +const CONFIG :&str = "/etc/pind/pindrc"; // You can use ~/ for user path + // like ~/.config/pind/pindrc static BINDINGS: OnceLock<Arc<Vec<(AttributeSet<KeyCode>, String)>>> = OnceLock::new();

fn get_bindings() -> Arc<Vec<(AttributeSet<KeyCode>, String)>> @@ -138,7 +139,7 @@ fn keyboards() -> Vec<PathBuf>

fn load_config(config: &str) -> Vec<(AttributeSet<KeyCode>, String)> { - let content = read_to_string(config) + let content = read_to_string(canonicalize(PathBuf::from(config.replace("~",&var("HOME").unwrap_or_default()))).unwrap_or_else(|e|{error("config",&e.to_string())})) .unwrap_or_else(|e| error("Config file read failed", &e.to_string()));

 content.lines()

// Created by Pi66

// Copyright ©Pi66 2026