예제 #1
0
def verifyPin():
    global pin, c

    if pin == "":
        retPage = kalipi.get_retPage()
        kalipi.screensaver(retPage)
        menuPin()
    elif pin == "111":
        pygame.quit()
        page = os.environ["MENUDIR"] + "menu-9p.py"
        retPage = kalipi.get_retPage()
        args = [page, retPage]
        os.execvp("python", ["python"] + args)
        sys.exit()
    elif pin == "110":
        pygame.quit()
        kalipi.run_cmd("/usr/bin/sudo /sbin/shutdown -h now")
        sys.exit()
    else:
        file = ".kalipi"
        pinFile = os.environ["MENUDIR"] + ".kalipi"
        file_conn = open(pinFile)
        file_pin = file_conn.readline()[:-1]
        file_conn.close()
        hashed_pin = hashlib.sha512(file + pin).hexdigest()
        if file_pin == hashed_pin:
            pygame.quit()
            launch_bg = os.environ["MENUDIR"] + "launch-bg.sh"
            process = subprocess.call(launch_bg, shell=True)
            retPage = kalipi.get_retPage()
            page = os.environ["MENUDIR"] + retPage
            args = [page]
            os.execvp("python", ["python"] + args)
            sys.exit()
        else:
            pin = ""
            c = 0
            return
예제 #2
0
파일: menu-9p.py 프로젝트: xh2310/Kali-Pi
def button(number):

    if number == 7:
        if button7.disable == 1:
            return

        # Previous page
        pygame.quit()
        page=os.environ["MENUDIR"] + "menu-pin.py"
        retPage=kalipi.get_retPage()
        args = [page, retPage]
        os.execvp("python", ["python"] + args)
        sys.exit()

    if number == 9:
        if button9.disable == 1:
            return

        # Refresh
        pygame.quit()
        menu9p()
예제 #3
0
def menuPin(argv):

    global c

    # Init screen
    kalipi.screen()
    # Outer Border
    kalipi.border(tron_blu)

    #############################
    ##        Buttons          ##

    # Buttons and labels
    # See variables at the top of the document to adjust the menu

    # Title
    titleButton.draw()

    # First Row
    # Button 1
    button1.disable = 0  # "1" disables button

    if button1.disable == 1:
        button1.draw()
    else:
        # Add button launch code here
        button1.draw()

    # Button 2
    button2.disable = 0  # "1" disables button

    if button2.disable == 1:
        button2.draw()
    else:
        # Add button launch code here
        button2.draw()

    # Button 3
    button3.disable = 0  # "1" disables button

    if button3.disable == 1:
        button3.draw()
    else:
        # Add button launch code here
        button3.draw()

    # Second Row
    # Button 4
    button4.disable = 0  # "1" disables button

    if button4.disable == 1:
        button4.draw()
    else:
        # Add button launch code here
        button4.draw()

    # Button 5
    button5.disable = 0  # "1" disables button

    if button5.disable == 1:
        button5.draw()
    else:
        # Add button launch code here
        button5.draw()

    # Button 6
    button6.disable = 0  # "1" disables button

    if button6.disable == 1:
        button6.draw()
    else:
        # Add button launch code here
        button6.draw()

    # Third Row
    # Button 7
    button7.disable = 0  # "1" disables button

    if button7.disable == 1:
        button7.draw()
    else:
        # Add button launch code here
        button7.draw()

    # Button 8
    button8.disable = 0  # "1" disables button

    if button8.disable == 1:
        button8.draw()
    else:
        # Add button launch code here
        button8.draw()

    # Button 9
    button9.disable = 0  # "1" disables button

    if button9.disable == 1:
        button9.draw()
    else:
        # Add button launch code here
        button9.draw()

    # Button c
    buttonc.disable = 0  # "1" disables button

    if buttonc.disable == 1:
        buttonc.draw()
    else:
        # Add button launch code here
        buttonc.draw()

    # Button 0
    button0.disable = 0  # "1" disables button

    if button0.disable == 1:
        button0.draw()
    else:
        # Add button launch code here
        button0.draw()

    # Button e
    buttone.disable = 0  # "1" disables button

    if buttone.disable == 1:
        buttone.draw()
    else:
        # Add button launch code here
        buttone.draw()

    ##        Buttons          ##
    #############################

    #############################
    ##        Input loop       ##

    if "KPTIMEOUT" in os.environ:
        timeout = float(
            os.environ["KPTIMEOUT"]) * 60 / 3  # Convert timeout to seconds

        #While loop to manage touch screen inputs
        t = timeout

        while True:
            for event in pygame.event.get():
                if event.type == pygame.MOUSEBUTTONDOWN:
                    t = timeout
                    pos = (pygame.mouse.get_pos()[0],
                           pygame.mouse.get_pos()[1])
                    num = local_on_touch()
                    button(num)
                    if c > 0:
                        pygame.draw.rect(screen.canvas, black,
                                         (newOriginX, newOriginX,
                                          buttonWidth * 3, buttonHeight), 0)
                        new_titleButton = Button("      " + c * "* ",
                                                 newOriginX, newOriginX,
                                                 buttonHeight,
                                                 buttonWidth * 3 + spacing * 2,
                                                 tron_blu, green,
                                                 newTitleFont * 2)
                        new_titleButton.draw()
                        if c > 15:
                            c = 0
                    else:
                        pygame.draw.rect(screen.canvas, black,
                                         (newOriginX, newOriginX,
                                          buttonWidth * 3, buttonHeight), 0)
                        titleButton.draw()

                #Debug:
                #ensure there is always a safe way to end the program if the touch screen fails
                ##if event.type == KEYDOWN:
                ##    if event.key == K_ESCAPE:
                ##        sys.exit()
            pygame.display.update()

            ## Reduce CPU utilisation
            time.sleep(0.1)
            t = t - 0.1

            if t <= 0:
                break

        ## Screensaver
        retPage = kalipi.get_retPage()
        kalipi.screensaver(retPage)
        menuPin()

    else:

        #While loop to manage touch screen inputs
        while True:
            for event in pygame.event.get():
                if event.type == pygame.MOUSEBUTTONDOWN:
                    pos = (pygame.mouse.get_pos()[0],
                           pygame.mouse.get_pos()[1])
                    num = local_on_touch()
                    button(num)
                    if c > 0:
                        pygame.draw.rect(screen, black,
                                         (newOriginX, newOriginX,
                                          buttonWidth * 3, buttonHeight), 0)
                        new_titleButton = Button("      " + c * "* ",
                                                 newOriginX, newOriginX,
                                                 buttonHeight,
                                                 buttonWidth * 3 + spacing * 2,
                                                 green, newTitleFont * 2)
                        make_button(new_titleButton)
                        if c > 15:
                            c = 0
                    else:
                        pygame.draw.rect(screen, black,
                                         (newOriginX, newOriginX,
                                          buttonWidth * 3, buttonHeight), 0)
                        make_button(titleButton)

            #Debug:
            #ensure there is always a safe way to end the program if the touch screen fails
            ## if event.type == KEYDOWN:
            ##     if event.key == K_ESCAPE:
            ##         sys.exit()

            pygame.display.update()

            ## Reduce CPU utilisation
            time.sleep(0.1)