コード例 #1
0
ファイル: my_widgets.py プロジェクト: juanscr/dotfiles
    def widget_ram(self) -> list[_Widget]:
        """Widget for showing RAM usage.

        Requirements
        ------------
        - https://pypi.org/project/psutil/

        Returns
        -------
        list[libqtile.widget.base._Widget]
            A list of the widgets for the RAM module.
        """

        ram_graph = Memory(
            **self.fonts["Normal"],
            background=self.colors["background"],
            foreground=self.colors["blue"],
            format="{MemPercent}%",
        )
        textbox = TextBox(
            **self.fonts["Normal"],
            text="RAM",
            foreground=self.colors["blue"],
            background=self.colors["background"],
        )

        return [textbox, ram_graph]
コード例 #2
0
ファイル: my_widgets.py プロジェクト: juanscr/dotfiles
    def widget_volume(self) -> list[_Widget]:
        """Widget for displaying the volume.

        Requirements
        ------------
        - pamixer

        Returns
        -------
        list[libqtile.widget.base._Widget]
            The list of widgets.
        """

        # Widget for volume
        widget_volume = Volume(
            **self.fonts["Normal"],
            # Colors
            foreground=self.colors["cyan"],
            background=self.colors["background"],
            # Volume command
            get_volume_command="/home/juanscr/.config/qtile/" +
            "get_volume_qtile.sh",
            mute_command="pamixer -t",
            volume_down_command="pamixer -d 5",
            volume_up_command="pamixer -i 5",
        )

        # Icon for volume
        icon_volume = TextBox(**self.fonts["Icons2"],
                              foreground=self.colors["cyan"],
                              text="",
                              padding=8)

        return [icon_volume, widget_volume]
コード例 #3
0
ファイル: my_widgets.py プロジェクト: juanscr/dotfiles
    def widget_time(self, compact: bool = False) -> list[_Widget]:
        """Widget for displaying the time.

        Returns
        -------
        list[libqtile.widget.base._Widget]
            The list of widgets to add to the bar.
        """

        clock_format = "%a, %d %b   %H:%M"
        padding = 6
        if compact:
            clock_format = "%d %b %H:%M"
            padding = 0

        # Icon
        w_clock_icon = TextBox(**self.fonts["Icons2"],
                               text=" ",
                               padding=padding)

        # Text
        widget_clock = Clock(**self.fonts["Normal"], format=clock_format)

        widgets = [w_clock_icon, widget_clock]
        return widgets
コード例 #4
0
ファイル: my_widgets.py プロジェクト: juanscr/dotfiles
    def widget_update(self) -> list[_Widget]:
        """Module for displaying updates.

        Requirements
        ------------
        - pacman-contrib

        Returns
        -------
        list[libqtile.widget.base._Widget]
            The list of widgets to add to the bar.
        """

        # Icon
        w_update_icon = TextBox(
            **self.fonts["Icons2"],
            text="ﮮ",
            foreground=self.colors["yellow"],
            padding=8,
        )

        # Text
        w_update_text = CheckUpdates(
            **self.fonts["Normal"],
            distro="Arch_checkupdates",
            colour_have_updates=self.colors["yellow"],
            colour_no_updates=self.colors["yellow"],
            no_update_string="0",
            display_format="{updates}",
            padding=0,
            update_interval=60,
        )

        widgets: list[_Widget] = [w_update_icon, w_update_text]
        return widgets
コード例 #5
0
ファイル: my_widgets.py プロジェクト: juanscr/dotfiles
    def create_widgets(
        self,
        widgets_left: list[_Widget],
        widgets_center: list[_Widget],
        widgets_right: list[_Widget],
        screen: int,
    ) -> list[_Widget]:
        """It creates the widgets list by section.

        Parameters
        ----------
        widgets_left: list[_Widget]
            The list of widgets to the left of the bar.
        widgets_center: list[_Widget]
            The list of widgets to the center of the bar.
        widgets_right: list[_Widget]
            The list of widgets to the right of the bar.
        screen: int
            The screen the bar is going to be displayed at.

        Returns
        -------
        list[_Widget]
            The widgets to add to the bar.
        """

        # Padding for bar
        paddingl = self.padding_left[f"bar{screen}"]
        paddingr = self.padding_right[f"bar{screen}"]
        widgets = []

        # Add left
        if len(widgets_left) > 0:
            background = widgets_left[0].background
            space = Spacer(length=paddingl, background=background)
            widgets += widgets_left
            widgets.insert(0, space)

        # Add center
        if len(widgets_center) > 0:
            widgets.append(Spacer())
            widgets += widgets_center
            widgets.append(Spacer())

        # Add right
        if len(widgets_right) > 0:
            if len(widgets_center) == 0:
                widgets.append(Spacer())

            background = widgets_right[-1].background
            space = Spacer(length=paddingr, background=background)
            widgets += widgets_right
            widgets.append(space)

        elif len(widgets_center) > 0:
            widgets.append(TextBox())

        return widgets
