diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2026-02-28 10:13:04 +0200 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2026-02-28 10:13:04 +0200 |
| commit | fe79d85e1767cd9095b1139aa22460ca2d1dde8c (patch) | |
| tree | 4fe39f4024478f8b6fdf7c4c4b0029235efb8bc2 | |
| parent | 6d0c06793dd933ea5156090a65e4f9117d9ccc8e (diff) | |
| parent | 60305617a34570eb0b4118a0216278e4d3871704 (diff) | |
Merge branch 'trash'
| -rw-r--r-- | README.txt | 4 | ||||
| -rw-r--r-- | config.h.in | 12 | ||||
| -rw-r--r-- | config_cmd.h.in | 8 | ||||
| -rw-r--r-- | config_key.h.in | 3 | ||||
| -rw-r--r-- | dfm.c | 10 |
5 files changed, 37 insertions, 0 deletions
@@ -160,6 +160,10 @@ environment, default values are derived from the config.h.in file. - DFM_OPENER (Opener script to use when opening files. This could be xdg-open or a custom script (see the examples/ directory)) +- DFM_TRASH (Program to use when trashing files.) + +- DFM_TRASH_DIR (Path to trash directory.) + --[CD On Exit]------------------------------------------------------------------ diff --git a/config.h.in b/config.h.in index f81ba94..eb2470a 100644 --- a/config.h.in +++ b/config.h.in @@ -34,6 +34,18 @@ #define DFM_BOOKMARK_9 "" // +// Default trash utility. +// Can be set at runtime via environment: \$DFM_TRASH +// +#define DFM_TRASH "\$DFM_TRASH" + +// +// Default trash directory. +// Can be set at runtime via environment: \$DFM_TRASH_DIR +// +#define DFM_TRASH_DIR "" + +// // Default sort mode. // See: fm_sort_fn() // diff --git a/config_cmd.h.in b/config_cmd.h.in index 1864955..5891957 100644 --- a/config_cmd.h.in +++ b/config_cmd.h.in @@ -146,3 +146,11 @@ FM_CMD(cmd_mkdir, .config = CMD_MUT, ) +FM_CMD(cmd_trash, + .prompt = CUT(":"), + .left = get_env("DFM_TRASH", DFM_TRASH), + .right = CUT(" %m"), + .enter = fm_cmd_run, + .config = CMD_MARK_DIR | CMD_MUT | CMD_EXEC_MARK, +) + diff --git a/config_key.h.in b/config_key.h.in index 392dfac..e503a30 100644 --- a/config_key.h.in +++ b/config_key.h.in @@ -79,6 +79,9 @@ static inline void (*fm_key(u32 cp))(struct fm *) case 'q': return act_quit; case 'Q': return act_quit_print_pwd; + case 't': return cmd_trash; + case 'T': return act_cd_trash; + case 'o': return cmd_exec_open; case 'O': return cmd_exec_open_bg; @@ -97,6 +97,8 @@ static const char DFM_HELP[] = "DFM_OPENER program used to open files (overridden by -o)\n" "DFM_BOOKMARK_[0-9] bookmark directories\n" "DFM_COPYER program used to copy PWD and file contents.\n" + "DFM_TRASH program used to trash files.\n" + "DFM_TRASH_DIR path to trash directory.\n" ; enum fm_opt { @@ -2645,6 +2647,14 @@ act_cd_mark_directory(struct fm *p) } static inline void +act_cd_trash(struct fm *p) +{ + cut e = get_env("DFM_TRASH_DIR", DFM_TRASH_DIR); + if (e.l) fm_path_cd(p, e.d, e.l); + else fm_draw_err(p, S("DFM_TRASH_DIR not set"), 0); +} + +static inline void act_cd_last(struct fm *p) { fm_path_cd(p, p->ppwd.m, p->ppwd.l); |