Skip to content
This repository has been archived by the owner on Dec 4, 2020. It is now read-only.

Commit

Permalink
Refactor chromium code
Browse files Browse the repository at this point in the history
  • Loading branch information
bennuttall committed Nov 20, 2018
1 parent 4f665ef commit edee315
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions chromium.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
import json

prefs_file = '/home/pi/.config/chromium/Default/Preferences'
master_prefs_file = '/usr/lib/chromium-browser/master_preferences'
global_prefs_file = '/usr/lib/chromium-browser/master_preferences'
prefs = {}

try:
with open(prefs_file, 'r') as f:
location = "local"
prefs = json.load(f)
except FileNotFoundError:
#print("Chromium settings not found - please launch Chromium once before running this script")
print("User Chromium settings not found - Modifying master settings")
with open(master_prefs_file, 'r') as f:
prefs_file = global_prefs_file
with open(prefs_file, 'r') as f:
prefs = json.load(f)
location = "master"

if prefs:
prefs['session'] = {
'restore_on_startup': 4,
'startup_urls': ['http://rpf.io/ap-msl-guide']
}
if location == "master":
with open(master_prefs_file, 'w') as f:
json.dump(prefs,f)
elif location == "local":
with open(prefs_file, 'w') as f:
json.dump(prefs,f)

with open(prefs_file, 'w') as f:
json.dump(prefs, f)

0 comments on commit edee315

Please sign in to comment.