about summary refs log tree commit diff stats
path: root/leo.pl
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-08-31 17:06:03 +0530
committerAndinus <andinus@nand.sh>2020-08-31 17:06:03 +0530
commit4648948ddb3cc0a3f046df50cccfe74a2da2e6d1 (patch)
tree5feb12c642cc8a9dbe1e46b5da29fcb5c1aa7d0d /leo.pl
parentc5295e12c7d1ec71f234dda8a69a0093157b0e64 (diff)
downloadleo-4648948ddb3cc0a3f046df50cccfe74a2da2e6d1.tar.gz
Move configuration to a config file
I'll switch to some other config format later, this format is not safe
at all!
Diffstat (limited to 'leo.pl')
-rwxr-xr-xleo.pl31
1 files changed, 9 insertions, 22 deletions
diff --git a/leo.pl b/leo.pl
index 39dcc9e..96bc921 100755
--- a/leo.pl
+++ b/leo.pl
@@ -19,34 +19,21 @@ GetOptions(
     qw{ verbose encrypt sign delete help }
 ) or die "Error in command line arguments\n";
 
-
-my $gpg_fingerprint = "D9AE4AEEE1F1B3598E81D9DFB67D55D482A799FD";
 my $ymd = ymd(); # YYYY-MM-DD.
 my $backup_dir = "/tmp/backup/$ymd";
 
 path($backup_dir)->mkpath; # Create backup directory.
 my $prof;
 
-my %profile = (
-    journal => [qw( documents/andinus.org.gpg
-                    documents/archive.org.gpg )],
-    emacs   => [qw( .emacs.d .elfeed .org-timestamps )],
-    config  => [qw( .config .kshrc .kshrc.d .tmux.conf .xsession .remind
-                    .screenlayout .mg .mbsyncrc .fehbg .profile .plan
-                    .authinfo.gpg .Xresources )],
-);
+# Config file for leo.
+my $config_file = $ENV{XDG_CONFIG_HOME} || "$ENV{HOME}/.config";
+$config_file .= "/leo.pl";
 
-# Add more directories to %profile.
-foreach my $tmp_prof (qw( emails music projects documents videos .ssh
-                          downloads pictures .password-store .mozilla
-                          fortunes )) {
-    $profile{$tmp_prof} = [$tmp_prof];
-}
+require "$config_file";
 
-# Aliases.
-$profile{ssh} = $profile{".ssh"};
-$profile{pass} = $profile{".password-store"};
-$profile{mozilla} = $profile{".mozilla"};
+my %profile = get_profile();
+my $gpg_fingerprint = get_gpg_fingerprint();
+my $gpg_bin = get_gpg_bin();
 
 HelpMessage() and exit 0 if scalar @ARGV == 0 or $options{help};
 foreach my $arg ( @ARGV ) {
@@ -100,7 +87,7 @@ sub encrypt_sign() {
     say "\nEncrypt/Sign: $file";
     warn "[WARN] $file.gpg exists, might overwrite.\n" if -e "$file.gpg";
 
-    run3 ["gpg2", "--yes", "-o", "$file.gpg", @options, $file];
+    run3 [$gpg_bin, "--yes", "-o", "$file.gpg", @options, $file];
 
     $? # We assume non-zero is an error.
         ? die "Encrypt/Sign failed :: $?\n"
@@ -131,7 +118,7 @@ Options:
     --sign
         Sign files with $gpg_fingerprint
     --delete
-        Delete the tar file after running gpg2
+        Delete the tar file after running $gpg_bin
     --verbose
     --help};
 }