From 940172aab197b432af476de990b61c2f5d0baf05 Mon Sep 17 00:00:00 2001 From: Bernhard B Date: Sun, 28 Jul 2019 18:14:46 +0200 Subject: [PATCH 1/6] added new system module * allows to shutdown/reboot the system --- bumblebee/modules/system.py | 77 +++++++++++++++++++++++++++++++++ themes/icons/ascii.json | 5 ++- themes/icons/awesome-fonts.json | 5 ++- themes/icons/ionicons.json | 5 ++- 4 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 bumblebee/modules/system.py diff --git a/bumblebee/modules/system.py b/bumblebee/modules/system.py new file mode 100644 index 0000000..a741a6c --- /dev/null +++ b/bumblebee/modules/system.py @@ -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) + + if do_it: + bumblebee.util.execute(command) + root.destroy() + + + 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 [] diff --git a/themes/icons/ascii.json b/themes/icons/ascii.json index 6358442..c329785 100644 --- a/themes/icons/ascii.json +++ b/themes/icons/ascii.json @@ -128,6 +128,9 @@ "dunst": { "muted": { "prefix": "dunst(muted)"}, "unmuted": { "prefix": "dunst" } - } + }, + "system": { + "prefix": "system" + } } diff --git a/themes/icons/awesome-fonts.json b/themes/icons/awesome-fonts.json index ff97533..6f6916b 100644 --- a/themes/icons/awesome-fonts.json +++ b/themes/icons/awesome-fonts.json @@ -202,5 +202,8 @@ }, "vpn": { "prefix": "" - } + }, + "system": { + "prefix": "  " + } } diff --git a/themes/icons/ionicons.json b/themes/icons/ionicons.json index f2f8fc1..cfe79bb 100644 --- a/themes/icons/ionicons.json +++ b/themes/icons/ionicons.json @@ -162,6 +162,9 @@ "dunst": { "muted": { "prefix": "\uf39a"}, "unmuted": { "prefix": "\uf39b" } - } + }, + "system": { + "prefix": " \uf2a9 " + } } From 1598275b257fc78cfeea3be9b4d714bafcb3d4d4 Mon Sep 17 00:00:00 2001 From: Bernhard B Date: Sun, 28 Jul 2019 18:17:29 +0200 Subject: [PATCH 2/6] fix indentation in system module --- bumblebee/modules/system.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bumblebee/modules/system.py b/bumblebee/modules/system.py index a741a6c..db7732a 100644 --- a/bumblebee/modules/system.py +++ b/bumblebee/modules/system.py @@ -47,10 +47,10 @@ class Module(bumblebee.engine.Module): cmd=self.popup) def update(self, widgets): - pass + pass def text(self, widget): - return "" + return "" def _on_command(self, header, text, command): do_it = True From 7f8e08a83228915fe9fa29767e2d6143a746b5ef Mon Sep 17 00:00:00 2001 From: Bernhard B Date: Sun, 28 Jul 2019 18:19:49 +0200 Subject: [PATCH 3/6] fixed small bug in system module * only destroy root window if it was created --- bumblebee/modules/system.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bumblebee/modules/system.py b/bumblebee/modules/system.py index db7732a..312dc73 100644 --- a/bumblebee/modules/system.py +++ b/bumblebee/modules/system.py @@ -60,10 +60,10 @@ class Module(bumblebee.engine.Module): root.focus_set() do_it = tkmessagebox.askyesno(header, text) + root.destroy() if do_it: - bumblebee.util.execute(command) - root.destroy() + bumblebee.util.execute(command) def popup(self, widget): From b4acd7de6dc34240d63b7c55d1eed5995e7e984d Mon Sep 17 00:00:00 2001 From: 927589452 <927589452@users.noreply.github.com> Date: Tue, 30 Jul 2019 08:26:31 +0200 Subject: [PATCH 4/6] Update README.md Add line breaks in statuscommand example (this is officially supported in i3: https://i3wm.org/docs/userguide.html 4.31. ) this adds a great deal of readability to the config --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b2f8d5e..04f02d6 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,10 @@ In your i3wm configuration, modify the *status_command* for your i3bar like this ``` bar { - status_command -m -p -t + status_command \ + -m \ + -p \ + -t } ``` From 39700c58d3c3fc3b6b45972edb0678e58451e459 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Wed, 31 Jul 2019 19:53:41 +0200 Subject: [PATCH 5/6] [README] bump module count (system) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 04f02d6..de820c2 100644 --- a/README.md +++ b/README.md @@ -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) [![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) From 49903bd6467fd1f7983068ff05eca678da26b500 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Wed, 31 Jul 2019 19:53:58 +0200 Subject: [PATCH 6/6] [CI] travis: remove python 3.3 as this seems broken --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 39c71a6..2c00527 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ sudo: false language: python python: - "2.7" - - "3.3" - "3.4" - "3.5" - "3.6"