예제 #1
0
def set_mode(mode_desc):
    group, mode, drive = tvservice.status()['gmd']
    mode = mode_desc["code"]
    tvservice.set_mode(group, mode, drive)
    Printer(['Changed to', "{},{},{}".format(group, mode, drive)],
            i,
            o,
            skippable=True)
    status = tvservice.status()
    try:
        x, y = status["resolution"]
    except KeyError:
        Printer(["Can't get", "resolution!"], i, o, skippable=True)
    else:
        try:
            check_output(["fbset", "-depth", "8"])
            check_output(["fbset", "-g", x, y, x, y, "16"])
            check_output([
                "chvt", "1"
            ])  #HAAAAAAAAAX - we need to switch VTs for changes to appear
            check_output(
                ["chvt", "7"]
            )  #This relies on the fact that GUI is mostly on VT7 and most people will want GUI resolutionto change.
            #TODO: Restart X... Maybe?
        except:
            Printer(["Refresh failed!", "Try Ctrl-Alt-F1", "and Ctrl-Alt-F7"],
                    i,
                    o,
                    skippable=True)
        else:
            raise MenuExitException  #Alright, post-resolution-change triggers executed, nothing to do here
예제 #2
0
def select_hdmi_mode():
    menu_contents = []
    try:
        current_group = tvservice.status()['gmd'][0]
    except KeyError, IndexError:
        Printer(["Error, is HDMI", "enabled?"], i, o)
        return False
예제 #3
0
def display_on():
    tvservice.display_on()
    Printer(['Enabled display', 'with defaults'], i, o, skippable=True)
    status = tvservice.status()
    try:
        x, y = status["resolution"]
    except KeyError:
        Printer(["Can't get", "resolution!"], i, o, skippable=True)
    else:
        try:
            check_output(["fbset", "-depth", "8"])
            check_output(["fbset", "-g", x, y, x, y, "16"])
            check_output([
                "chvt", "1"
            ])  #HAAAAAAAAAX - we need to switch VTs for changes to appear
            check_output(
                ["chvt",
                 "7"])  #This relies on the fact that GUI is mostly on VT7
        except:
            Printer(["Refresh failed!", "Try Ctrl-Alt-F1", "and Ctrl-Alt-F7"],
                    i,
                    o,
                    skippable=True)
        else:
            pass  #All successful.
예제 #4
0
def launch():
    try:
        status = tvservice.status()
    except OSError as e:
        if e.errno == 2:
            Printer(["Do you have", "tvservice?"], i, o, 3, skippable=True)
            return
        else:
            raise e
    else:
        main_menu_contents = [["Status", show_status],
                              ["Choose HDMI mode", select_hdmi_mode],
                              ["Display on", display_on],
                              ["Display off", display_off]]
        main_menu = Menu(main_menu_contents, i, o, "tvservice main menu")
        main_menu.activate()
예제 #5
0
def show_status():
    try:
        status = tvservice.status()
    except IndexError, KeyError:
        Printer(["Unknown mode", "open GH issue"], i, o)
        return False