Compare commits
10 Commits
Author | SHA1 | Date |
---|---|---|
Nemo | ef43ce5942 | |
Nemo | 52a2dbc94b | |
Nemo | be8b61530f | |
Nemo | 249f3f1b84 | |
Nemo | b751bcd74c | |
Nemo | 30a38bd769 | |
Nemo | a78796e029 | |
Nemo | c10614c2bd | |
Nemo | 5736b65bb4 | |
Nemo | 3117a7948e |
|
@ -0,0 +1,3 @@
|
|||
ko_fi: captn3m0
|
||||
liberapay: captn3m0
|
||||
github: captn3m0
|
|
@ -21,3 +21,4 @@ pip-delete-this-directory.txt
|
|||
|
||||
pyvenv.cfg
|
||||
bin/
|
||||
.coverage
|
||||
|
|
|
@ -13,8 +13,11 @@ python:
|
|||
install:
|
||||
- pip install requests
|
||||
- pip install nose
|
||||
- pip install coverage
|
||||
- pip install coveralls
|
||||
# command to run tests, e.g. python setup.py test
|
||||
script: nosetests --nocapture
|
||||
script: coverage run --source=hackertray $(which nosetests)
|
||||
after_success: coveralls
|
||||
notifications:
|
||||
email:
|
||||
on_success: never
|
||||
|
|
|
@ -3,6 +3,13 @@ This file will only list released and supported versions, usually skipping over
|
|||
Unreleased
|
||||
==========
|
||||
|
||||
4.0.2
|
||||
=====
|
||||
|
||||
* Adds a --reverse flag for users with bar at the bottom of their screen
|
||||
* Uses markup to keep points in fixed-width, so titles are more readable
|
||||
* Removes the buggy hover-out behaviour (non-appindicator). You now need to click elsewhere to close the menu
|
||||
|
||||
4.0.1
|
||||
=====
|
||||
|
||||
|
@ -15,6 +22,7 @@ Unreleased
|
|||
* Upgrades to Python 3.0. Python 2 is no longer supported
|
||||
* Switches from PyGtk to PyGObject.
|
||||
* AppIndicator is no longer supported, because it is Python 2 only
|
||||
* Removed all MixPanel tracking.
|
||||
|
||||
3.0.0
|
||||
=====
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
Copyright 2021 Abhay Rana
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
12
README.md
12
README.md
|
@ -2,12 +2,11 @@
|
|||
|
||||
[![HackerTray on PyPi](https://pypip.in/v/hackertray/badge.png)](https://pypi.python.org/pypi/hackertray/)
|
||||
[![HackerTray on PyPi](https://pypip.in/d/hackertray/badge.png)](https://pypi.python.org/pypi/hackertray/)
|
||||
[![Build Status](https://travis-ci.org/captn3m0/hackertray.png)](https://travis-ci.org/captn3m0/hackertray)
|
||||
[![Build Status](https://travis-ci.org/captn3m0/hackertray.png)](https://travis-ci.org/captn3m0/hackertray) [![Coverage Status](https://coveralls.io/repos/github/captn3m0/hackertray/badge.svg?branch=master)](https://coveralls.io/github/captn3m0/hackertray?branch=master)
|
||||
|
||||
HackerTray is a simple [Hacker News](https://news.ycombinator.com/) Linux application
|
||||
that lets you view top HN stories in your System Tray. It relies on appindicator, so
|
||||
it is not guaranteed to work on all systems. It also provides a Gtk StatusIcon fallback
|
||||
in case AppIndicator is not available.
|
||||
that lets you view top HN stories in your System Tray. It uses appindicator where available,
|
||||
but provides a Gtk StatusIcon fallback in case AppIndicator is not available.
|
||||
|
||||
The inspiration for this came from [Hacker Bar](http://hackerbarapp.com), which is Mac-only.
|
||||
|
||||
|
@ -60,6 +59,7 @@ HackerTray accepts its various options via the command line. Run `hackertray -h`
|
|||
1. `-c`: Enables comments support. Clicking on links will also open the comments page on HN. Can be switched off via the UI, but the setting is not remembered.
|
||||
2. `--chrome PROFILE-PATH`: Specifying a profile path to a chrome directory will make HackerTray read the Chrome History file to mark links as read. Links are checked once every 5 minutes, which is when the History file is copied (to override the lock in case Chrome is open), searched using sqlite and deleted. This feature is still experimental.
|
||||
3. `--firefox PROFILE-PATH`: Specify path to a firefox profile directory. HackerTray will read your firefox history from this profile, and use it to mark links as read. Pass `auto` as PROFILE-PATH to automatically read the default profile and use that.
|
||||
4. `--reverse` (or `-r`). Switches the order for the elements in the menu, so Quit is at top. Use this if your system bar is at the bottom of the screen.
|
||||
|
||||
Note that the `--chrome` and `--firefox` options are independent, and can be used together. However, they cannot be specified multiple times (so reading from 2 chrome profiles is not possible).
|
||||
|
||||
|
@ -107,7 +107,7 @@ To develop on hackertray, or to test out experimental versions, do the following
|
|||
|
||||
On every launch, a request is made to `https://pypi.python.org/pypi/hackertray/json` to check the latest version.
|
||||
|
||||
**No more tracking**. All data every collected for this project has been deleted. You can see [the wiki](https://github.com/captn3m0/hackertray/wiki/Analytics) for what all was collected earlier.
|
||||
**No more tracking**. All data every collected for this project has been deleted. You can see [the wiki](https://github.com/captn3m0/hackertray/wiki/Analytics) for what all was collected earlier (Version `< 4.0.0`).
|
||||
|
||||
## Credits
|
||||
|
||||
|
@ -117,4 +117,4 @@ On every launch, a request is made to `https://pypi.python.org/pypi/hackertray/j
|
|||
|
||||
## Licence
|
||||
|
||||
Licenced under the [MIT Licence](https://nemo.mit-license.org/).
|
||||
Licenced under the [MIT Licence](https://nemo.mit-license.org/). See the LICENSE file for complete license text.
|
||||
|
|
|
@ -54,40 +54,41 @@ class HackerNewsApp:
|
|||
|
||||
# The default state is false, and it toggles when you click on it
|
||||
self.commentState = args.comments
|
||||
self.reverse = args.reverse
|
||||
|
||||
# create items for the menu - refresh, quit and a separator
|
||||
menuSeparator = Gtk.SeparatorMenuItem()
|
||||
menuSeparator.show()
|
||||
self.menu.append(menuSeparator)
|
||||
self.add(menuSeparator)
|
||||
|
||||
btnComments = Gtk.CheckMenuItem("Show Comments")
|
||||
btnComments.show()
|
||||
btnComments.set_active(args.comments)
|
||||
btnComments.set_draw_as_radio(True)
|
||||
btnComments.connect("activate", self.toggleComments)
|
||||
self.menu.append(btnComments)
|
||||
self.add(btnComments)
|
||||
|
||||
btnAbout = Gtk.MenuItem("About")
|
||||
btnAbout.show()
|
||||
btnAbout.connect("activate", self.showAbout)
|
||||
self.menu.append(btnAbout)
|
||||
self.add(btnAbout)
|
||||
|
||||
btnRefresh = Gtk.MenuItem("Refresh")
|
||||
btnRefresh.show()
|
||||
# the last parameter is for not running the timer
|
||||
btnRefresh.connect("activate", self.refresh, True, args.chrome)
|
||||
self.menu.append(btnRefresh)
|
||||
self.add(btnRefresh)
|
||||
|
||||
if Version.new_available():
|
||||
btnUpdate = Gtk.MenuItem("New Update Available")
|
||||
btnUpdate.show()
|
||||
btnUpdate.connect('activate', self.showUpdate)
|
||||
self.menu.append(btnUpdate)
|
||||
self.add(btnUpdate)
|
||||
|
||||
btnQuit = Gtk.MenuItem("Quit")
|
||||
btnQuit.show()
|
||||
btnQuit.connect("activate", self.quit)
|
||||
self.menu.append(btnQuit)
|
||||
self.add(btnQuit)
|
||||
self.menu.show()
|
||||
self.ind.set_menu(self.menu)
|
||||
|
||||
|
@ -95,6 +96,12 @@ class HackerNewsApp:
|
|||
args.firefox = Firefox.default_firefox_profile_path()
|
||||
self.refresh(chrome_data_directory=args.chrome, firefox_data_directory=args.firefox)
|
||||
|
||||
def add(self, item):
|
||||
if self.reverse:
|
||||
self.menu.prepend(item)
|
||||
else:
|
||||
self.menu.append(item)
|
||||
|
||||
def toggleComments(self, widget):
|
||||
"""Whether comments page is opened or not"""
|
||||
self.commentState = not self.commentState
|
||||
|
@ -149,8 +156,12 @@ class HackerNewsApp:
|
|||
if item['points'] == 0 or item['points'] is None:
|
||||
return
|
||||
|
||||
i = Gtk.CheckMenuItem(
|
||||
"(" + str(item['points']).zfill(3) + "/" + str(item['comments_count']).zfill(3) + ") " + item['title'])
|
||||
points = str(item['points']).zfill(3) + "/" + str(item['comments_count']).zfill(3)
|
||||
|
||||
i = Gtk.CheckMenuItem.new_with_label(label="(" + points + ")"+item['title'])
|
||||
label = i.get_child()
|
||||
label.set_markup("<tt>" + points + "</tt> <span>"+item['title']+"</span>".format(points=points, title=item['title']))
|
||||
label.set_selectable(False)
|
||||
|
||||
visited = item['history'] or item['id'] in self.db
|
||||
|
||||
|
@ -161,7 +172,10 @@ class HackerNewsApp:
|
|||
i.signal_id = i.connect('activate', self.open)
|
||||
i.hn_id = item['id']
|
||||
i.item_id = item['id']
|
||||
self.menu.prepend(i)
|
||||
if self.reverse:
|
||||
self.menu.append(i)
|
||||
else:
|
||||
self.menu.prepend(i)
|
||||
i.show()
|
||||
|
||||
def refresh(self, widget=None, no_timer=False, chrome_data_directory=None, firefox_data_directory=None):
|
||||
|
@ -207,11 +221,10 @@ class HackerNewsApp:
|
|||
def main():
|
||||
parser = argparse.ArgumentParser(description='Hacker News in your System Tray')
|
||||
parser.add_argument('-v', '--version', action='version', version=Version.current())
|
||||
parser.add_argument('-c', '--comments', dest='comments', action='store_true', help="Load the HN comments link for the article as well")
|
||||
parser.add_argument('-c', '--comments', dest='comments', default=False, action='store_true', help="Load the HN comments link for the article as well")
|
||||
parser.add_argument('--chrome', dest='chrome', help="Specify a Google Chrome Profile directory to use for matching chrome history")
|
||||
parser.add_argument('--firefox', dest='firefox', help="Specify a Firefox Profile directory to use for matching firefox history. Pass auto to automatically pick the default profile")
|
||||
parser.set_defaults(comments=False)
|
||||
parser.set_defaults(dnt=False)
|
||||
parser.add_argument('-r', '--reverse', dest='reverse', default=False, action='store_true', help="Reverse the order of items. Use if your status bar is at the bottom of the screen")
|
||||
args = parser.parse_args()
|
||||
indicator = HackerNewsApp(args)
|
||||
indicator.run()
|
||||
|
|
|
@ -82,30 +82,5 @@ class Indicator:
|
|||
# Show the menu
|
||||
self.menu.popup(None, None, None, 0, 0, Gtk.get_current_event_time())
|
||||
|
||||
# Get the location and size of the window
|
||||
mouse_rect = self.menu.get_window().get_frame_extents()
|
||||
|
||||
self.x = mouse_rect.x
|
||||
self.y = mouse_rect.y
|
||||
self.right = self.x + mouse_rect.width
|
||||
self.bottom = self.y + mouse_rect.height
|
||||
|
||||
# Set a timer to poll the menu
|
||||
self.timer = GLib.timeout_add(100, self.check_mouse)
|
||||
|
||||
def check_mouse(self):
|
||||
if not self.menu.get_window().is_visible():
|
||||
return
|
||||
|
||||
# Now check the global mouse coords
|
||||
root = self.menu.get_screen().get_root_window()
|
||||
|
||||
_,x,y,_ = root.get_pointer()
|
||||
|
||||
if (x < (self.x-10)) or (x > self.right) or (y < (self.y+10)) or (y > self.bottom):
|
||||
self.hide_menu()
|
||||
else:
|
||||
return True
|
||||
|
||||
def hide_menu(self):
|
||||
self.menu.popdown()
|
||||
|
|
2
setup.py
2
setup.py
|
@ -6,7 +6,7 @@ from setuptools import find_packages
|
|||
requirements = ['requests']
|
||||
|
||||
setup(name='hackertray',
|
||||
version='4.0.1',
|
||||
version='4.0.2',
|
||||
description='Hacker News app that sits in your System Tray',
|
||||
long_description='HackerTray is a simple Hacker News Linux application that lets you view top HN stories in your System Tray. It supports appindicator and falls back to Gtk StatusIcon otherwise.',
|
||||
keywords='hacker news hn tray system tray icon hackertray',
|
||||
|
|
Loading…
Reference in New Issue