Exemplo n.º 1
0
        conn.on('workspace::focus', clear_title)

        # clears the title when the last window on ws was closed
        conn.on("window::close", clear_title)

        # listens for events which can trigger the title update
        conn.on("window::title", update_title)
        conn.on("window::focus", update_title)
        conn.on("binding", update_title)

        conn.main()  # run the event loop

    def window_title(self):
        resp = {
            'cached_until': self.py3.CACHE_FOREVER,
            'full_text': self.title,
        }

        return resp


if __name__ == "__main__":
    """
    Run module in test mode.
    """
    config = {
        'always_show': True,
    }
    from py3status.module_test import module_test
    module_test(Py3status, config=config)
Exemplo n.º 2
0
        vnstat_data = self.py3.command_output("vnstat --oneline b")
        values = vnstat_data.splitlines()[0].split(";")[self.slice]
        stat = dict(zip(["down", "up", "total"], map(int, values)))
        response = {"cached_until": self.py3.time_in(self.cache_timeout)}

        if self.coloring:
            response["color"] = self.py3.threshold_get_color(stat["total"])

        for x in self.thresholds_init:
            if x in stat:
                self.py3.threshold_get_color(stat[x], x)

        response["full_text"] = self.py3.safe_format(
            self.format,
            dict(
                total=self._divide_and_format(stat["total"]),
                up=self._divide_and_format(stat["up"]),
                down=self._divide_and_format(stat["down"]),
            ),
        )
        return response


if __name__ == "__main__":
    """
    Run module in test mode.
    """
    from py3status.module_test import module_test

    module_test(Py3status)
Exemplo n.º 3
0
        ]
    )

    module_test(
        Py3status,
        config={
            "api_key": os.getenv("OWM_API_KEY"),
            # Select icons
            "icons": {"200": "☔", "230_232": "🌧"},
            # Complete configuration
            "format_clouds": "{icon} {coverage}%",
            "format_humidity": "{icon} {humidity}%",
            "format_pressure": "{icon} {pressure} Pa, sea: {sea_level} Pa",
            "format_rain": "{icon} {amount:.0f} in",
            "format_snow": "{icon} {amount:.0f} in",
            "format_temperature": (
                "{icon}: max: [\?color=max {max:.0f}°F], "
                "min: [\?color=min {min:.0f}°F], "
                "current: [\?color=current {current:.0f}°F]"
            ),
            "format_wind": (
                "{icon} {degree}°, gust: {gust:.0f} mph, " "speed: {speed:.0f} mph"
            ),
            "format": ("{city}, {country}: {icon} " + all_string + "//{forecast}"),
            "format_forecast": ("{icon} " + all_string),
            # Miscellaneous
            "forecast_days": 1,
            "forecast_text_separator": "//",
        },
    )
Exemplo n.º 4
0
        )
        return response

    def _command_start(self):
        try:
            command = Popen(shlex.split(self.script_path), stdout=PIPE)
            while True:
                if command.poll() is not None:  # script has exited/died; restart it
                    command = Popen(shlex.split(self.script_path), stdout=PIPE)

                output = command.stdout.readline().decode().strip()

                if re.search(r"^#[0-9a-fA-F]{6}$", output) and not self.force_nocolor:
                    self.command_color = output
                else:
                    if output != self.command_output:
                        self.command_output = output
                        self.py3.update()
        except Exception as e:
            self.command_error = str(e)
            self.py3.update()


if __name__ == "__main__":
    """
    Run module in test mode.
    """
    from py3status.module_test import module_test

    module_test(Py3status, config={"script_path": "ping 127.0.0.1"})
Exemplo n.º 5
0
        '{wind}'
    ])

    module_test(Py3status, config={
        'api_key': os.getenv('OWM_API_KEY'),

        # Select icons
        'icons': {
            '200': "☔",
            '230_232': "🌧",
        },

        # Complete configuration
        'format_clouds': '{icon} {coverage}%',
        'format_humidity': '{icon} {humidity}%',
        'format_pressure': '{icon} {pressure} Pa, sea: {sea_level} Pa',
        'format_rain': '{icon} {amount:.0f} in',
        'format_snow': '{icon} {amount:.0f} in',
        'format_temperature': ('{icon}: max: [\?color=max {max:.0f}°F], '
                               'min: [\?color=min {min:.0f}°F], '
                               'current: [\?color=current {current:.0f}°F]'),
        'format_wind': ('{icon} {degree}°, gust: {gust:.0f} mph, '
                        'speed: {speed:.0f} mph'),
        'format': ('{city}, {country}: {icon} ' + all_string + '//{forecast}'),
        'format_forecast': ('{icon} ' + all_string),

        # Miscellaneous
        'forecast_days': 1,
        'forecast_text_separator': '//',
    })
