Пример #1
0
#! /bin/python
import dmenu_extended
dmenu_extended.dmenu().cache_build()
Пример #2
0
#!/usr/bin/python
import dmenu_extended
import sys

if __name__ == "__main__":
    d = dmenu_extended.dmenu()
    d.load_preferences()
    # Find a way to hide the users password by setting the forground text colour
    # to match the background text colour (so it's not readable)
    if '-nb' in d.prefs['menu_arguments']:
        index_background = d.prefs['menu_arguments'].index('-nb') + 1
        if '-nf' in d.prefs['menu_arguments']:
            index_foreground = d.prefs['menu_arguments'].index('-nf') + 1
            d.prefs['menu_arguments'][index_foreground] = d.prefs[
                'menu_arguments'][index_background]
        else:
            d.prefs['menu_arguments'] += [
                '-nf', d.prefs['menu_arguments'][index_background]
            ]
    else:
        d.prefs['menu_arguments'] += ['-nf', '#000000']
        d.prefs['menu_arguments'] += ['-nb', '#000000']
    with open(dmenu_extended.path_plugins + '/plugin_sudo_counter.txt',
              'r') as f:
        message = f.readline()
    pword = d.menu('', prompt=message)
    if pword == '':
        sys.exit()
    else:
        with open(dmenu_extended.path_plugins + '/plugin_sudo_counter.txt',
                  'w') as f:
Пример #3
0
#! /usr/bin/env python
# -*- coding: utf8 -*-

import mock
import pytest
import sys
from os import path

sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
import dmenu_extended as d

menu = d.dmenu()


def test_required_variables_available():
    assert d.path_cache[-len('dmenu-extended'):] == 'dmenu-extended'


def test_command_to_list():
    assert menu.command_to_list(['a', 'b', 'c']) == [u'a', u'b', u'c']
    assert menu.command_to_list('a b c') == [u'a', u'b', u'c']
    assert menu.command_to_list(['a', 'b c']) == [u'a', u'b', u'c']
    assert menu.command_to_list(['a', 'b', 'c',
                                 'aö']) == [u'a', u'b', u'c', u'a\xf6']
    assert menu.command_to_list('a b c aö') == [u'a', u'b', u'c', u'a\xf6']
    assert menu.command_to_list([u'a',
                                 u'b c aö']) == [u'a', u'b', u'c', u'a\xf6']
    assert menu.command_to_list('xdg-open "/home/user/aö/"') == [
        u'xdg-open', u'/home/user/a\xf6/'
    ]
    assert menu.command_to_list('xdg-open /home/user/aö/') == [
Пример #4
0
#!/usr/bin/python
import dmenu_extended
import sys

if __name__ == "__main__":
    d = dmenu_extended.dmenu()
    d.load_preferences()
    # Find a way to hide the users password by setting the forground text colour
    # to match the background text colour (so it's not readable)
    if "-nb" in d.prefs["menu_arguments"]:
        index_background = d.prefs["menu_arguments"].index("-nb") + 1
        if "-nf" in d.prefs["menu_arguments"]:
            index_foreground = d.prefs["menu_arguments"].index("-nf") + 1
            d.prefs["menu_arguments"][index_foreground] = d.prefs["menu_arguments"][index_background]
        else:
            d.prefs["menu_arguments"] += ["-nf", d.prefs["menu_arguments"][index_background]]
    else:
        d.prefs["menu_arguments"] += ["-nf", "#000000"]
        d.prefs["menu_arguments"] += ["-nb", "#000000"]
    with open(dmenu_extended.path_plugins + "/plugin_sudo_counter.txt", "r") as f:
        message = f.readline()
    pword = d.menu("", prompt=message)
    if pword == "":
        sys.exit()
    else:
        with open(dmenu_extended.path_plugins + "/plugin_sudo_counter.txt", "w") as f:
            f.write("Password incorrect, try again:")
        print(pword + "\n")


class extension(dmenu_extended.dmenu):