diff options
| -rw-r--r-- | .gitignore | 4 | ||||
| -rw-r--r-- | README.md | 7 | ||||
| -rw-r--r--[-rwxr-xr-x] | py3status/__init__.py (renamed from py3status/py3status.py) | 39 | ||||
| -rw-r--r-- | setup.py | 42 | ||||
| -rw-r--r-- | setup.sh | 18 |
5 files changed, 83 insertions, 27 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..674f765 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.pyc +build +dist +*.egg-info @@ -1,7 +1,7 @@ py3status ========= -py3status extends the mighty i3status for enhanced i3bar customization on i3wm +py3status is an extensible i3status wrapper written in python ## Documentation See the [wiki](https://github.com/ultrabug/py3status/wiki) for up to date documentation. @@ -22,9 +22,9 @@ Get into the cloned directory: $ cd .py3status -And run the setup.sh as root or via sudo: +And run the setup.py as root or via sudo: - $ sudo sh setup.sh + $ sudo python setup.py install ## Usage In your i3 config file, simply change the `status_command` with: @@ -49,3 +49,4 @@ Just pull on your local clone to get the latest py3status: $ cd .py3status $ git pull + $ sudo python setup.py install diff --git a/py3status/py3status.py b/py3status/__init__.py index 8c22fff..3dd7411 100755..100644 --- a/py3status/py3status.py +++ b/py3status/__init__.py @@ -1,6 +1,27 @@ -#!/usr/bin/python - -""" py3status wraps the mighty i3status for enhanced i3bar customization. """ +# Copyright (c) 2013, Ultrabug +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. # includes ################################################################################ @@ -89,7 +110,7 @@ def i3status(message_queue, stop_thread): Execute i3status in a thread and send its output to a Queue to py3status """ from subprocess import Popen, PIPE - i3status_pipe = Popen(['i3status', '-c', I3STATUS_CONFIG_FILE], stdout=PIPE) + i3status_pipe = Popen(['i3status', '-c', I3STATUS_CONFIG_FILE], stdout=PIPE, stderr=PIPE) message_queue.put(i3status_pipe.stdout.readline()) message_queue.put(i3status_pipe.stdout.readline()) while not stop_thread: @@ -190,12 +211,15 @@ def load_from_file(filepath): # main stuff ################################################################################ -if __name__ == '__main__': +def main(): try: + # global definition + global CACHE_TIMEOUT, DISABLE_TRANSFORM, I3STATUS_CONFIG_FILE + global I3STATUS_CONFIG, INCLUDE_PATH, INTERVAL, USER_CACHE, USER_CLASSES + # command line options PARSER = argparse.ArgumentParser(description='The agile, python-powered, i3status wrapper') PARSER = argparse.ArgumentParser(add_help=True) - PARSER = argparse.ArgumentParser(version='0.1') PARSER.add_argument('-c', action="store", dest="i3status_conf", type=str, default="/etc/i3status.conf", help="path to i3status config file") PARSER.add_argument('-d', action="store_true", dest="disable_transform", help="disable integrated transformations") PARSER.add_argument('-i', action="store", dest="include_path", type=str, default='.i3/py3status', help="user-based class include directory") @@ -254,3 +278,6 @@ if __name__ == '__main__': except Exception, err: syslog(LOG_ERR, "py3status error (%s)" % str(err)) sys.exit(1) + +if __name__ == '__main__': + main() diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..3524d4a --- /dev/null +++ b/setup.py @@ -0,0 +1,42 @@ +""" +py3status +""" + +import os +from setuptools import find_packages, setup + +# Utility function to read the README file. +# Used for the long_description. It's nice, because now 1) we have a top level +# README file and 2) it's easier to type in the README file than to put a raw +# string in below ... +def read(fname): + return open(os.path.join(os.path.dirname(__file__), fname)).read() + +setup( + name='py3status', + version='0.1', + url='https://github.com/ultrabug/py3status/wiki', + download_url='https://github.com/ultrabug/py3status', + license='BSD', + author='Ultrabug', + author_email='ultrabug@ultrabug.net', + description='py3status is an extensible i3status wrapper written in python', + long_description=read('README.md'), + zip_safe=False, + platforms='any', + packages=find_packages(), + entry_points={ + 'console_scripts': [ + 'py3status = py3status:main', + ] + }, + classifiers=[ + 'License :: OSI Approved :: BSD License', + 'Operating System :: POSIX :: Linux', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2.6', + 'Programming Language :: Python :: 2.7', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Desktop Environment :: Window Managers :: i3wm', + ], + ) diff --git a/setup.sh b/setup.sh deleted file mode 100644 index 131c4d2..0000000 --- a/setup.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -if [ ! -f py3status/py3status.py ]; then - echo "py3status/py3status.py not found, run me from the cloned directory" - exit 1 -fi - -echo -n "setting up symlink... " -if [ ! -L /usr/bin/py3status ]; then - ln -s $(pwd)/py3status/py3status.py /usr/bin/py3status || exit 2 -fi -echo "ok" - -echo -n "setting up permissions... " -chmod +x py3status/py3status.py || exit 3 -echo "ok" - -echo "setup done, enjoy !" |
