summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmonitor-menu.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/monitor-menu.py b/monitor-menu.py
index 710eab7..5c4ee3a 100755
--- a/monitor-menu.py
+++ b/monitor-menu.py
@@ -3,8 +3,11 @@
'''
monitor-menu.py
Usage:
- monitor-menu.py
- monitor-menu.py <profile>
+ monitor-menu.py [options]
+ monitor-menu.py [options] <profile>
+
+Options:
+ --loglevel=LOGLEVEL Set the log level [default: info]
'''
from os.path import expanduser
@@ -12,6 +15,7 @@ from os.path import expanduser
import dialog
import docopt
import json
+import logging
import subprocess
d = dialog.Dialog()
@@ -52,7 +56,9 @@ class MonitorMenu():
if monitor.get('background') is not None:
feh_cmd.append(monitor['background']);
+ logging.debug("Executing: %s", xrandr_cmd)
subprocess.run(xrandr_cmd)
+ logging.debug("Executing: %s", feh_cmd)
subprocess.run(feh_cmd)
@@ -61,6 +67,11 @@ def main(argv=None):
menu = MonitorMenu()
+ numeric_level = getattr(logging, args["--loglevel"].upper(), None)
+ if not isinstance(numeric_level, int):
+ raise ValueError(f"invalid log level: {args['--loglevel']}")
+ logging.basicConfig(level=numeric_level)
+
try:
if '<profile>' in args and args['<profile>'] is not None:
menu.run(int(args['<profile>']))