Merge pull request #302 from jlopezzarza/master
[modules/docker] Add basic docker list module
This commit is contained in:
commit
f7d80d8f27
4 changed files with 86 additions and 36 deletions
|
@ -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
|
||||
|
||||
|
|
37
bumblebee/modules/docker_ps.py
Normal file
37
bumblebee/modules/docker_ps.py
Normal 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"})))
|
|
@ -60,6 +60,9 @@
|
|||
"redshift": {
|
||||
"day": { "prefix": "day" }, "night": { "prefix": "night" }, "transition": { "prefix": "trans" }
|
||||
},
|
||||
"docker_ps": {
|
||||
"prefix": "containers"
|
||||
},
|
||||
"sensors": {
|
||||
"prefix": "sensors"
|
||||
},
|
||||
|
|
|
@ -91,13 +91,20 @@
|
|||
"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": "" }
|
||||
},
|
||||
"docker_ps": {
|
||||
"prefix": ""
|
||||
},
|
||||
"sensors": {
|
||||
"prefix": ""
|
||||
|
@ -143,6 +150,8 @@
|
|||
"prefix": " "
|
||||
},
|
||||
"progress": {
|
||||
"copying": { "prefix": "" }
|
||||
"copying": {
|
||||
"prefix": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue