aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-11-19 03:20:12 +0100
committerMattias Andrée <maandree@operamail.com>2015-11-19 03:21:17 +0100
commit46eb4985359ca5f52b8ccbad9d7ad11ba77b67d2 (patch)
tree72f3d2b3adcd3251156ce01bdb02f38341e15c14
parentfix issue #1 (diff)
downloadxpybar-46eb4985359ca5f52b8ccbad9d7ad11ba77b67d2.tar.gz
xpybar-46eb4985359ca5f52b8ccbad9d7ad11ba77b67d2.tar.bz2
xpybar-46eb4985359ca5f52b8ccbad9d7ad11ba77b67d2.tar.xz
prefer graphicsmagick over imagemagick
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--DEPENDENCIES3
-rw-r--r--src/plugins/image.py18
2 files changed, 19 insertions, 2 deletions
diff --git a/DEPENDENCIES b/DEPENDENCIES
index 441f2f0..0e629f6 100644
--- a/DEPENDENCIES
+++ b/DEPENDENCIES
@@ -18,7 +18,8 @@ OPTIONAL RUNTIME DEPENDENCIES:
inotify-tools: for inotify support
alarm: for limiting the time of a file search in locks
findutils: for file search in locks
- imagemagic: for image support
+ graphicsmagick: for image support
+ imagemagick: for image support (used if graphicmagick is not installed)
file: for image support
librsvg: for image support
diff --git a/src/plugins/image.py b/src/plugins/image.py
index 20511e5..5653ed7 100644
--- a/src/plugins/image.py
+++ b/src/plugins/image.py
@@ -71,7 +71,8 @@ class Image:
if not convert.wait() == 0:
raise Exception('Image could not be converted')
- convert = ['convert', '-', '-background', background, '-alpha', 'remove', '-depth', '8']
+ convert = ['gm'] if Image.have_graphicsmagick() else []
+ convert += ['convert', '-', '-background', background, '-alpha', 'remove', '-depth', '8']
if width is not None:
convert += ['-resize', '%ix%i!' % (width, height)]
convert += ['ppm:-']
@@ -131,6 +132,21 @@ class Image:
@staticmethod
+ def have_graphicsmagick():
+ '''
+ Figure out whether graphicsmagick is installed
+
+ @return :bool Whether graphicsmagick is installed
+ '''
+ import os
+ path = os.environ['PATH'] if 'PATH' in os.environ else '/usr/local/bin:/usr/bin:/bin';
+ for p in [p + '/gm' for p in path.split(':') if not p == '']:
+ if os.access(p, os.X_OK):
+ return True
+ return False
+
+
+ @staticmethod
def find_icon(name, width, height, preferences):
'''
Find and image for in abstract icon