wayglance 0.3.3

A file clipboard for Wayland — watches directories for new files and shows a transient Waybar widget with drag-and-drop, open, edit, and copy actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::config::Config;
use crate::state::read_history;
use anyhow::Result;
use std::process::Command;

pub fn run(cfg: &Config) -> Result<()> {
    let history = read_history(&Config::state_file());
    let manually_scrolled = history.selected != 0;
    if let Some(st) = history.current().filter(|e| manually_scrolled || !e.is_expired(cfg.dismiss_seconds)) {
        if st.path.exists() {
            Command::new("wl-copy")
                .arg(st.path.to_string_lossy().as_ref())
                .output()?;
        }
    }
    Ok(())
}