Merge branch 'master' into theme-directories
This commit is contained in:
commit
9d81d83d37
7 changed files with 106 additions and 2 deletions
|
@ -5,7 +5,7 @@
|
||||||
[![Test Coverage](https://codeclimate.com/github/tobi-wan-kenobi/bumblebee-status/badges/coverage.svg)](https://codeclimate.com/github/tobi-wan-kenobi/bumblebee-status/coverage)
|
[![Test Coverage](https://codeclimate.com/github/tobi-wan-kenobi/bumblebee-status/badges/coverage.svg)](https://codeclimate.com/github/tobi-wan-kenobi/bumblebee-status/coverage)
|
||||||
[![Issue Count](https://codeclimate.com/github/tobi-wan-kenobi/bumblebee-status/badges/issue_count.svg)](https://codeclimate.com/github/tobi-wan-kenobi/bumblebee-status)
|
[![Issue Count](https://codeclimate.com/github/tobi-wan-kenobi/bumblebee-status/badges/issue_count.svg)](https://codeclimate.com/github/tobi-wan-kenobi/bumblebee-status)
|
||||||
|
|
||||||
**Many, many thanks to all contributors! As of now, 22 of the modules are from various contributors (!), and only 16 from myself.**
|
**Many, many thanks to all contributors! As of now, 24 of the modules are from various contributors (!), and only 16 from myself.**
|
||||||
|
|
||||||
bumblebee-status is a modular, theme-able status line generator for the [i3 window manager](https://i3wm.org/).
|
bumblebee-status is a modular, theme-able status line generator for the [i3 window manager](https://i3wm.org/).
|
||||||
|
|
||||||
|
|
70
bumblebee/modules/shortcut.py
Normal file
70
bumblebee/modules/shortcut.py
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
# pylint: disable=C0112,R0903
|
||||||
|
|
||||||
|
"""Shows a widget per user-defined shortcut and allows to define the behaviour
|
||||||
|
when clicking on it.
|
||||||
|
|
||||||
|
For more than one shortcut, the commands and labels are strings separated by
|
||||||
|
a demiliter (; semicolon by default).
|
||||||
|
|
||||||
|
For example in order to create two shortcuts labeled A and B with commands
|
||||||
|
cmdA and cmdB you could do:
|
||||||
|
|
||||||
|
./bumblebee-status -m shortcut -p shortcut.cmd="ls;ps" shortcut.label="A;B"
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
* shortcut.cmds : List of commands to execute
|
||||||
|
* shortcut.labels: List of widgets' labels (text)
|
||||||
|
* shortcut.delim : Commands and labels delimiter (; semicolon by default)
|
||||||
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import bumblebee.engine
|
||||||
|
import bumblebee.output
|
||||||
|
import bumblebee.input
|
||||||
|
|
||||||
|
LINK = "https://github.com/tobi-wan-kenobi/bumblebee-status/wiki"
|
||||||
|
LABEL = "Click me"
|
||||||
|
|
||||||
|
class Module(bumblebee.engine.Module):
|
||||||
|
""" Shortcut module."""
|
||||||
|
|
||||||
|
def __init__(self, engine, config):
|
||||||
|
widgets = []
|
||||||
|
self._engine = engine
|
||||||
|
super(Module, self).__init__(engine, config, widgets)
|
||||||
|
|
||||||
|
self._labels = self.parameter("labels", "{}".format(LABEL))
|
||||||
|
self._cmds = self.parameter("cmds", "firefox {}".format(LINK))
|
||||||
|
self._delim = self.parameter("delim", ";")
|
||||||
|
|
||||||
|
self.update_widgets(widgets)
|
||||||
|
|
||||||
|
def update_widgets(self, widgets):
|
||||||
|
""" Creates a set of widget per user define shortcut."""
|
||||||
|
|
||||||
|
cmds = self._cmds.split(self._delim)
|
||||||
|
labels = self._labels.split(self._delim)
|
||||||
|
|
||||||
|
# to be on the safe side create as many widgets as there are data (cmds or labels)
|
||||||
|
num_shortcuts = min(len(cmds), len(labels))
|
||||||
|
|
||||||
|
# report possible problem as a warning
|
||||||
|
if (len(cmds) is not len(labels)):
|
||||||
|
logging.warning("shortcut: the number of commands does not match "\
|
||||||
|
"the number of provided labels.")
|
||||||
|
logging.warning("cmds : %s, labels : %s", cmds, labels)
|
||||||
|
|
||||||
|
for idx in range(0, num_shortcuts):
|
||||||
|
cmd = cmds[idx]
|
||||||
|
label = labels[idx]
|
||||||
|
|
||||||
|
widget = bumblebee.output.Widget(full_text=label)
|
||||||
|
self._engine.input.register_callback(widget, button=bumblebee.input.LEFT_MOUSE, cmd=cmd)
|
||||||
|
|
||||||
|
widgets.append(widget)
|
||||||
|
|
||||||
|
def update(self, widgets):
|
||||||
|
if len(widgets) <= 0:
|
||||||
|
self.update_widgets(widgets)
|
||||||
|
|
||||||
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
30
bumblebee/modules/uptime.py
Normal file
30
bumblebee/modules/uptime.py
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
# pylint: disable=C0111,R0903
|
||||||
|
|
||||||
|
"""Displays the system uptime."""
|
||||||
|
|
||||||
|
# Use absolute_import because there's already a datatime module
|
||||||
|
# in the same directory
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
import bumblebee.input
|
||||||
|
import bumblebee.output
|
||||||
|
import bumblebee.engine
|
||||||
|
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
|
class Module(bumblebee.engine.Module):
|
||||||
|
def __init__(self, engine, config):
|
||||||
|
super(Module, self).__init__(engine, config,
|
||||||
|
bumblebee.output.Widget(full_text=self.output)
|
||||||
|
)
|
||||||
|
self._uptime = ""
|
||||||
|
|
||||||
|
def output(self, _):
|
||||||
|
return "{}".format(self._uptime)
|
||||||
|
|
||||||
|
def update(self, widgets):
|
||||||
|
with open('/proc/uptime', 'r') as f:
|
||||||
|
uptime_seconds = int(float(f.readline().split()[0]))
|
||||||
|
self._uptime = timedelta(seconds = uptime_seconds)
|
||||||
|
|
||||||
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
BIN
screenshots/shortcut.png
Normal file
BIN
screenshots/shortcut.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
screenshots/uptime.png
Normal file
BIN
screenshots/uptime.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 980 B |
|
@ -86,5 +86,8 @@
|
||||||
},
|
},
|
||||||
"spotify": {
|
"spotify": {
|
||||||
"prefix": ""
|
"prefix": ""
|
||||||
|
},
|
||||||
|
"uptime": {
|
||||||
|
"prefix": "uptime"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,8 @@
|
||||||
"layout": { "prefix": "" },
|
"layout": { "prefix": "" },
|
||||||
"layout-xkb": { "prefix": "" },
|
"layout-xkb": { "prefix": "" },
|
||||||
"todo": { "empty": {"prefix": "" },
|
"todo": { "empty": {"prefix": "" },
|
||||||
"items": {"prefix": "" }
|
"items": {"prefix": "" },
|
||||||
|
"uptime": {"prefix": "" }
|
||||||
},
|
},
|
||||||
|
|
||||||
"cmus": {
|
"cmus": {
|
||||||
|
|
Loading…
Reference in a new issue