Skip to content

Commit

Permalink
TRASH_D_DIR environment variable
Browse files Browse the repository at this point in the history
Added support for setting the trash directory via the environment
variable TRASH_D_DIR.

Related to #2
  • Loading branch information
rushsteve1 committed Sep 3, 2021
1 parent 11bf854 commit 54d65ae
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions source/trash.d
Expand Up @@ -571,16 +571,19 @@ int parseOpts(ref string[] args) {
return -1;
}

// Get the correct XDG directory
string data_home = environment.get("XDG_DATA_HOME");
if (data_home is null) {
data_home = expandTilde("~/.local/share");
OPTS.trash_dir = environment.get("TRASH_D_DIR");
if (OPTS.trash_dir is null) {
// Get the correct XDG directory
string data_home = environment.get("XDG_DATA_HOME");
if (data_home is null) {
data_home = expandTilde("~/.local/share");
} else {
// Set the trash dir option
OPTS.trash_dir = data_home.chainPath("Trash").asAbsolutePath().array();
log("trash directory: %s", OPTS.trash_dir);
}
}

// Set the trash dir option
OPTS.trash_dir = data_home.chainPath("Trash").asAbsolutePath().array();
log("trash directory: %s", OPTS.trash_dir);

// This function is a little special because it has a unique return code
// -1 means "stop program and with status code 0"
return 0;
Expand Down

0 comments on commit 54d65ae

Please sign in to comment.