コード例 #6
0
ファイル: my_widgets.py プロジェクト: juanscr/dotfiles
    def widget_brightness(self) -> list[_Widget]:
        """It gets the brightness widgets.

        Requirements
        ------------
        - https://github.com/haikarainen/light

        Returns
        -------
        list[libqtile.widget.base_Widget]
            The list of widgets for the brightness module.
        """
        def get_brightness() -> str:
            """It gets the current brightness.

            Returns
            -------
            str
                The percentage of brightness.
            """

            try:
                output = subprocess.check_output(
                    'light -G | awk \'{split($0, a, "."); print a[1]"%"}\'',
                    shell=True).decode()[:-1]
            except subprocess.SubprocessError:
                return ""

            return output

        widget_brightness = GenPollText(
            **self.fonts["Normal"],
            foreground=self.colors["magenta"],
            func=get_brightness,
            update_interval=2,
        )
        widget_text = TextBox(
            **self.fonts["Icons2"],
            foreground=self.colors["magenta"],
            text="",
            padding=8,
        )
        return [widget_text, widget_brightness]
コード例 #7
0
ファイル: my_widgets.py プロジェクト: juanscr/dotfiles
        def wrapper(self: MyWidgets, *args: Any,
                    **kwargs: Any) -> list[_Widget]:
            """It adds a separator and a pipe in the respective places.

            Parameters
            ----------
            self: MyWidgets
                The object to store the result.
            args: Any
                The positional arguments of the function.
            kwargs: Any
                The named arguments of the function.

            Returns
            -------
            list[libqtile.base._Widget]
                The list of the widgets with the spacer and the pipe.
            """

            add_pipe = kwargs.pop("add_pipe", True)
            widgets = func(self, *args, **kwargs)

            # Add space
            if space is not None:
                widgets.insert(0, Spacer(length=space))

            # Add pipe
            if add_pipe:
                widgets.insert(
                    0,
                    TextBox(
                        **self.fonts["Normal"],
                        text="|",
                        foreground=self.colors[color],
                        padding=padding,
                    ),
                )

            return widgets
コード例 #8
0
ファイル: my_widgets.py プロジェクト: juanscr/dotfiles
    def widget_spotify(self, max_length: int = 30) -> list[_Widget]:
        """Widget for showing spotify.

        Parameters
        ----------
        max_length: int, optional
            The max length of the spotify output. Default: 30.

        Requirements
        ------------
        - https://github.com/mihirlad55/polybar-spotify-module

        Returns
        -------
        list[libqtile.widget.base._Widget]
            The list of widgets to add to the bar.
        """

        # Track information
        widget_spotify = Mpris2(
            **self.fonts["Normal"],
            foreground=self.colors["foreground"],
            display_metadata=["xesam:title", "xesam:artist"],
            objname="org.mpris.MediaPlayer2.spotify",
            scroll_chars=0,
            max_chars=max_length,
        )

        # Icon
        widget_icon_spotify = TextBox(
            **self.fonts["Icons2"],
            foreground=self.colors["foreground"],
            text="",
            padding=8,
        )

        widgets: list[_Widget] = [widget_icon_spotify, widget_spotify]
        return widgets
コード例 #9
0
ファイル: my_widgets.py プロジェクト: juanscr/dotfiles
    def widget_cpu(self, text=False) -> list[_Widget]:
        """Widget for showing CPU usage.

        Requirements
        ------------
        - https://pypi.org/project/psutil/

        Returns
        -------
        list[libqtile.widget.base._Widget]
            A list of the widgets for the CPU module.
        """

        if text:
            cpu_graph = CPU(
                **self.fonts["Normal"],
                background=self.colors["background"],
                foreground=self.colors["red"],
                format="{load_percent}%",
            )
        else:
            cpu_graph = CPUGraph(
                background=self.colors["background"],
                border_color=self.colors["background"],
                graph_color=self.colors["red"],
                fill_color=self.colors["red"],
                type="linefill",
            )
        textbox = TextBox(
            **self.fonts["Normal"],
            text="CPU",
            foreground=self.colors["red"],
            background=self.colors["background"],
        )

        return [textbox, cpu_graph]
