From bcbd5bb12b3a1f89948d21a7a9bc0f056db73f38 Mon Sep 17 00:00:00 2001 From: Victor Häggqvist Date: Tue, 2 Sep 2014 11:27:50 +0200 Subject: --status --- xboomx/bin/web_xboomx | 13 +++++++++++++ xboomx/bin/xboomx | 37 +++++++++++++++++++++++++++++++++++++ xboomx/bin/xboomx_path.py | 11 +++++++++++ xboomx/bin/xboomx_sort.py | 36 ++++++++++++++++++++++++++++++++++++ xboomx/bin/xboomx_update.py | 31 +++++++++++++++++++++++++++++++ xboomx/bin/xboomx_urls.py | 15 +++++++++++++++ 6 files changed, 143 insertions(+) create mode 100644 xboomx/bin/web_xboomx create mode 100755 xboomx/bin/xboomx create mode 100755 xboomx/bin/xboomx_path.py create mode 100644 xboomx/bin/xboomx_sort.py create mode 100644 xboomx/bin/xboomx_update.py create mode 100644 xboomx/bin/xboomx_urls.py (limited to 'xboomx/bin') diff --git a/xboomx/bin/web_xboomx b/xboomx/bin/web_xboomx new file mode 100644 index 0000000..67baba3 --- /dev/null +++ b/xboomx/bin/web_xboomx @@ -0,0 +1,13 @@ +#!/usr/bin/python + +import subprocess +from xboomx.config import config + + +DMENU_LAUNCHER = 'dmenu ' + config.get("dmenu_params", "") + +subprocess.call("""xboomx_urls.py | xboomx_sort.py urls | \ + """ + DMENU_LAUNCHER + """| \ + xboomx_update.py urls | \ + xargs -I {} sh -c \'exec firefox {} &\'""", + shell=True) diff --git a/xboomx/bin/xboomx b/xboomx/bin/xboomx new file mode 100755 index 0000000..2b4d266 --- /dev/null +++ b/xboomx/bin/xboomx @@ -0,0 +1,37 @@ +#!/usr/bin/python +import fileinput + +import subprocess +from xboomx.config import config +import xboomx.db +import sys + + +if len(sys.argv) > 1 and sys.argv[1] == "--stats": + db = xboomx.db.open_shelve('') + + items = [] + + keys = db.keys() + + for x in keys: + items.append([x, db.get(x, "")]) + + db.close() + + # sort items + items.sort(key=lambda x: x[1], reverse=True) + + # print items + print "Application\tLaunches" + for item in items: + if len(item[0]) < 8: + print item[0]+"\t\t"+str(item[1]) + else: + print item[0]+"\t"+str(item[1]) + + exit(0) + +DMENU_LAUNCHER = 'dmenu ' + config.get("dmenu_params", "") + +subprocess.call("xboomx_path.py | xboomx_sort.py | " + DMENU_LAUNCHER + "| xboomx_update.py | xargs -I {} sh -c \'exec {} &\'", shell=True) diff --git a/xboomx/bin/xboomx_path.py b/xboomx/bin/xboomx_path.py new file mode 100755 index 0000000..67a1cb1 --- /dev/null +++ b/xboomx/bin/xboomx_path.py @@ -0,0 +1,11 @@ +#!/usr/bin/python + +import os + +pathes = os.environ['PATH'].split(':') + + +for path in pathes: + if os.path.isdir(path): + for f in os.listdir(path): + print f diff --git a/xboomx/bin/xboomx_sort.py b/xboomx/bin/xboomx_sort.py new file mode 100644 index 0000000..a30c362 --- /dev/null +++ b/xboomx/bin/xboomx_sort.py @@ -0,0 +1,36 @@ +#!/usr/bin/python +import fileinput +import sys + +import xboomx.db + + +def main(): + + # get db type + db_type = '' + if len(sys.argv) > 1: + db_type = sys.argv[1] + + # open shelve + db = xboomx.db.open_shelve(db_type) + + # read lines and set weight according to db + items = [] + + for input_item in fileinput.input([]): + input_item = input_item.strip('\n') + items.append((db.get(input_item, 0), input_item)) + + # sort items + items.sort(key=lambda x: x[0], reverse=True) + + # print items + for item in items: + print item[1] + + # clean up + db.close() + + +main() diff --git a/xboomx/bin/xboomx_update.py b/xboomx/bin/xboomx_update.py new file mode 100644 index 0000000..892bc4c --- /dev/null +++ b/xboomx/bin/xboomx_update.py @@ -0,0 +1,31 @@ +#!/usr/bin/python +import sys +import fileinput + +import xboomx.db + + +def main(): + # get db type + db_type = '' + if len(sys.argv) > 1: + db_type = sys.argv[1] + # open db + db = xboomx.db.open_shelve(db_type) + + # get item to update + item = fileinput.input([]).next() + item = item.strip('\n') + + # update item + db[item] = db.get(item, 0) + 1 + + # print it + print item + + # clean up + db.sync() + db.close() + + +main() diff --git a/xboomx/bin/xboomx_urls.py b/xboomx/bin/xboomx_urls.py new file mode 100644 index 0000000..211c98c --- /dev/null +++ b/xboomx/bin/xboomx_urls.py @@ -0,0 +1,15 @@ +#!/usr/bin/python + +import xboomx.db +DB_TYPE = 'urls' + + +def main(): + db = xboomx.db.open_shelve(DB_TYPE) + for url in db.keys(): + print url + + db.close() + + +main() -- cgit v1.2.3