Merge branch 'master' of github.com:tobi-wan-kenobi/bumblebee-status

This commit is contained in:
Milos Miljanic 2019-07-31 23:28:47 +02:00
commit f8cdb18861
No known key found for this signature in database
GPG key ID: 34AC6A0400650287
6 changed files with 93 additions and 4 deletions

View file

@ -2,7 +2,6 @@ sudo: false
language: python language: python
python: python:
- "2.7" - "2.7"
- "3.3"
- "3.4" - "3.4"
- "3.5" - "3.5"
- "3.6" - "3.6"

View file

@ -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, 43 of the modules are from various contributors (!), and only 19 from myself.** **Many, many thanks to all contributors! As of now, 44 of the modules are from various contributors (!), and only 19 from myself.**
![Solarized Powerline](https://github.com/tobi-wan-kenobi/bumblebee-status/blob/master/screenshots/themes/powerline-solarized.png) ![Solarized Powerline](https://github.com/tobi-wan-kenobi/bumblebee-status/blob/master/screenshots/themes/powerline-solarized.png)
@ -80,7 +80,10 @@ In your i3wm configuration, modify the *status_command* for your i3bar like this
``` ```
bar { bar {
status_command <path to bumblebee-status/bumblebee-status> -m <list of modules> -p <list of module parameters> -t <theme> status_command <path to bumblebee-status/bumblebee-status> \
-m <list of modules> \
-p <list of module parameters> \
-t <theme>
} }
``` ```

View file

@ -0,0 +1,77 @@
# -*- coding: utf-8 -*-
# pylint: disable=C0111,R0903
""" system module
adds the possibility to
* shutdown
* reboot
the system.
Per default a confirmation dialog is shown before the actual action is performed.
Paramters:
* system.confirm: show confirmation dialog before performing any action (default: true)
"""
import logging
import bumblebee.input
import bumblebee.output
import bumblebee.engine
import bumblebee.popup_v2
import functools
try:
import Tkinter as tk
import tkMessageBox as tkmessagebox
except ImportError:
# python 3
try:
import tkinter as tk
from tkinter import messagebox as tkmessagebox
except ImportError:
logging.warning("failed to import tkinter - bumblebee popups won't work!")
class Module(bumblebee.engine.Module):
def __init__(self, engine, config):
super(Module, self).__init__(engine, config,
bumblebee.output.Widget(full_text=self.text)
)
self._confirm = True
if self.parameter("confirm", "true") == "false":
self._confirm = False
engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE,
cmd=self.popup)
def update(self, widgets):
pass
def text(self, widget):
return ""
def _on_command(self, header, text, command):
do_it = True
if self._confirm:
root = tk.Tk()
root.withdraw()
root.focus_set()
do_it = tkmessagebox.askyesno(header, text)
root.destroy()
if do_it:
bumblebee.util.execute(command)
def popup(self, widget):
menu = bumblebee.popup_v2.PopupMenu()
menu.add_menuitem("shutdown", callback=functools.partial(self._on_command, "Shutdown", "Shutdown?", "shutdown -h now"))
menu.add_menuitem("reboot", callback=functools.partial(self._on_command, "Reboot", "Reboot?", "reboot"))
menu.show(widget)
def state(self, widget):
return []

View file

@ -299,5 +299,9 @@
"unmuted": { "unmuted": {
"prefix": "twmn(muted)" "prefix": "twmn(muted)"
} }
},
"system": {
"prefix": "system"
} }
} }

View file

@ -213,5 +213,8 @@
}, },
"vpn": { "vpn": {
"prefix": "" "prefix": ""
},
"system": {
"prefix": "  "
} }
} }

View file

@ -176,5 +176,8 @@
"twmn": { "twmn": {
"muted": { "prefix": "\uf1f6" }, "muted": { "prefix": "\uf1f6" },
"unmuted": { "prefix": "\uf0f3" } "unmuted": { "prefix": "\uf0f3" }
},
"system": {
"prefix": " \uf2a9 "
} }
} }