From 650d7477915648ac1c2489b1d2788a71d4fccef0 Mon Sep 17 00:00:00 2001 From: Christian Colglazier Date: Fri, 18 Sep 2020 08:40:44 -0400 Subject: [PATCH] Desktop start up with additional Firefox windows --- requirements.txt | 2 +- scripts/launch-stocks-tracker.py | 29 +++++++++++++++++++++++++++++ scripts/system-start-audio.sh | 6 ++++-- 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 scripts/launch-stocks-tracker.py diff --git a/requirements.txt b/requirements.txt index a25f34e..49398ec 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -configparser todoist-python tbapy \ No newline at end of file +configparser todoist-python tbapy holidays diff --git a/scripts/launch-stocks-tracker.py b/scripts/launch-stocks-tracker.py new file mode 100644 index 0000000..af745ea --- /dev/null +++ b/scripts/launch-stocks-tracker.py @@ -0,0 +1,29 @@ +import datetime, holidays, os +from dateutil.tz import tzlocal + +tz = tzlocal() +usHolidays = holidays.US() +def openToday(now = None): + if not now: + now = datetime.datetime.now(tz) + openTime = datetime.time(hour = 9, minute = 30, second = 0) + closeTime = datetime.time(hour = 16, minute = 0, second = 0) + # If it is a holiday + if now.strftime('%Y-%m-%d') in usHolidays: + return False + # If it is a weekend + if now.date().weekday() > 4: + return False + return True + + +def closed(): + now = datetime.datetime.now(tz) + closeTime = datetime.time(hour = 16, minute = 0, second = 0) + # If before 0930 or after 1600 + if (now.time() > closeTime): + return True + return False +if (openToday() and not closed()): + print("Open") + os.system("i3-msg 'workspace 10; exec firefox --new-window robinhood.com'") diff --git a/scripts/system-start-audio.sh b/scripts/system-start-audio.sh index 3b21bfb..bfed0bb 100644 --- a/scripts/system-start-audio.sh +++ b/scripts/system-start-audio.sh @@ -26,8 +26,10 @@ function fixPulse() { function launchi3() { if [ -z "$skipi3" ]; then echo Opening i3wm sound workspaces - sleep .1 && i3-msg 'workspace 10; exec google-play-music-desktop-player' sleep .1 && i3-msg 'workspace 5; exec firefox' + sleep .1 && i3-msg 'workspace 10; exec firefox --new-window music.youtube.com' + sleep .1 && python python ~/.config/scripts/launch-stocks-tracker.py + sleep .1 && i3-msg 'workspace 10; exec firefox --new-window youtube.com/feed/subscriptions' fi } @@ -45,7 +47,7 @@ killPulse # Start up jack cadence-session-start --system-start & -wait %1 +wait %1 && sleep 1 ladish_control sload studio # Make start up reliable