コード例 #10
0
def init_widgets_list():
    prompt = "{0}@{1}: ".format(os.environ["USER"], socket.gethostname())
    widgets_list = [
        GroupBox(font="FontAwesome",
                 fontsize=16,
                 margin_y=-1,
                 margin_x=0,
                 padding_y=6,
                 padding_x=5,
                 borderwidth=0,
                 disable_drag=True,
                 active=colors[5],
                 inactive=colors[9],
                 rounded=False,
                 highlight_method="text",
                 this_current_screen_border=colors[8],
                 foreground=colors[2],
                 background=colors[1]
                 ),
        Sep(
            linewidth=1,
            padding=10,
            foreground=colors[2],
            background=colors[1]
        ),
        CurrentLayout(
            font="MesloLGS NF Bold",
            foreground=colors[5],
            background=colors[1]
        ),
        Sep(
            linewidth=1,
            padding=10,
            foreground=colors[2],
            background=colors[1]
        ),
        WindowName(font="Noto Sans",
                   fontsize=12,
                   foreground=colors[5],
                   background=colors[1],
                   ),
        Prompt(name="my_prompt"),
        Sep(
            linewidth=1,
            padding=10,
            foreground=colors[2],
            background=colors[1]
        ),
        HeadsetBattery(font="MesloLGS NF",
                       charging_charts=[':'],
                       battery_level_format=lambda x: f':{x}%',
                       # battery_level_format=status_getter,
                       disconnected_chart=''),
        Sep(
            linewidth=1,
            padding=10,
            foreground=colors[2],
            background=colors[1]
        ),
        Radio(playlist={"R Nacional": "http://198.15.107.53:8090/;"},
              playing_spinner=[random_bar() + random_bar() + random_bar() + random_bar() for e in range(10)],
              font="MesloLGS NF",
              mute_string="婢",
              stopped_spinner=[""]),
        Sep(
            linewidth=1,
            padding=10,
            foreground=colors[2],
            background=colors[1]
        ),
        TaskLog(
            line_saved="\nFecha: {date}     min: {time}     Tarea: {task}",
            prompt_name="my_prompt",
            file_path="~/tiempos.log",
            format="min: {time}",
            get_time=lambda start_date: round((datetime.now() - start_date).seconds / 60, 1)
        ),
        Sep(
            linewidth=1,
            padding=10,
            foreground=colors[2],
            background=colors[1]
        ),
        Net(
            font="MesloLGS NF Blond",
            fontsize=12,
            # interface=["enp24s0", "wlp26s0"],
            foreground=colors[2],
            background=colors[1],
            padding=0,
            format="{down}  {up}"
        ),
        Sep(
            linewidth=1,
            padding=10,
            foreground=colors[2],
            background=colors[1]
        ),
        # NetGraph(
        #          font="Noto Sans",
        #          fontsize=12,
        #          bandwidth="down",
        #          interface="auto",
        #          fill_color = colors[8],
        #          foreground=colors[2],
        #          background=colors[1],
        #          graph_color = colors[8],
        #          border_color = colors[2],
        #          padding = 0,
        #          border_width = 1,
        #          line_width = 1,
        #          ),
        # Sep(
        #          linewidth = 1,
        #          padding = 10,
        #          foreground = colors[2],
        #          background = colors[1]
        #          ),
        TextBox(
            font="FontAwesome",
            text="  ",
            foreground=colors[6],
            background=colors[1],
            padding=0,
            fontsize=16
        ),
        CPUGraph(
            border_color=colors[2],
            fill_color=colors[8],
            graph_color=colors[8],
            background=colors[1],
            border_width=1,
            line_width=1,
            core="all",
            type="box"
        ),
        # do not activate in Virtualbox - will break qtile
        # ThermalSensor(
        #                        foreground = colors[5],
        #                        foreground_alert = colors[6],
        #                        background = colors[1],
        #                        metric = True,
        #                        padding = 3,
        #                        threshold = 80
        #                        ),
        Sep(
            linewidth=1,
            padding=10,
            foreground=colors[2],
            background=colors[1]
        ),
        TextBox(
            font="FontAwesome",
            text="  ",
            foreground=colors[4],
            background=colors[1],
            padding=0,
            fontsize=16
        ),
        Memory(
            font="FontAwesome",
            foreground=colors[2],
            background=colors[1],
            padding=0,
            fontsize=12,
            format="{MemUsed: .0f}/{MemTotal: .0f}"
        ),
        Sep(
            linewidth=1,
            padding=10,
            foreground=colors[2],
            background=colors[1]
        ),
        TextBox(
            font="FontAwesome",
            text="  ",
            foreground=colors[3],
            background=colors[1],
            padding=0,
            fontsize=16
        ),
        Clock(
            foreground=colors[5],
            background=colors[1],
            fontsize=12,
            format="%Y-%m-%d %H:%M",
            mouse_callbacks={'Button1': lambda qtile: qtile.cmd_spawn("xfce4-terminal cal -3")}
        ),
        # WidgetBox(widgets=[
        #    TextBox(text="This widget is in the box"),
        #    Memory()
        # ],background=colors[1]),
        Sep(
            linewidth=1,
            padding=10,
            foreground=colors[2],
            background=colors[1]
        ),
        Systray(
            background=colors[1],
            icon_size=20,
            padding=4
        ),
    ]
    return widgets_list
コード例 #11
0
	def bold_white(self):
		return TextBox(
			font = self.font.bold,
			text = " | "
		)
コード例 #12
0
	def white(self):
		return TextBox(
			text = " | "
		)
コード例 #13
0
 def normal(self):
     return TextBox(
         font = self.font.bold,
         foreground = self.color.yellow,
         text = "  "
     )