summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/raps244
1 files changed, 22 insertions, 22 deletions
diff --git a/bin/raps2 b/bin/raps2
index c33a033..42383b9 100755
--- a/bin/raps2
+++ b/bin/raps2
@@ -25,8 +25,8 @@ my ($action, @args) = @ARGV;
sub cmd_add {
my ($name) = @_;
- my $init = get_xdg_config_home() . '/init';
- my $store = get_xdg_data_home() . "/${name}";
+ my $init = get_xdg_config_file('init');
+ my $store = get_xdg_data_file($name);
my $pass;
if (-e $store) {
@@ -68,7 +68,7 @@ sub cmd_add {
sub cmd_dump {
my ($name) = @_;
- my $store = get_xdg_data_home() . "/${name}";
+ my $store = get_xdg_data_file($name);
my $password;
my $cipher;
@@ -93,7 +93,7 @@ sub cmd_dump {
sub cmd_get {
my ($name) = @_;
- my $store = get_xdg_data_home() . "/${name}";
+ my $store = get_xdg_data_file($name);
my $password;
my $cipher;
@@ -113,7 +113,7 @@ sub cmd_get {
sub cmd_info {
my ($name) = @_;
- my $store = get_xdg_data_home() . "/${name}";
+ my $store = get_xdg_data_file($name);
if (not -e $store) {
die("No such password\n");
@@ -131,8 +131,8 @@ sub cmd_info {
}
sub create_dot_dirs {
- make_path(get_xdg_config_home());
- make_path(get_xdg_data_home());
+ make_path(get_xdg_config_file());
+ make_path(get_xdg_data_file());
return;
}
@@ -165,7 +165,7 @@ sub create_pass {
sub get_password {
my $pass;
- my $passfile = get_xdg_config_home() . '/password';
+ my $passfile = get_xdg_config_file('password');
if (not -e $passfile) {
return create_pass($passfile);
@@ -187,26 +187,26 @@ sub get_password {
return $pass;
}
-sub get_xdg_config_home {
- my $env = $ENV{'XDG_CONFIG_HOME'};
- my $home = $ENV{'HOME'};
+sub get_xdg_config_file {
+ my ($file) = @_;
+ my $env = $ENV{'XDG_CONFIG_HOME'};
+ my $home = $ENV{'HOME'};
- if ($env) {
- return "${env}/raps2";
- }
+ $file //= q{};
+ $env //= "${home}/.config";
- return "${home}/.config/raps2";
+ return "${env}/raps2/${file}";
}
-sub get_xdg_data_home {
- my $env = $ENV{'XDG_DATA_HOME'};
- my $home = $ENV{'HOME'};
+sub get_xdg_data_file {
+ my ($file) = @_;
+ my $env = $ENV{'XDG_DATA_HOME'};
+ my $home = $ENV{'HOME'};
- if ($env) {
- return "${env}/raps2";
- }
+ $file //= q{};
+ $env //= "${home}/.local/share";
- return "${home}/.local/share/raps2";
+ return "${env}/raps2/${file}";
}
sub load_state_from {