fixed config creation

This commit is contained in:
Andrei Stoica 2020-02-02 13:55:03 -05:00
parent 2f5be434b3
commit f82ffc3163
2 changed files with 3 additions and 3 deletions

View File

@ -8,6 +8,7 @@ Currently tested on:
- Ubuntu MATE 18.04 - Ubuntu MATE 18.04
### Depenancies ### Depenancies
- [python3](https://docs.python.org/3/)
- [pyqt5](https://www.riverbankcomputing.com/software/pyqt/intro) - [pyqt5](https://www.riverbankcomputing.com/software/pyqt/intro)
- [pynotifier](https://github.com/YuriyLisovskiy/pynotifier) - [pynotifier](https://github.com/YuriyLisovskiy/pynotifier)

View File

@ -1,7 +1,7 @@
import sys import sys
import threading import threading
import configparser import configparser
from os import environ, path from os import environ, path, makedirs
from time import sleep from time import sleep
from PyQt5.QtGui import * from PyQt5.QtGui import *
from PyQt5.QtWidgets import * from PyQt5.QtWidgets import *
@ -14,13 +14,12 @@ config_folder = path.join(path.join(environ['HOME'], ".config/pomo/"))
config_file = path.join(config_folder, "pomo.ini") config_file = path.join(config_folder, "pomo.ini")
config = configparser.ConfigParser(strict=False) config = configparser.ConfigParser(strict=False)
if not path.exists(config_file): if not path.exists(config_file):
config['DEFAULT'] = {'pomo_time' : 25, config['DEFAULT'] = {'pomo_time' : 25,
'break_time' : 5, 'break_time' : 5,
'long_break' : 4, 'long_break' : 4,
'long_break_time' : 30} 'long_break_time' : 30}
config_folder.mkdir(parents=True) makedirs(config_folder)
with open(config_file, 'w') as f: with open(config_file, 'w') as f:
config.write(f) config.write(f)
else: else: