diff options
author | Mattias Andrée <maandree@operamail.com> | 2015-04-04 03:52:21 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2015-04-04 03:52:21 +0200 |
commit | efe4ff0ca5d236c7d7975ccb708259b9754d4733 (patch) | |
tree | 59bf46c7aefc6ee45ee1b2dc9ff45675d00a9543 | |
parent | m (diff) | |
download | xpybar-efe4ff0ca5d236c7d7975ccb708259b9754d4733.tar.gz xpybar-efe4ff0ca5d236c7d7975ccb708259b9754d4733.tar.bz2 xpybar-efe4ff0ca5d236c7d7975ccb708259b9754d4733.tar.xz |
fix errors in image plugin + begin on launchers
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | examples/launchers | 56 | ||||
-rw-r--r-- | src/plugins/image.py | 10 |
4 files changed, 64 insertions, 9 deletions
@@ -33,17 +33,17 @@ PLUGINS = chase clock cpuinfo cpuonline cpu df discstats ipaddress \ pacman snmp snmp6 softirqs solar uname uptime users \ vmstat weather xdisplay xkb alsa dentrystate inodestate \ files hdparm tzclock ropty ping inotify random swaps \ - locks + locks images PLUGIN_EXAMPLES = chase clock cpu cpuinfo cpuonline df discstats \ ipaddress kmsg loadavg lunar mem moc network \ pacman uname uptime users xdisplay xkb alsa \ dentrystate inodestate files tzclock ropty ping \ - inotify random swaps locks + inotify random swaps locks images TRICK_EXAMPLES = localutcclock anytzclock -EXAMPLES = mixed moderate test xmonad +EXAMPLES = mixed moderate test xmonad launchers @@ -11,7 +11,6 @@ List of plugins to implement: /proc/acpi (mute) System tray Eyes - Launchers Taskbar (as in rarity) Application menu UPS diff --git a/examples/launchers b/examples/launchers new file mode 100644 index 0000000..e0bcd67 --- /dev/null +++ b/examples/launchers @@ -0,0 +1,56 @@ +# -*- python -*- +''' +xpybar – xmobar replacement written in python +Copyright © 2014, 2015 Mattias Andrée (maandree@member.fsf.org) + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. +''' + +# A xpybar configuration example when application launchers + +import time +import threading + +from plugins.image import Image + + +OUTPUT, HEIGHT, YPOS, TOP = 0, 24, 24, True + + +class Launcher: + def __init__(self, icon, *command): + self.icon = Image(icon, height = HEIGHT, icon = '/' not in icon) + self.command = list(command) + + +launchers = [ ('dia', 'dia') + , ('inkscape', 'inkscape') + , ('gimp', 'gimp') + , ('calligrakrita', 'krita') + , ('blender', 'blender') + , ('/usr/share/pixmaps/openscad.png', 'openscad') + ] + + + +launchers = [Launcher(x[0], *x[1:]) for x in launchers] + + +def redraw(): + bar.clear() + offset = 0 + for launcher in launchers: + launcher.icon.draw(bar, offset, 0) + offset += HEIGHT + diff --git a/src/plugins/image.py b/src/plugins/image.py index ccb8b29..d72e829 100644 --- a/src/plugins/image.py +++ b/src/plugins/image.py @@ -109,8 +109,8 @@ class Image: i = 0 for _i in range(len(buf) // 3): self.data.append(buf[i]) - self.data.append(buf[i + 1]) self.data.append(buf[i + 2]) + self.data.append(buf[i + 1]) self.data.append(0) i += 3 self.data = bytes(self.data) @@ -154,7 +154,7 @@ class Image: dname = name.split('/')[0] if '/' in name else None iname = name.split('/')[-1] - preferred_size = int((width ** 2 + height ** 2) ** 0.5) if width is not None else None + preferred_size = (width + height) // 2 if width is not None else None def order_themes(themes): themes, pre, post, state = set(themes), [], [], 0 @@ -169,13 +169,13 @@ class Image: def order_sizes(sizes): sizes = [t(lambda : int(s.split('x')[0]), -1) for s in sizes] if preferred_size is not None: - high = [s for s in sizes if (s > 0) and (s > preferred_size)] - low = [s for s in sizes if (s > 0) and (s < preferred_size)] + high = [s for s in sizes if (s > 0) and (s >= preferred_size)] + low = [s for s in sizes if (s > 0) and (s < preferred_size)] high.sort() low.sort() high = ['%ix%i' % (s, s) for s in high] low = ['%ix%i' % (s, s) for s in reversed(low)] - return ['%ix%i' % (preferred_size, preferred_size)] + high + ['scalable'] + low + return high + ['scalable'] + low else: sizes.sort() return ['scalable'] + reversed(sizes) |