Esempio n. 1
0
def get_screen_log():
    """Get display information using kano-settings display functions.

    Returns:
        dict: An aggregate of display characteristics
    """

    try:
        from kano_settings.system.display import get_edid, get_edid_name, get_status, \
            list_supported_modes, get_optimal_resolution_mode, override_models

        edid = get_edid()
        model = get_edid_name(use_cached=False)

        override_models(edid, model)

        status = get_status()
        supported = list_supported_modes(use_cached=False)
        optimal = get_optimal_resolution_mode(edid, supported)

        log_data = {
            'model': model,
            'status': status,
            'edid': edid,
            'supported': supported,
            'optimal': optimal,
        }
        log = json.dumps(log_data, sort_keys=True, indent=4)
    except:
        return traceback.format_exc()

    return log
Esempio n. 2
0
def get_screen_log():
    """Get display information using kano-settings display functions.

    Returns:
        dict: An aggregate of display characteristics
    """

    try:
        from kano_settings.system.display import get_edid, get_edid_name, get_status, \
            list_supported_modes, get_optimal_resolution_mode, override_models

        edid = get_edid()
        model = get_edid_name(use_cached=False)

        override_models(edid, model)

        status = get_status()
        supported = list_supported_modes(use_cached=False)
        optimal = get_optimal_resolution_mode(edid, supported)

        log_data = {
            'model': model,
            'status': status,
            'edid': edid,
            'supported': supported,
            'optimal': optimal,
        }
        log = json.dumps(log_data, sort_keys=True, indent=4)
    except:
        return traceback.format_exc()

    return log
Esempio n. 3
0
        def _trigger_tracking_event(self):
            """ Generate a tracker event with some hardware settings.

                This will send a track_date event called 'user-settings'
                with the audio setting, parental lock level and display
                configuration.
            """

            track_data('user-settings', {
                'audio': 'hdmi' if is_HDMI() else 'analog',
                'parental-lock-level': get_setting('Parental-level'),
                'display': get_status()
            })
Esempio n. 4
0
        def _trigger_tracking_event(self):
            """ Generate a tracker event with some hardware settings.

                This will send a track_date event called 'user-settings'
                with the audio setting, parental lock level and display
                configuration.
            """

            track_data('user-settings', {
                'audio': 'hdmi' if is_HDMI() else 'analog',
                'parental-lock-level': get_setting('Parental-level'),
                'display': get_status()
            })
Esempio n. 5
0
def init():
    global size, width, height, padding, boundaries, passSize

    # Get containing terminal window and set it to maximised
    pid = os.getpid()
    win = _get_window_by_child_pid(pid)
    gdk_window_settings(win, maximized=True)
    time.sleep(0.1)
    available_size = (width, height) = console.getTerminalSize()

    try:
        # Check for screen resolution
        resolution = get_status()['resolution']
        h = int(resolution.split('x')[1])
        # Select a set of sizes depending on the screen resolution
        if h > 1024:
            chosen_size = config.game_sizes_big[parser.args.board]
        if h <= 1024 and h > 720:
            chosen_size = config.game_sizes_medium[parser.args.board]
        else:
            chosen_size = config.game_sizes_small[parser.args.board]
        passSize = parser.args.board
    except:
        print "Can't find board size: %s" % (parser.args.board)
        __main__.exit()
        exit()

    # Calculate width
    if chosen_size[0] > available_size[0] / 2:
        width = (available_size[0] / 2) - 3
    else:
        width = chosen_size[0]
    # Calculate height
    if chosen_size[1] > available_size[1]:
        height = available_size[1]
    else:
        height = chosen_size[1]

    size = (width, height)

    padding_x = int(math.floor(available_size[0] - width) / 4)
    padding_y = int(math.floor(available_size[1] - height) / 2)

    padding = (padding_y, padding_x, padding_y, padding_x)

    boundaries = {
        "bottom": int(math.floor(height / 2)),
        "left": int(math.floor(-width / 2)),
        "right": int(math.floor(width / 2)),
        "top": int(math.floor(-height / 2)),
    }
Esempio n. 6
0
def init():
    global size, width, height, padding, boundaries, passSize

    # Get containing terminal window and set it to maximised
    pid = os.getpid()
    win = _get_window_by_child_pid(pid)
    gdk_window_settings(win, maximized=True)
    time.sleep(0.1)
    available_size = (width, height) = console.getTerminalSize()

    try:
        # Check for screen resolution
        resolution = get_status()['resolution']
        h = int(resolution.split('x')[1])
        # Select a set of sizes depending on the screen resolution
        if h > 1024:
            chosen_size = config.game_sizes_big[parser.args.board]
        if h <= 1024 and h > 720:
            chosen_size = config.game_sizes_medium[parser.args.board]
        else:
            chosen_size = config.game_sizes_small[parser.args.board]
        passSize = parser.args.board
    except:
        print "Can't find board size: %s" % (parser.args.board)
        __main__.exit()

    # Calculate width
    if chosen_size[0] > available_size[0] / 2:
        width = (available_size[0] / 2) - 3
    else:
        width = chosen_size[0]
    # Calculate height
    if chosen_size[1] > available_size[1]:
        height = available_size[1]
    else:
        height = chosen_size[1]

    size = (width, height)

    padding_x = int(math.floor(available_size[0] - width) / 4)
    padding_y = int(math.floor(available_size[1] - height) / 2)

    padding = (padding_y, padding_x, padding_y, padding_x)

    boundaries = {
        "bottom": int(math.floor(height / 2)),
        "left": int(math.floor(-width / 2)),
        "right": int(math.floor(width / 2)),
        "top": int(math.floor(-height / 2)),
    }