Exemplo n.º 6
0
            self.backend = Msg(self)
        else:
            raise Exception(STRING_ERROR.format(self.ipc))

        self.thresholds_init = self.py3.get_color_names_list(self.format)

    def scratchpad(self):
        scratchpad_data = self.backend.get_scratchpad_data()

        for x in self.thresholds_init:
            if x in scratchpad_data:
                self.py3.threshold_get_color(scratchpad_data[x], x)

        response = {
            "cached_until": self.py3.time_in(self.cache_timeout),
            "full_text": self.py3.safe_format(self.format, scratchpad_data),
        }
        if scratchpad_data["urgent"]:
            response["urgent"] = True
        return response


if __name__ == "__main__":
    """
    Run module in test mode.
    """
    from py3status.module_test import module_test

    config = {"format": r"\[{ipc}\] [\?color=scratchpad {scratchpad}]"}
    module_test(Py3status, config=config)
Exemplo n.º 7
0
                # those players need the dbus module
                if player_name in ('vlc') and not dbus_available:
                    self.py3.log('%s requires the dbus python module' %
                                 player_name)
                    return None

                return player_name

        return None

    def _get_vlc(self):
        mpris = 'org.mpris.MediaPlayer2'
        mpris_slash = '/' + mpris.replace('.', '/')
        bus = dbus.SessionBus()
        proxy = bus.get_object(mpris + '.vlc', mpris_slash)
        return dbus.Interface(proxy, dbus_interface=mpris + '.Player')

    def player_control(self):
        return dict(
            full_text=self.icon,
            cached_until=self.py3.time_in(self.cache_timeout),
        )


if __name__ == "__main__":
    """
    Run module in test mode.
    """
    from py3status.module_test import module_test
    module_test(Py3status)
Exemplo n.º 8
0
    module_test(
        Py3status,
        config={
            'api_key':
            os.getenv('OWM_API_KEY'),

            # Select icons
            'icons': {
                '200': "☔",
                '230_232': "🌧",
            },

            # Complete configuration
            'format_clouds':
            '{icon} {coverage}%',
            'format_humidity':
            '{icon} {humidity}%',
            'format_pressure':
            '{icon} {pressure} Pa, sea: {sea_level} Pa',
            'format_rain':
            '{icon} {amount:.0f} in',
            'format_snow':
            '{icon} {amount:.0f} in',
            'format_temperature':
            ('{icon}: max: [\?color=max {max:.0f}°F], '
             'min: [\?color=min {min:.0f}°F], '
             'current: [\?color=current {current:.0f}°F]'),
            'format_wind': ('{icon} {degree}°, gust: {gust:.0f} mph, '
                            'speed: {speed:.0f} mph'),
            'format':
            ('{city}, {country}: {icon} ' + all_string + '//{forecast}'),
            'format_forecast': ('{icon} ' + all_string),

            # Miscellaneous
            'forecast_days':
            1,
            'forecast_text_separator':
            '//',
        })
Exemplo n.º 9
0
 module_test(
     Py3status,
     config={
         "api_key":
         os.getenv("OWM_API_KEY"),
         # Select icons
         "icons": {
             "200": "☔",
             "230_232": "🌧"
         },
         # Complete configuration
         "format_clouds":
         "{icon} {coverage}%",
         "format_humidity":
         "{icon} {humidity}%",
         "format_pressure":
         "{icon} {pressure} Pa, sea: {sea_level} Pa",
         "format_rain":
         "{icon} {amount:.0f} in",
         "format_snow":
         "{icon} {amount:.0f} in",
         "format_temperature":
         ("{icon}: max: [\?color=max {max:.0f}°F], "
          "min: [\?color=min {min:.0f}°F], "
          "current: [\?color=current {current:.0f}°F]"),
         "format_wind": ("{icon} {degree}°, gust: {gust:.0f} mph, "
                         "speed: {speed:.0f} mph"),
         "format":
         ("{city}, {country}: {icon} " + all_string + "//{forecast}"),
         "format_forecast": ("{icon} " + all_string),
         # Miscellaneous
         "forecast_days":
         1,
         "forecast_text_separator":
         "//",
     },
 )