summaryrefslogtreecommitdiff
path: root/uwidgets/uwidgets-runner
blob: 3efeac56eb2290120391d7a8a87efcc4e336c623 (plain)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 
#!/usr/bin/env python3 import os import configparser widgets=[] widgets_dir=os.path.expanduser('~/.local/share/unity/widgets') if os.path.exists(widgets_dir): for widget in [f.path for f in os.scandir(widgets_dir) if f.is_dir() and os.path.exists(os.path.join(f, 'widget.ini'))]: try: os.chdir(widget) config = configparser.ConfigParser() config.read(os.path.join(widget, 'widget.ini')) if config.get('widget', 'enabled') == 'true': os.popen(config.get('widget', 'exec')) widgets.append(os.path.basename(widget)) except (KeyError, configparser.NoSectionError, configparser.NoOptionError) as e: print(f'uwidget-runner: error occurred when attempting to run {widget}:\n {e}') if len(widgets) == 0: print("No widgets found.") else: print("Loaded:", ' '.join(widgets))