Merge pull request #302 from jlopezzarza/master

[modules/docker] Add basic docker list module
This commit is contained in:
tobi-wan-kenobi 2018-10-18 19:25:09 +02:00 committed by GitHub
commit f7d80d8f27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 86 additions and 36 deletions

View file

@ -170,6 +170,7 @@ Modules and commandline utilities are only required for modules, the core itself
* dbus (for the module 'spotify') * dbus (for the module 'spotify')
* i3ipc (for the module 'title') * i3ipc (for the module 'title')
* pacman-contrib (for module 'arch-update') * pacman-contrib (for module 'arch-update')
* docker (for the module 'docker_ps')
# Required commandline utilities # Required commandline utilities

View file

@ -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"})))

View file

@ -60,6 +60,9 @@
"redshift": { "redshift": {
"day": { "prefix": "day" }, "night": { "prefix": "night" }, "transition": { "prefix": "trans" } "day": { "prefix": "day" }, "night": { "prefix": "night" }, "transition": { "prefix": "trans" }
}, },
"docker_ps": {
"prefix": "containers"
},
"sensors": { "sensors": {
"prefix": "sensors" "prefix": "sensors"
}, },

View file

@ -59,9 +59,9 @@
"muted": { "prefix": "" }, "muted": { "prefix": "" },
"unmuted": { "prefix": "" } "unmuted": { "prefix": "" }
}, },
"kernel": { "kernel": {
"prefix": "\uf17c" "prefix": "\uf17c"
}, },
"nic": { "nic": {
"wireless-up": { "prefix": "" }, "wireless-up": { "prefix": "" },
"wireless-down": { "prefix": "" }, "wireless-down": { "prefix": "" },
@ -91,22 +91,29 @@
"estimate": { "prefix": "" } "estimate": { "prefix": "" }
}, },
"caffeine": { "caffeine": {
"activated": {"prefix": " " }, "deactivated": { "prefix": " " } "activated": {"prefix": " " },
"deactivated": { "prefix": " " }
}, },
"xrandr": { "xrandr": {
"on": { "prefix": " "}, "off": { "prefix": " " } "on": { "prefix": " "},
"off": { "prefix": " " }
}, },
"redshift": { "redshift": {
"day": { "prefix": "" }, "night": { "prefix": "" }, "transition": { "prefix": "" } "day": { "prefix": "" },
"night": { "prefix": "" },
"transition": { "prefix": "" }
}, },
"sensors": { "docker_ps": {
"prefix": "" "prefix": ""
}, },
"traffic":{ "sensors": {
"rx": { "prefix": "" }, "prefix": ""
"tx": { "prefix": "" } },
}, "traffic":{
"mpd": { "rx": { "prefix": "" },
"tx": { "prefix": "" }
},
"mpd": {
"playing": { "prefix": "" }, "playing": { "prefix": "" },
"paused": { "prefix": "" }, "paused": { "prefix": "" },
"stopped": { "prefix": "" }, "stopped": { "prefix": "" },
@ -123,26 +130,28 @@
"github": { "github": {
"prefix": "  " "prefix": "  "
}, },
"hipchat": { "hipchat": {
"prefix": "  " "prefix": "  "
}, },
"spotify": { "spotify": {
"prefix": "  " "prefix": "  "
}, },
"publicip": { "publicip": {
"prefix": "  " "prefix": "  "
}, },
"weather": { "weather": {
"clouds": { "prefix": "" }, "clouds": { "prefix": "" },
"rain": { "prefix": "" }, "rain": { "prefix": "" },
"snow": { "prefix": "" }, "snow": { "prefix": "" },
"clear": { "prefix": "" }, "clear": { "prefix": "" },
"thunder": { "prefix": "" } "thunder": { "prefix": "" }
}, },
"taskwarrior": { "taskwarrior": {
"prefix": "  " "prefix": "  "
}, },
"progress": { "progress": {
"copying": { "prefix": "" } "copying": {
} "prefix": ""
}
}
} }