Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/buskill_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1416,9 +1416,7 @@ def build_config(self, config):
importlib.reload( kivy.config )

Config.read( self.bk.CONF_FILE )
Config.setdefaults('buskill', {
'buskill_trigger': 'lock-screen',
})
Config.setdefaults('buskill', self.bk.DEFAULT_CONF) # For more config option in future, only have to update the DEFAULT_CONF value in __init__.py

# TODO: don't hard-code this, pull it from kivy/config.py
# * https://stackoverflow.com/questions/78216476/how-to-get-kivy-to-set-its-defaults-in-the-config-at-runtime
Expand Down
16 changes: 16 additions & 0 deletions src/packages/buskill/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,12 @@ def __init__(self):
# path to buskill's config file
self.CONF_FILE = os.path.join( self.DATA_DIR, "config.ini" )

# Setting up universal default value for both GUI and CLI config options
self.DEFAULT_CONF = {
'buskill_trigger': 'lock-screen',
'persistent_log': self.PERSISTENT_LOG
}

# does the config file exist already?
if not os.path.exists( self.CONF_FILE ):
# the config file doesn't exist yet; create it
Expand All @@ -431,6 +437,16 @@ def __init__(self):
with open( self.CONF_FILE, 'w' ) as fd:
fd.write( contents )

# For CLI and GUI config option Initialising it when the config.ini file is created
# So when ever any new config option is to be added only have to add it to self.DEFAULT_CONF dict
# This will only run once when user either runs CLI or GUI
# The users who run the CLI can change the file manually and still the user change persist
config = configparser.ConfigParser()
config.read( self.CONF_FILE )
config['buskill'] = self.DEFAULT_CONF
with open(self.CONF_FILE, 'w') as fd:
config.write(fd)

msg = "DEBUG: CACHE_DIR:|" +str(self.CACHE_DIR)+ "|\n"
msg = "DEBUG: CONF_FILE:|" +str(self.CONF_FILE)+ "|\n"
print( msg ); logger.debug( msg )
Expand Down
13 changes: 13 additions & 0 deletions src/packages/buskill/settings_buskill.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@
"confirmation": ["", "This selection may cause data loss! Are you sure you want to continue?\n\nThe 'soft-shutdown' trigger will immediately cause your computer to shutdown. This could cause you to lose work if, for example, you're writing an email or typing a text document.\n\nAre you sure you want to select the 'soft-shutdown' trigger, despite the risk of data loss?" ],
"options_icons": ["\ue1bf","\ue62a"]
},
{
"icon": "\ue873",
"type": "complex-options",
"title": "Persistent Logging",
"desc": "Do you want to store the log file persistently (keeping the data after your computer reboots)?",
"section": "buskill",
"key": "persistent_log",
"options": ["True","False"],
"options_human": ["True","False"],
"options_long": ["Log file will be not deleted after your system restarts","Log file will be deleted once you restart the computer"],
"confirmation": ["Please restart the app so the changes can be implimented","Please restart the app so the changes can be implimented"],
"options_icons": ["\ue161","\ue5cd"]
},
{
"type": "title",
"title": "Look & Feel"
Expand Down
Loading