Esempio n. 7
0
def init():
    global size, width, height, padding, boundaries, chosen_theme, resolution

    # Get containing terminal window and set it to maximised
    pid = os.getpid()
    win = _get_window_by_child_pid(pid)
    gdk_window_settings(win, maximized=True)
    time.sleep(0.1)
    available_size = (width, height) = console.getTerminalSize()
     # Check for screen resolution
    resolution = get_status()['resolution']
    resolution = int(resolution.split('x')[1])
    # Select a set of sizes depending on the screen resolution
    if resolution > 768:
        chosen_size = (20, 15)
    else:
        chosen_size = (10, 5)

    # Calculate width
    if chosen_size[0] > available_size[0] / 2:
        width = available_size[0] / 2
    else:
        width = chosen_size[0]
    # Calculate height
    if chosen_size[1] > available_size[1]:
        height = available_size[1]
    else:
        height = chosen_size[1]

    size = (width, height)

    padding_x = int(math.floor(available_size[0] - width) / 4)
    padding_y = int(math.floor(available_size[1] - height) / 2)

    padding = (padding_y, padding_x, padding_y, padding_x)

    boundaries = {
        "bottom": int(math.floor(height / 2)),
        "left": int(math.floor(-width / 2)),
        "right": int(math.floor(width / 2)),
        "top": int(math.floor(-height / 2)),
    }
Esempio n. 8
0
    def __init__(self, win):
        # Show the Display brand and model
        self.model = get_edid_name()
        info_message = _("\nScreen Model: {}".format(self.model))

        # And the current display resolution
        try:
            current_resolution = get_status()['resolution']
            info_message += _("\nCurrent Resolution: {}").format(_(current_resolution))
        except:
            pass

        Template.__init__(
            self,
            _("Display"),
            info_message,
            _("APPLY CHANGES")
        )

        self.win = win
        self.win.set_main_widget(self)

        self.win.top_bar.enable_prev()
        self.win.change_prev_callback(self.win.go_to_home)

        self.kano_button.connect('button-release-event', self.apply_changes)
        self.kano_button.connect('key-release-event', self.apply_changes)

        horizontal_container = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL,
                                       spacing=40)
        horizontal_container.set_valign(Gtk.Align.CENTER)

        # HDMI mode combo box
        self.mode_combo = KanoComboBox(max_display_items=7)
        self.mode_combo.connect('changed', self.on_mode_changed)

        # Fill list of modes
        modes = list_supported_modes()
        self.mode_combo.append('auto')
        mode_string = '{hdmi_group}:{hdmi_mode}  {width}x{height}  {refresh_rate}Hz  {aspect_ratio}'

        if modes:
            for mode in modes:
                self.mode_combo.append(mode_string.format(
                    hdmi_group=mode['group'],
                    hdmi_mode=mode['mode'],
                    width=mode['width'],
                    height=mode['height'],
                    refresh_rate=mode['rate'],
                    aspect_ratio=mode['aspect_ratio']
                ))

        horizontal_container.pack_start(self.mode_combo, False, False, 0)
        self.mode_combo.props.valign = Gtk.Align.CENTER

        # Select the current setting in the dropdown list
        saved_group, saved_mode = read_hdmi_mode()
        active_item = find_matching_mode(modes, saved_group, saved_mode)
        self.mode_combo.set_selected_item_index(active_item)
        self.init_item = active_item
        self.mode_index = active_item
        # Overscan button
        overscan_button = OrangeButton(_("Overscan"))
        horizontal_container.pack_end(overscan_button, False, False, 0)
        overscan_button.connect('button-release-event', self.go_to_overscan)

        self.box.pack_start(horizontal_container, False, False, 0)

        # Create Flip 180 checkbox
        flip_button = Gtk.CheckButton(_("Flip Screen"))
        flip_button.set_can_focus(False)
        flip_button.props.valign = Gtk.Align.CENTER
        flip_button.set_active(get_screen_value('display_rotate') == 2)
        flip_button.connect('clicked', self.flip)

        self.box.pack_start(flip_button, False, False, 0)
        self.kano_button.set_sensitive(False)

        # Add apply changes button under the main settings content
        self.win.show_all()
    def __init__(self, win):
        # Show the Display brand and model
        self.model = get_model()
        info_message = ' (Changing this requires a reboot)'

        # And the current display resolution
        try:
            current_resolution = get_status()['resolution']
            info_message += '\n\nCurrent resolution: {}'.format(current_resolution)
        except:
            pass

        Template.__init__(
            self,
            "Display",
            self.model + info_message,
            "APPLY CHANGES"
        )

        self.win = win
        self.win.set_main_widget(self)

        self.win.top_bar.enable_prev()
        self.win.change_prev_callback(self.win.go_to_home)

        self.kano_button.connect("button-release-event", self.apply_changes)
        self.kano_button.connect("key-release-event", self.apply_changes)

        horizontal_container = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=40)
        horizontal_container.set_valign(Gtk.Align.CENTER)

        # HDMI mode combo box
        self.mode_combo = KanoComboBox(max_display_items=7)
        self.mode_combo.connect("changed", self.on_mode_changed)

        # Fill list of modes
        modes = list_supported_modes()
        self.mode_combo.append("auto")
        if modes:
            for v in modes:
                self.mode_combo.append(v)

        horizontal_container.pack_start(self.mode_combo, False, False, 0)
        self.mode_combo.props.valign = Gtk.Align.CENTER

        # Select the current setting in the dropdown list
        saved_group, saved_mode = read_hdmi_mode()
        active_item = find_matching_mode(modes, saved_group, saved_mode)
        self.mode_combo.set_selected_item_index(active_item)
        self.init_item = active_item
        self.mode_index = active_item
        # Overscan button
        overscan_button = OrangeButton("Overscan")
        horizontal_container.pack_end(overscan_button, False, False, 0)
        overscan_button.connect("button-release-event", self.go_to_overscan)

        self.box.pack_start(horizontal_container, False, False, 0)

        # Create Flip 180 checkbox 
        flip_button = Gtk.CheckButton("Flip Screen")
        flip_button.set_can_focus(False)
        flip_button.props.valign = Gtk.Align.CENTER
        flip_button.set_active(get_config_value("display_rotate") == 2)
        flip_button.connect("clicked", self.flip)

        self.box.pack_start(flip_button, False, False, 0)
        self.kano_button.set_sensitive(False)

        # Add apply changes button under the main settings content
        self.win.show_all()
