mirror of
https://github.com/nikdoof/oblogout.git
synced 2025-12-17 20:59:23 +00:00
Allows for local config file in ~/.config, also enable info logging on oblogout command
This commit is contained in:
@@ -41,6 +41,7 @@ def main(argv = None):
|
|||||||
logout = logging.StreamHandler(sys.stdout)
|
logout = logging.StreamHandler(sys.stdout)
|
||||||
logout.setFormatter(logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s"))
|
logout.setFormatter(logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s"))
|
||||||
logger.addHandler(logout)
|
logger.addHandler(logout)
|
||||||
|
logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
verbose = None
|
verbose = None
|
||||||
config = None
|
config = None
|
||||||
@@ -72,21 +73,23 @@ def main(argv = None):
|
|||||||
local_mode = True
|
local_mode = True
|
||||||
|
|
||||||
if not config:
|
if not config:
|
||||||
if not local_mode:
|
if local_mode:
|
||||||
config = '/etc/oblogout.conf'
|
|
||||||
else:
|
|
||||||
config = 'data/oblogout.conf'
|
config = 'data/oblogout.conf'
|
||||||
|
elif os.path.isfile('%s/.config/oblogout.conf' % os.getenv("HOME")):
|
||||||
|
config = '%s/.config/oblogout.conf' % os.getenv("HOME")
|
||||||
|
else:
|
||||||
|
config = '/etc/oblogout.conf'
|
||||||
|
|
||||||
# Check config in local path, if it exists pass it on
|
# Check config in local path, if it exists pass it on
|
||||||
if not os.path.exists(config):
|
if not os.path.isfile(config):
|
||||||
logger.error("Invalid config file: %s" % config)
|
logger.error("Invalid config file: %s" % config)
|
||||||
return 1
|
return 1
|
||||||
|
else:
|
||||||
|
logger.info("Using config file %s" % config)
|
||||||
|
|
||||||
# If debug mode is enabled, output debug messages
|
# If debug mode is enabled, output debug messages
|
||||||
if verbose:
|
if verbose:
|
||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
else:
|
|
||||||
logger.setLevel(logging.INFO)
|
|
||||||
|
|
||||||
# Start the application
|
# Start the application
|
||||||
app = OpenboxLogout(config, local_mode)
|
app = OpenboxLogout(config, local_mode)
|
||||||
|
|||||||
Reference in New Issue
Block a user