diff --git a/README.md b/README.md index dbc1de3..4573fba 100644 --- a/README.md +++ b/README.md @@ -170,6 +170,7 @@ Modules and commandline utilities are only required for modules, the core itself * dbus (for the module 'spotify') * i3ipc (for the module 'title') * pacman-contrib (for module 'arch-update') +* docker (for the module 'docker_ps') # Required commandline utilities diff --git a/bumblebee/modules/docker_ps.py b/bumblebee/modules/docker_ps.py new file mode 100644 index 0000000..5c1e031 --- /dev/null +++ b/bumblebee/modules/docker_ps.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- + +"""Displays the number of docker containers running + +Requires the following python packages: + * docker + +""" + +try: + import docker +except ImportError: + pass + +from requests.exceptions import ConnectionError + +import bumblebee.input +import bumblebee.output +import bumblebee.engine + + +class Module(bumblebee.engine.Module): + def __init__(self, engine, config): + widget = bumblebee.output.Widget(full_text=self.status) + super(Module, self).__init__(engine, config, widget) + self._status = self.status + + def update(self, widgets): + self._status = self.status + + def status(self, _): + cli = docker.DockerClient(base_url='unix://var/run/docker.sock') + try: + cli.ping() + except ConnectionError: + return "Daemon off" + return "OK - {}".format(len(cli.containers.list(filters={'status': "running"}))) diff --git a/themes/icons/ascii.json b/themes/icons/ascii.json index 115bd52..547e764 100644 --- a/themes/icons/ascii.json +++ b/themes/icons/ascii.json @@ -60,6 +60,9 @@ "redshift": { "day": { "prefix": "day" }, "night": { "prefix": "night" }, "transition": { "prefix": "trans" } }, + "docker_ps": { + "prefix": "containers" + }, "sensors": { "prefix": "sensors" }, diff --git a/themes/icons/awesome-fonts.json b/themes/icons/awesome-fonts.json index f041a00..9352372 100644 --- a/themes/icons/awesome-fonts.json +++ b/themes/icons/awesome-fonts.json @@ -59,9 +59,9 @@ "muted": { "prefix": "" }, "unmuted": { "prefix": "" } }, - "kernel": { - "prefix": "\uf17c" - }, + "kernel": { + "prefix": "\uf17c" + }, "nic": { "wireless-up": { "prefix": "" }, "wireless-down": { "prefix": "" }, @@ -91,22 +91,29 @@ "estimate": { "prefix": "" } }, "caffeine": { - "activated": {"prefix": " " }, "deactivated": { "prefix": " " } + "activated": {"prefix": " " }, + "deactivated": { "prefix": " " } }, "xrandr": { - "on": { "prefix": " "}, "off": { "prefix": " " } + "on": { "prefix": " "}, + "off": { "prefix": " " } }, "redshift": { - "day": { "prefix": "" }, "night": { "prefix": "" }, "transition": { "prefix": "" } + "day": { "prefix": "" }, + "night": { "prefix": "" }, + "transition": { "prefix": "" } }, - "sensors": { - "prefix": "" - }, - "traffic":{ - "rx": { "prefix": "" }, - "tx": { "prefix": "" } - }, - "mpd": { + "docker_ps": { + "prefix": "" + }, + "sensors": { + "prefix": "" + }, + "traffic":{ + "rx": { "prefix": "" }, + "tx": { "prefix": "" } + }, + "mpd": { "playing": { "prefix": "" }, "paused": { "prefix": "" }, "stopped": { "prefix": "" }, @@ -123,26 +130,28 @@ "github": { "prefix": "  " }, - "hipchat": { - "prefix": "  " - }, - "spotify": { - "prefix": "  " - }, - "publicip": { - "prefix": "  " - }, - "weather": { - "clouds": { "prefix": "" }, - "rain": { "prefix": "" }, - "snow": { "prefix": "" }, - "clear": { "prefix": "" }, - "thunder": { "prefix": "" } - }, - "taskwarrior": { - "prefix": "  " - }, - "progress": { - "copying": { "prefix": "" } - } + "hipchat": { + "prefix": "  " + }, + "spotify": { + "prefix": "  " + }, + "publicip": { + "prefix": "  " + }, + "weather": { + "clouds": { "prefix": "" }, + "rain": { "prefix": "" }, + "snow": { "prefix": "" }, + "clear": { "prefix": "" }, + "thunder": { "prefix": "" } + }, + "taskwarrior": { + "prefix": "  " + }, + "progress": { + "copying": { + "prefix": "" + } + } }