aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LICENSE1
-rw-r--r--LICENSE.org9
-rw-r--r--README.md50
-rw-r--r--etc/config3
-rw-r--r--setup.py22
-rw-r--r--xboomx/__init__.py1
-rw-r--r--xboomx/bin/web_xboomx13
-rwxr-xr-xxboomx/bin/xboomx37
-rwxr-xr-xxboomx/bin/xboomx_path.py11
-rw-r--r--xboomx/bin/xboomx_sort.py36
-rw-r--r--xboomx/bin/xboomx_update.py31
-rw-r--r--xboomx/bin/xboomx_urls.py15
-rw-r--r--xboomx/config.py15
-rw-r--r--xboomx/db.py13
14 files changed, 256 insertions, 1 deletions
diff --git a/LICENSE b/LICENSE
index d7f1051..458fa7c 100644
--- a/LICENSE
+++ b/LICENSE
@@ -337,3 +337,4 @@ proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
+>>>>>>> b0d8f2c999236474d0101819b8ec5dc514b73ccf
diff --git a/LICENSE.org b/LICENSE.org
new file mode 100644
index 0000000..91d7289
--- /dev/null
+++ b/LICENSE.org
@@ -0,0 +1,9 @@
+Copyright (c) 2013, Yuriy Netesov
+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.
diff --git a/README.md b/README.md
index ae4c37b..a5749f4 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,52 @@
xboomx
======
-xboomx is wrapper around the dmenu. It is also a launcher
+xboomx is wrapper around the dmenu. It is also a launcher. All the things it done is just sorting commands to launch according to their launch frequency. In other words - if you launch emacs and lxterminal all the time - they will appear in the list of commands first.
+
+#Installation
+```sh
+git clone https://github.com/victorhaggqvist/xboomx
+cd xboomx
+sudo apt-get install suckless-tools # here is instrtuction for debian. really we need only dmenu
+sudo python setup.py install
+mkdir ~/.xboomx
+cp etc/config ~/.xboomx/config
+```
+
+#Config
+The config file, which if you followed the instructions above is located at `~/.xboomx/config`, contains the following a json object.
+```json
+{
+ "dmenu_params": "-b -i -nb black -nf orange -sb black -p \"#\"",
+ "ignorelist": ["X"]
+}
+```
+
+For `dmenu_params` please see the manpages for dmenu.
+```sh
+man dmenu
+```
+
+The `ignorelist` to prevent stuff that is in your path for showing up as suggestions. Like if you type `x` then `X` might show up before `xbmc`.
+
+#License
+ xboomx
+ Copyright (C) 2014 Victor Häggqvist
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+For original license see the file`LICENSE.org`
+
+This is a fork of https://bitbucket.org/dehun/xboomx
diff --git a/etc/config b/etc/config
new file mode 100644
index 0000000..15eb62e
--- /dev/null
+++ b/etc/config
@@ -0,0 +1,3 @@
+{
+ "dmenu_params": "-i -nb black -nf orange -sb black -p \"#\""
+} \ No newline at end of file
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..fe1a6c3
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,22 @@
+from setuptools import setup
+
+
+setup(
+ name='xboomx',
+ version='0.50',
+ packages=['xboomx'],
+ scripts=['xboomx/bin/xboomx_path.py',
+ 'xboomx/bin/xboomx_sort.py',
+ 'xboomx/bin/xboomx_update.py',
+ 'xboomx/bin/xboomx_urls.py',
+ 'xboomx/bin/web_xboomx',
+ 'xboomx/bin/xboomx'],
+ license='BSD',
+ long_description='wrapper for most common occurences in dmenu',
+ install_requires=[],
+ include_package_data=True,
+ package_data={'shared': ["etc/config"]},
+ author="Yuriy Netesov",
+ author_email="[email protected]",
+ url="https://bitbucket.org/dehun/xboomx/",
+)
diff --git a/xboomx/__init__.py b/xboomx/__init__.py
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/xboomx/__init__.py
@@ -0,0 +1 @@
+
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()
diff --git a/xboomx/config.py b/xboomx/config.py
new file mode 100644
index 0000000..a98ef03
--- /dev/null
+++ b/xboomx/config.py
@@ -0,0 +1,15 @@
+import os
+import json
+import logging
+
+
+def load_config():
+ try:
+ with open(os.getenv("HOME") + "/.xboomx/config") as config_file:
+ return json.loads('\n'.join(config_file.readlines()))
+ except:
+ logging.error("Failed to load config file")
+ return {}
+
+
+config = load_config()
diff --git a/xboomx/db.py b/xboomx/db.py
new file mode 100644
index 0000000..fd099e3
--- /dev/null
+++ b/xboomx/db.py
@@ -0,0 +1,13 @@
+import shelve
+import os
+
+
+def open_shelve(db_type=''):
+ # create dir if not exists
+ try:
+ os.makedirs(os.getenv("HOME") + '/.xboomx')
+ except:
+ pass
+
+ # open shelve
+ return shelve.open(os.getenv("HOME") + '/.xboomx/xboomx%s.db' % db_type)