Skip to content

Commit

Permalink
Merge branch 'release/1.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefano Tranquillini committed Jun 5, 2024
2 parents 17b7fa6 + e4db778 commit d5e86a1
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# [1.1.0] - ?
- STEFANO: improving messages when connection is missing.

# [1.0.0] - 2024-03-21
- STEFANO: a lot of things happened and changed. Since approved by google, it's time to make a major.

Expand Down
2 changes: 1 addition & 1 deletion src/mvdist.fish
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
rm -r /Applications/Vince.app
rm -r -f /Applications/Vince.app
cp -r dist/Vince.app /Applications/
2 changes: 1 addition & 1 deletion src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
'argv_emulation': False,
'plist': {'LSUIElement': True,
'CFBundleName': 'Vince',
'CFBundleShortVersionString': '0.0.1',
'CFBundleShortVersionString': '1.2.0',
},
'iconfile':'icon.png',
}
Expand Down
53 changes: 47 additions & 6 deletions src/vince.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
from appdirs import user_data_dir
from bs4 import BeautifulSoup
import logging
import urllib.request
import time

logging.basicConfig(level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s')

Expand All @@ -39,6 +42,30 @@ def __init__(self):
self.app_name = "Vince"
self.settings = self.load_settings()
self.current_events = []
self.creds = None


def _has_internet(self):

try:
urllib.request.urlopen("https://www.google.com")
return True
except urllib.error.URLError:
return False
@rumps.timer(5)
def _load(self,_):
if self.creds:
return
if not self._has_internet():
print(f"Waiting for internet ... ")
self.title = "Waiting for internet ... "
quit_btn = rumps.MenuItem("Quit")
quit_btn.set_callback(self.quit)
self.menu.clear()
self.menu.add(quit_btn)
return



data_dir = user_data_dir(self.app_name)
file_path = os.path.join(data_dir, "token.json")
Expand Down Expand Up @@ -69,6 +96,8 @@ def __init__(self):

@rumps.timer(90*5)
def timely_load_events(self, _):
if not self.creds:
return
self.load_events()

def load_events(self):
Expand Down Expand Up @@ -199,21 +228,29 @@ def build_menu(self):
self.menu.add(quit_btn)

def open_browser(self, sender):
print(self.settings.get('app_meet',""))
if self.settings['link_opening_enabled']:
for url in sender.urls:
if app_meet:= self.settings.get('app_meet',""):
if url.startswith("https://meet.google.com"):
cmd = fr"open -a {app_meet} "
print(cmd)
os.system(cmd)
return

webbrowser.open(url)

@rumps.clicked("Refresh Menu")
def refresh_menu(self, _):
self.load_events()
self.build_menu()
self.update_exiting_events(None)




@rumps.timer(61)
def update_exiting_events(self, _):
if not self.creds:
return
# every 60 seconds remove the events that are past.
current_datetime = datetime.now(pytz.utc)
res = []
Expand Down Expand Up @@ -276,6 +313,8 @@ def _get_next_events(self):

@rumps.timer(1)
def update_bar_str(self, _):
if not self.creds:
return
if self.settings['show_menu_bar']:
# updates the bar
if self.menu_items:
Expand Down Expand Up @@ -347,13 +386,15 @@ def _str_event_menu_next(self, element):
if element:
hours, minutes = self._time_left(
element['start'], current_datetime)
title += f" [{element['summary'][:20]} in {hours:02d}:{minutes:02d}]"
title = f" [{element['summary'][:20]} in {hours:02d}:{minutes:02d}]"
return title
else:
return ""

@rumps.timer(1)
def send_notification_(self, _):
if not self.creds:
return
if self.settings['notifications']:

if self.menu_items:
Expand Down Expand Up @@ -385,6 +426,8 @@ def send_notification_(self, _):

@rumps.timer(1)
def send_and_open_link(self, _):
if not self.creds:
return
if self.settings['link_opening_enabled']:
# 1 min beofre the meeting it opens the browser with the link
# you can't miss it.
Expand All @@ -409,9 +452,6 @@ def send_and_open_link(self, _):
@rumps.clicked("Quit")
def quit(self, _):
print('over')
data_dir = user_data_dir(self.app_name)
file_path = os.path.join(data_dir, "token.json")
os.remove(file_path)
rumps.quit_application()

def _convert_minutes_to_epoch(self, mins):
Expand Down Expand Up @@ -481,6 +521,7 @@ def load_settings(self):
"calendars": ["primary"],
"link_opening_enabled": True,
"show_menu_bar": True,
"app_meet":"",
"notifications": [
{
"time_left": 5,
Expand Down

0 comments on commit d5e86a1

Please sign in to comment.