aboutsummaryrefslogtreecommitdiff
path: root/xboomx/bin/xboomx
diff options
context:
space:
mode:
Diffstat (limited to 'xboomx/bin/xboomx')
-rwxr-xr-xxboomx/bin/xboomx53
1 files changed, 28 insertions, 25 deletions
diff --git a/xboomx/bin/xboomx b/xboomx/bin/xboomx
index c8865dc..98641ee 100755
--- a/xboomx/bin/xboomx
+++ b/xboomx/bin/xboomx
@@ -1,35 +1,38 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+__author__ = 'Victor Häggqvist, Yuriy Netesov'
+__copyright__ = 'Copyright 2014-2015, Victor Häggqvist'
+__credits__ = ['Victor Häggqvist', 'Yuriy Netesov']
+__license__ = 'GPL-2.0'
+__version__ = '0.7.0'
+__maintainer__ = 'Victor Häggqvist <[email protected]>'
+
import subprocess
from xboomx.config import config
-import xboomx.db
+from xboomx.sqlitemgr import get_session, PathItem
import sys
+def main():
+ if len(sys.argv) > 1 and sys.argv[1] == "--stats":
+ session = get_session()
+ items = session.query(PathItem).order_by(PathItem.count.desc())
-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()
+ print('Application\tLaunches')
+ for item in items:
+ if item.count < 3:
+ continue
- # sort items
- items.sort(key=lambda x: x[1], reverse=True)
+ if len(item.name) < 8:
+ print('%s\t\t%s' % (item.name, item.count))
+ else:
+ print('%s\t%s' % (item.name, item.count))
- # 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)
- exit(0)
+ dmenu_launcher = 'dmenu ' + config.get("dmenu_params", "")
-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)
-subprocess.call("xboomx_path.py | xboomx_sort.py | " + DMENU_LAUNCHER + "| xboomx_update.py | xargs -I {} sh -c \'exec {} &\'", shell=True)
+if __name__ == '__main__':
+ main()