Exemple #1
0
 def __init__(self, **config):
     Volume.__init__(self, **config)
     self.add_defaults(FixedWidthVolume.defaults)
     if self.theme_path:
         self.length_type = bar.STATIC
         self.length = 0
     self.surfaces = {}
     self.volume = None
Exemple #2
0
def test_images_good(tmpdir, fake_bar, svg_img_as_pypath):
    names = (
        'audio-volume-high.svg',
        'audio-volume-low.svg',
        'audio-volume-medium.svg',
        'audio-volume-muted.svg',
    )
    for name in names:
        target = tmpdir.join(name)
        svg_img_as_pypath.copy(target)

    vol = Volume(theme_path=str(tmpdir))
    vol.bar = fake_bar
    vol.setup_images()
    assert len(vol.surfaces) == len(names)
    for name, surfpat in vol.surfaces.items():
        assert isinstance(surfpat, cairocffi.SurfacePattern)
Exemple #3
0
def test_images_good(tmpdir, fake_bar, svg_img_as_pypath):
    names = (
        'audio-volume-high.svg',
        'audio-volume-low.svg',
        'audio-volume-medium.svg',
        'audio-volume-muted.svg',
    )
    for name in names:
        target = tmpdir.join(name)
        svg_img_as_pypath.copy(target)

    vol = Volume(theme_path=str(tmpdir))
    vol.bar = fake_bar
    vol.setup_images()
    assert len(vol.surfaces) == len(names)
    for name, surfpat in vol.surfaces.items():
        assert isinstance(surfpat, cairocffi.SurfacePattern)
Exemple #4
0
def test_text():
    fmt = "Volume: {}"
    vol = Volume(fmt=fmt)
    vol.volume = -1
    vol._update_drawer()
    assert vol.text == 'M'

    vol.volume = 50
    vol._update_drawer()
    assert vol.text == '50%'
