def apply_changes(self, button, event): pw_dialog = ParentalPasswordDialog(self.win) if not pw_dialog.verify(): return level = self.parental_level.get_value() set_parental_level(level) set_setting('Parental-level', level) # track which parental control level people use track_data("parental-control-level-changed", { "level": level }) if level == 3.0: # If on the highest parental control, prompt user to relaunch # the browser kdialog = KanoDialog( title_text='Settings', description_text=("If any browsers are open, please relaunch " "them for this setting to take effect"), parent_window=self.win ) kdialog.run() else: # Only reboot for the lower parental controls common.need_reboot = True self.win.go_to_home()
def change_overclock_value(config, board_name=None): board = get_board_props(board_name=board_name) if not board: logger.error("Could not get overclocking settings for board") return try: values = board.CLOCKING['values'][config] except KeyError: logger.error( "kano-settings: set_overclock: SetOverclock: set_overclock(): " \ "was called with an invalid overclock setting={}" .format(config) ) return logger.info( u"set_overclock / apply_changes: " \ "config:{} arm_freq:{arm_freq} " \ "core_freq:{core_freq} " \ "sdram_freq:{sdram_freq} " \ "over_voltage:{over_voltage}" .format(config, **values) ) # Apply changes for val in values: set_config_value(val, values[val]) # Update config set_setting('Overclocking', config)
def set_gfx_driver(enabled): if enabled: set_config_value('dtoverlay', 'vc4-kms-v3d') try: try: os.makedirs(os.path.dirname(fpturbo_conf_backup_path)) except OSError as e: if e.strerror == "File exists": pass else: raise shutil.copyfile(fpturbo_conf_path, fpturbo_conf_backup_path) os.remove(fpturbo_conf_path) except Exception as e: logger.error("Error restoring fpturbo_config", exception=e) else: set_config_value('dtoverlay', None) if not os.path.exists(fpturbo_conf_path): try: shutil.copyfile(fpturbo_conf_backup_path, fpturbo_conf_path) except Exception as e: logger.error("Error restoring fpturbo_config", exception=e) end_config_transaction() set_setting('Use_GLX', enabled)
def set_parental_level(level_setting): set_setting('Parental-level', max(level_setting, 0)) # NB, we pass -1 to disable all feature_levels = [ # Low ['blacklist', 'forcesafe'], # Medium ['dns'], # High ['chromium', 'search_engines'], # Ultimate ['ultimate'] ] enabled = [] for level, features in enumerate(feature_levels): if level <= level_setting: enabled = enabled + features logger.debug("Setting parental control to level {}".format(level_setting)) set_dns_parental('ultimate' in enabled, 'forcesafe' in enabled, 'dns' in enabled) if 'ultimate' not in enabled: set_chromium_parental('chromium' in enabled) # Blacklist setup blacklist, whitelist = read_listed_sites() set_hosts_blacklist('blacklist' in enabled, 'search_engines' in enabled, blocked_sites=blacklist, allowed_sites=whitelist)
def set_to_HDMI(HDMI): if not hdmi_supported: HDMI = False # 1 analog # 2 hdmi # These are the changes we'll apply if they have changed from what they were if HDMI: amixer_cmd = amixer_set_cmd.format(value=hdmi_value) set_config_value("hdmi_ignore_edid_audio", None) set_config_value("hdmi_drive", 2) config = "HDMI" else: amixer_cmd = amixer_set_cmd.format(value=analogue_value) set_config_value("hdmi_ignore_edid_audio", 1) set_config_value("hdmi_drive", None) config = "Analogue" # Set audio path in amixer o, e, rc = run_cmd(amixer_cmd) if rc: logger.warn("error from amixer: {} {} {}".format(o, e, rc)) # trigger alsa-utils to store the path in /var/lib/alsa/asound.state o, e, rc = run_cmd(store_cmd) if rc: logger.warn("error from alsa-utils: {} {} {}".format(o, e, rc)) set_setting('Audio', config)
def change_overclock_value(config, is_pi2): try: values = CLOCK_MODES[is_pi2]['values'][config] except KeyError: logger.error( 'kano-settings: set_overclock: SetOverclock: set_overclock(): ' 'was called with an invalid overclock setting={}' .format(config) ) return logger.info( 'set_overclock / apply_changes: ' 'config:{} arm_freq:{arm_freq} ' 'core_freq:{core_freq} ' 'sdram_freq:{sdram_freq} ' 'over_voltage:{over_voltage}' .format(config, **values) ) # Apply changes for val in values: set_config_value(val, values[val]) # Update config set_setting("Overclocking", config)
def apply_changes(self, button): language = self._language_combo.get_selected_item_text() region = self._region_combo.get_selected_item_text() locale_code = Locales.get_locale_code_from_langs(language, region) set_locale(locale_code) set_setting('Locale', locale_code) common.need_reboot = True self.win.go_to_home()
def configure_cpu_monitor_animation(self, checkbox=None): is_ticked = self.cpu_monitor_checkbox.get_active() was_enabled = get_setting('LED-Speaker-anim') if is_ticked and not was_enabled: set_setting('LED-Speaker-anim', is_ticked) run_bg('kano-speakerleds cpu-monitor start', unsudo=True) elif was_enabled and not is_ticked: set_setting('LED-Speaker-anim', is_ticked) run_bg('kano-speakerleds cpu-monitor stop', unsudo=True)
def is_HDMI(): # Find the audio setting amixer_string, e, rc = run_cmd(amixer_get_cmd) if rc: logger.warn("error from amixer: {} {} {}".format(amixer_string, e, rc)) if amixer_string.find(hdmi_string) != -1: # Make sure config file is up to date if get_setting('Audio') != _("HDMI"): set_setting('Audio', _("HDMI")) return True # Default to Analogue else: # Make sure config file is up to date if get_setting('Audio') != _("Analogue"): set_setting('Audio', _("Analogue")) return False
def set_dns_parental(ultimate, safesearch, opendns): if ultimate or safesearch: # if server is running, kill it and restart it kill_server() # this is to get the most up to date whitelist restore_dns_interfaces() redirect_traffic_to_google() if ultimate: set_setting('use_sentry', 'whitelist') parse_whitelist_to_config_file(sentry_config) elif safesearch: set_setting('use_sentry', 'safesearch') make_safesearch_config_file(sentry_config, opendns) # Now set resolv.conf to point to localhost clear_dns_interfaces() redirect_traffic_to_localhost() launch_sentry_server(sentry_config) else: restore_dns_interfaces() redirect_traffic_to_google() kill_server() set_setting('use_sentry', '')
def set_to_HDMI(HDMI, force=False): ''' Set audio output to HDMI if supported by the display, otherwise set it to Analogue output. Returns 'HDMI' or 'Analogue', whichever was applied. ''' if not is_hdmi_audio_supported() and not force: HDMI = False # 1 analog # 2 hdmi # These are the changes we'll apply if they have changed from what they were if HDMI: amixer_cmd = hdmi_cmd set_config_value('hdmi_ignore_edid_audio', None) set_config_value('hdmi_drive', 2) config = _("HDMI") else: amixer_cmd = analogue_cmd set_config_value('hdmi_ignore_edid_audio', 1) set_config_value('hdmi_drive', None) config = _("Analogue") end_config_transaction() # Set audio path in amixer o, e, rc = run_cmd(amixer_cmd) if rc: logger.warn("error from amixer: {} {} {}".format(o, e, rc)) # trigger alsa-store to store the path in /var/lib/alsa/asound.state o, e, rc = run_cmd(store_cmd) if rc: logger.warn("error from alsa-store: {} {} {}".format(o, e, rc)) set_setting('Audio', config) return config
def update_config(self): logger.info('set_keyboard.update_config {} {} {} {} {} {}'.format( self.selected_continent_index, self.selected_country_index, self.selected_variant_index, self.selected_continent_hr, self.selected_country_hr, self.selected_variant_hr )) # Add new configurations to config file. set_setting("Keyboard-continent-index", self.selected_continent_index) set_setting("Keyboard-country-index", self.selected_country_index) set_setting("Keyboard-variant-index", self.selected_variant_index) set_setting("Keyboard-continent-human", self.selected_continent_hr) set_setting("Keyboard-country-human", self.selected_country_hr) set_setting("Keyboard-variant-human", self.selected_variant_hr)
def update_settings_keyboard_conf(continent_index, country_index, variant_index, continent, country, variant): logger.info('set_keyboard.update_config {} {} {} {} {} {}'.format( continent_index, country_index, variant_index, continent, country, variant )) # Add new configurations to config file. set_setting("Keyboard-continent-index", continent_index) set_setting("Keyboard-country-index", country_index) set_setting("Keyboard-variant-index", variant_index) set_setting("Keyboard-continent-human", continent) set_setting("Keyboard-country-human", country) set_setting("Keyboard-variant-human", variant)
def update_config(self): '''Add new configurations to config file. ''' selected = self.get_selected() if selected: set_setting('Wallpaper', selected)
def update_config(self): '''Add new configurations to config file. ''' selected = self.get_selected() if selected: set_setting("Wallpaper", selected)
def update_settings_keyboard_conf(continent_index, country_index, variant_index, continent, country, variant): logger.info('set_keyboard.update_config {} {} {} {} {} {}'.format( continent_index, country_index, variant_index, continent, country, variant)) # Add new configurations to config file. set_setting("Keyboard-continent-index", continent_index) set_setting("Keyboard-country-index", country_index) set_setting("Keyboard-variant-index", variant_index) set_setting("Keyboard-continent-human", continent) set_setting("Keyboard-country-human", country) set_setting("Keyboard-variant-human", variant)