Commits

Anonymous committed c1e1182

Initial commit

Comments (0)

Files changed (5)

+from setuptools import setup
+
+setup(
+    name='xboomx',
+    version='0.1dev',
+    packages=['xboomx'],
+scripts=['xboomx/bin/xboomx_sort.py',
+         'xboomx/bin/xboomx_update.py',
+         'xboomx/bin/xboomx'],
+license='BSD',
+long_description='wrapper for most common occurences in dmenu',
+install_requires=[]
+)

xboomx/__init__.py

Empty file added.

xboomx/bin/xboomx

+#!/usr/bin/python
+
+import os
+
+DMENU_LAUNCHER = 'dmenu'
+
+os.system("bash -c 'dmenu_path | xboomx_sort.py | " + DMENU_LAUNCHER +  "| xboomx_update.py'")

xboomx/bin/xboomx_sort.py

+import shelve
+import fileinput
+
+
+def main():
+    # open db
+    db = shelve.open('~/.xboomx/xboomx.db')
+
+    # read lines and set weight according to db
+    items = []
+
+    for input_item in fileinput.input():
+        items.append((db.get(input_item, 0), input_item))
+
+
+    # sort items
+    items.sort(key= lambda x: x[0])
+
+    # print items
+    for item in items:
+        print item[1]
+
+    # clean up
+    db.close()
+
+
+
+
+main()

xboomx/bin/xboomx_update.py

+import shelve
+import fileinput
+
+
+def main():
+    # open db
+    db = shelve.open('~/.xboomx/xboomx.db')
+
+    # get item to update
+    item = fileinput.input().next()
+
+    # update item
+    db[item] = db.get(item, 0) + 1
+
+    # clean up
+    db.sync()
+    db.close()
+
+
+main()