Exemple #5
0
     text="[",
     foreground=colorz[2],
     fontsize=18,
 ),
 Net(**w_net, ),
 TextBox(
     text="]",
     foreground=colorz[2],
     fontsize=18,
 ),
 TextBox(
     text="[",
     foreground=colorz[4],
     fontsize=18,
 ),
 Volume(**w_vol),
 TextBox(
     text="]",
     foreground=colorz[4],
     fontsize=18,
 ),
 TextBox(
     text="[",
     foreground=colorz[3],
     fontsize=18,
 ),
 Clock(**w_clock),
 TextBox(
     text="]",
     foreground=colorz[3],
     fontsize=18,
Exemple #6
0
    def init_top_main(self, hidpi = False):

        fontsize = 12 if not hidpi else 22

        wl  = []

        wl += [CurrentLayoutIcon(
            fontsize=fontsize,
            # custom_icon_paths=[expanduser("~/.config/qtile/icons")],
            foreground=self.color.white,
            padding=10,
            scale=0.7
        )]

        wl += [GroupBox(
            fontsize=24 if not hidpi else 40,
            font=self.font.bold,
            margin_y=3,
            margin_x=0,
            padding_y=5,
            padding_x=10 if not hidpi else 20,
            borderwidth=3,
            hide_unused=True,
            active=self.color.yellow,
            inactive=self.color.lightgrey,
            urgent_text=self.color.white,
            highlight_method="line",
            urgent_alert_method="line",
            highlight_color=self.color.grey,
            urgent_border=self.color.red,
            this_current_screen_border=self.color.yellow,
            other_screen_border=self.color.magenta,
            this_screen_border=self.color.magenta,
            other_current_screen_border=self.color.yellow,
            rounded=False,
            disable_drag=True,
            use_mouse_wheel=False
        )]

        wl += [self.space.small()]

        wl += [Prompt(
            fontsize=fontsize,
            prompt="λ : ",
            padding=10,
            bell_style="visual",
            foreground=self.color.magenta,
            background=self.color.black
        )]

        wl += [self.space.small()]

        wl += [WindowName(
            fontsize=fontsize,
            padding=0,
            show_state=False,
            for_current_screen=False,
            foreground=self.color.yellow
        )]

        wl += [self.space.extra_large()]

        wl += [TextBox(
            fontsize=fontsize,
            foreground=self.color.magenta,
            text=" "
        )]
        wl += [DF(
            fontsize=fontsize,
            foreground=self.color.magenta,
            format='{uf}{m}',
            partition='/',
            visible_on_warn=False
        )]

        wl += [self.space.small()]

        wl += [TextBox(
            fontsize=fontsize,
            foreground=self.color.magenta,
            text=" "
        )]
        wl += [DF(
            fontsize=fontsize,
            foreground=self.color.magenta,
            format='{uf}{m}',
            partition='/home',
            visible_on_warn=False
        )]

        wl += [self.separator.normal()]

        wl += [TextBox(
            fontsize=fontsize,
            foreground=self.color.blue,
            text=" "
        )]
        wl += [CPU(
            fontsize=fontsize,
            foreground=self.color.blue,
            # TODO Remove hard coded terminal
            mouse_callbacks={'Button1': lambda qtile: qtile.cmd_spawn("alacritty -e ytop")},
            format='{load_percent}%',
            update_interval=2.0
        )]

        wl += [self.space.small()]

        wl += [TextBox(
            fontsize=fontsize,
            foreground=self.color.blue,
            text=" "
        )]
        wl += [ThermalSensor(
            fontsize=fontsize,
            foreground=self.color.blue,
            threshold=90,
            mouse_callbacks={'Button1': lambda qtile: qtile.cmd_spawn("alacritty -e ytop")},
            update_interval=2.0
        )]

        wl += [self.separator.normal()]
        wl += [TextBox(
            fontsize=fontsize,
            foreground=self.color.cyan,
            text=" "
        )]
        wl += [Memory(
            fontsize=fontsize,
            foreground=self.color.cyan,
            mouse_callbacks={'Button1': lambda qtile: qtile.cmd_spawn(terminal + ' -e ytop')},
            update_interval=2.0,
        )]

        wl += [self.separator.normal()]

        wl += [TextBox(
            fontsize=fontsize,
            foreground=self.color.green,
            font=self.font.bold,
            text="直 "
        )]
        wl += [Wlan(
            fontsize=fontsize,
            foreground=self.color.green,
            interface='wlp60s0',
            format='{essid} ({percent:2.0%})'
        )]

        wl += [self.separator.normal()]

        wl += [TextBox(
            fontsize=fontsize,
            foreground=self.color.orange,
            font=self.font.bold,
            text=" "
        )]
        wl += [Volume(
            fontsize=fontsize,
            foreground=self.color.orange
        )]

        wl += [self.space.small()]

        wl += [TextBox(
            fontsize=fontsize,
            foreground=self.color.orange,
            font=self.font.bold,
            text=" "
        )]
        wl += [Backlight(
            fontsize=fontsize,
            foreground=self.color.orange,
            backlight_name='intel_backlight',
            format='{percent:2.0%}'
        )]

        wl += [self.space.small()]

        wl += [Battery(
            fontsize=fontsize,
            foreground=self.color.orange,
            low_foreground=self.color.red,
            format='{char} {percent:2.0%}',
            low_percentage=0.2,
            charge_char='',
            full_char='',
            empty_char='',
            ramp_cap0_char='',
            ramp_cap1_char='',
            ramp_cap2_char='',
            ramp_cap3_char='',
            ramp_cap4_char='',
            ramp_cap0_foreground=self.color.red[0],
            ramp_cap1_foreground=self.color.red[0],
            ramp_cap2_foreground=self.color.orange[0],
            ramp_cap3_foreground=self.color.orange[0],
            ramp_cap4_foreground=self.color.green[0],
        )]

        # wl += [self.separator.normal()]
        # wl += [TextBox(
        #     font=self.font.bold,
        #     text=" "
        # )]
        # wl += [CheckUpdates(
        #     distro="Arch_checkupdates",
        #     display_format="{updates}",
        #     update_interval=900,
        #     colour_have_updates=self.color.white,
        #     colour_no_updates=self.color.white
        # )]

        # wl += [self.separator.normal()]
        # wl += [Systray(
        #     padding=3,
        #     icon_size=19 if not hidpi else 30
        # )]

        wl += [self.separator.normal()]
        wl += [Clock(
            fontsize=fontsize,
            foreground=self.color.yellow,
            format=" %d.%m.%Y  %H:%M"
        )]
        wl += [self.space.large()]

        return wl
Exemple #7
0
def test_images_fail():
    vol = Volume(theme_path=TEST_DIR)
    with pytest.raises(images.LoadingError):
        vol.setup_images()
Exemple #8
0
def test_emoji():
    vol = Volume(emoji=True)
    vol.volume = -1
    vol._update_drawer()
    assert vol.text == '\U0001f507'

    vol.volume = 29
    vol._update_drawer()
    assert vol.text == '\U0001f508'

    vol.volume = 79
    vol._update_drawer()
    assert vol.text == '\U0001f509'

    vol.volume = 80
    vol._update_drawer()
    assert vol.text == '\U0001f50a'
Exemple #9
0
def test_images_fail():
    vol = Volume(theme_path=TEST_DIR)
    with pytest.raises(images.LoadingError):
        vol.setup_images()