Esempio n. 10
0
    def __init__(self, win):
        # Show the Display brand and model
        self.model = get_edid_name()
        info_message = _("\nScreen Model: {}".format(self.model))

        # And the current display resolution
        try:
            current_resolution = get_status()['resolution']
            info_message += _("\nCurrent Resolution: {}").format(_(current_resolution))
        except:
            pass

        Template.__init__(
            self,
            _("Display"),
            info_message,
            _("APPLY CHANGES")
        )

        self.win = win
        self.win.set_main_widget(self)

        self.win.top_bar.enable_prev()
        self.win.change_prev_callback(self.win.go_to_home)

        self.kano_button.connect('button-release-event', self.apply_changes)
        self.kano_button.connect('key-release-event', self.apply_changes)

        horizontal_container = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL,
                                       spacing=40)
        horizontal_container.set_valign(Gtk.Align.CENTER)

        # HDMI mode combo box
        self.mode_combo = KanoComboBox(max_display_items=7)
        self.mode_combo.connect('changed', self.on_mode_changed)

        # Fill list of modes
        modes = list_supported_modes()
        self.mode_combo.append('auto')
        mode_string = '{hdmi_group}:{hdmi_mode}  {width}x{height}  {refresh_rate}Hz  {aspect_ratio}'

        if modes:
            for mode in modes:
                self.mode_combo.append(mode_string.format(
                    hdmi_group=mode['group'],
                    hdmi_mode=mode['mode'],
                    width=mode['width'],
                    height=mode['height'],
                    refresh_rate=mode['rate'],
                    aspect_ratio=mode['aspect_ratio']
                ))

        horizontal_container.pack_start(self.mode_combo, False, False, 0)
        self.mode_combo.props.valign = Gtk.Align.CENTER

        # Select the current setting in the dropdown list
        saved_group, saved_mode = read_hdmi_mode()
        active_item = find_matching_mode(modes, saved_group, saved_mode)
        self.mode_combo.set_selected_item_index(active_item)
        self.init_item = active_item
        self.mode_index = active_item
        # Overscan button
        overscan_button = OrangeButton(_("Overscan"))
        horizontal_container.pack_end(overscan_button, False, False, 0)
        overscan_button.connect('button-release-event', self.go_to_overscan)

        self.box.pack_start(horizontal_container, False, False, 0)

        # Create Flip 180 checkbox
        flip_button = Gtk.CheckButton(_("Flip Screen"))
        flip_button.set_can_focus(False)
        flip_button.props.valign = Gtk.Align.CENTER
        self.flip_preference_start = (get_screen_value('display_rotate') == 2)
        self.flip_preference_end = self.flip_preference_start
        flip_button.set_active(self.flip_preference_start)
        flip_button.connect('clicked', self.on_flip_screen_clicked)

        self.box.pack_start(flip_button, False, False, 0)
        self.kano_button.set_sensitive(False)

        # Add apply changes button under the main settings content
        self.win.show_all()