diff --git a/qasim/config.rb b/qasim/config.rb index 81dd072..b25d8f7 100644 --- a/qasim/config.rb +++ b/qasim/config.rb @@ -20,27 +20,10 @@ module Qasim def initialize - user = if ENV['USER'] then - ENV['USER'] - else - raise "Environment variable 'USER' is missing!" - end - home_dir = if ENV['HOME'] then - ENV['HOME'] - else - "/home/" + user - end + @mnt_dir = File.join ENV['HOME'], "mnt" - xdg_dir = if ENV['XDG_CONFIG_HOME'] then - ENV['XDG_CONFIG_HOME'] - else - home_dir + '/.config' - end - - @mnt_dir = File.join home_dir, "mnt" - - @config_dir = xdg_dir + '/sshfs-mapper' + @config_dir = APP_CONFIG_DIR @config_file = nil @maps = [] @initialize_enable = false diff --git a/qasim/constants.rb b/qasim/constants.rb index 0ffc237..fd21c64 100644 --- a/qasim/constants.rb +++ b/qasim/constants.rb @@ -1,6 +1,13 @@ module Qasim APP_ICON_PATH = File.join QASIM_INCLUDE_DIR, "icons" - APP_SYSCONFIG_DIR = "/etc/qasim/maps.d" APP_NAME = "Qasim" APP_VERSION = "0.1" + + APP_SYSCONFIG_DIR = "/etc/qasim/maps.d" + + APP_CONFIG_DIR = if ENV['XDG_CONFIG_HOME'] then + File.join ENV['XDG_CONFIG_HOME'], 'qasim' + else + File.join ENV['HOME'], '.config', 'qasim' + end end