A web browser-independent bookmark manager that uses rofi as an interface to save, open or type out URL bookmarks.
git clone https://mcol.xyz/code/bkmkfi
Log | Files | Refs | README | LICENSE

commit 694891811997fc9c17239d63272376bf05c83f3b
parent 54250534bd9fe5fa357312b5cbe2f346132b39c3
Author: mclgn <mlv@posteo.net>
Date:   Sun,  2 Jun 2019 20:23:42 +0100

package with setup.py

Diffstat:
M.gitignore | 3+++
Rsrc/__init__.py -> bkmkfi/__init__.py | 0
Abkmkfi/__main__.py | 94+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Abkmkfi/__pycache__/__init__.cpython-37.pyc | 0
Abkmkfi/__pycache__/bookmarks.cpython-37.pyc | 0
Rsrc/bookmarks.py -> bkmkfi/bookmarks.py | 0
Msetup.py | 3++-
Dsrc/bkmkfi | 94-------------------------------------------------------------------------------
8 files changed, 99 insertions(+), 95 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1 +1,4 @@ src/__pycache__ +bkmkfi.egg-info/ +build/ +dist/ diff --git a/src/__init__.py b/bkmkfi/__init__.py diff --git a/bkmkfi/__main__.py b/bkmkfi/__main__.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python3 +# +# bkmkfi +# Manage web page bookmarks using rofi +# Main script +# + +from subprocess import PIPE, run +import os +import argparse + +from bkmkfi.bookmarks import Bookmarks + + +home = os.path.expanduser('~') +path = home + '/.config/bkmks.json' + + +def parse_args(): + """ + Parse command line arguments + """ + + parser = argparse.ArgumentParser( + usage = 'bkmkfi [-h | -o [COMMAND] | -d | -c | -t] [-b BOOKMARKS]', + description = 'rofi bookmark manager' + ) + + parser.add_argument( + '-f', '--file', nargs=1, + help='file containing bookmarks (default $HOME/.config/bkmks.json)', + default=[home + '/.config/bkmks'], + type=str + ) + + parser.add_argument( + '-o', '--open', nargs=1, + help='open command (e.g. "tor-browser --allow-remote %%s")', + default=[''], + type=str + ) + + parser.add_argument( + '-d', '--delete', + help='delete bookmark', + action='store_true' + ) + + parser.add_argument( + '-c', '--copy', + help='copy bookmark URL to clipboard', + action='store_true' + ) + + parser.add_argument( + '-t', '--type', + help='type bookmark URL with keyboard', + action='store_true' + ) + + args = parser.parse_args() + return args + + +# Main +def main(): + p = parse_args() + + # Create bookmarks class + bkmks = Bookmarks(p) + + # Decide what to do with it + if bkmks.selected_isnew: + # just adding an entry + bkmks.save() + + elif p.open[0]: + # open URL in new tab + bkmks.open(p.open[0]) + + elif p.type: + # type out URL + bkmks.type() + + elif p.delete: + # delete entry + bkmks.delete() + + elif p.copy: + # copy entry to clipboard + bkmks.copy() + +if __name__ == '__main__': + main() diff --git a/bkmkfi/__pycache__/__init__.cpython-37.pyc b/bkmkfi/__pycache__/__init__.cpython-37.pyc Binary files differ. diff --git a/bkmkfi/__pycache__/bookmarks.cpython-37.pyc b/bkmkfi/__pycache__/bookmarks.cpython-37.pyc Binary files differ. diff --git a/src/bookmarks.py b/bkmkfi/bookmarks.py diff --git a/setup.py b/setup.py @@ -5,7 +5,7 @@ with open("README.rst", "r") as fh: setuptools.setup( name="bkmkfi", - version="0.0.1", + version="0.1", author="mcol", author_email="mcol@posteo.net", description="rofi-based bookmarks manager", @@ -13,6 +13,7 @@ setuptools.setup( long_description_content_type="text/markdown", url="https://github.com/m-col/bkmkfi", packages=setuptools.find_packages(), + entry_points={'console_scripts': ['bkmkfi = bkmkfi.__main__:main']}, classifiers=[ "Programming Language :: Python :: 3", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", diff --git a/src/bkmkfi b/src/bkmkfi @@ -1,94 +0,0 @@ -#!/usr/bin/env python3 -# -# bkmkfi -# Manage web page bookmarks using rofi -# Main script -# - -from subprocess import PIPE, run -import os -import argparse - -from bookmarks import Bookmarks - - -home = os.path.expanduser('~') -path = home + '/.config/bkmks.json' - - -def parse_args(): - """ - Parse command line arguments - """ - - parser = argparse.ArgumentParser( - usage = 'bkmkfi [-h | -o [COMMAND] | -d | -c | -t] [-b BOOKMARKS]', - description = 'rofi bookmark manager' - ) - - parser.add_argument( - '-f', '--file', nargs=1, - help='file containing bookmarks (default $HOME/.config/bkmks.json)', - default=[home + '/.config/bkmks'], - type=str - ) - - parser.add_argument( - '-o', '--open', nargs=1, - help='open command (e.g. "tor-browser --allow-remote %%s")', - default=[''], - type=str - ) - - parser.add_argument( - '-d', '--delete', - help='delete bookmark', - action='store_true' - ) - - parser.add_argument( - '-c', '--copy', - help='copy bookmark URL to clipboard', - action='store_true' - ) - - parser.add_argument( - '-t', '--type', - help='type bookmark URL with keyboard', - action='store_true' - ) - - args = parser.parse_args() - return args - - -# Main -def main(): - p = parse_args() - - # Create bookmarks class - bkmks = Bookmarks(p) - - # Decide what to do with it - if bkmks.selected_isnew: - # just adding an entry - bkmks.save() - - elif p.open[0]: - # open URL in new tab - bkmks.open(p.open[0]) - - elif p.type: - # type out URL - bkmks.type() - - elif p.delete: - # delete entry - bkmks.delete() - - elif p.copy: - # copy entry to clipboard - bkmks.copy() - -if __name__ == '__main__': - main()