Skip to content

Commit

Permalink
Merge pull request #3 from nomandhoni-cs/testig-notification
Browse files Browse the repository at this point in the history
Added first Launch Notification, Current Time in the popup
  • Loading branch information
nomandhoni-cs authored Jan 31, 2024
2 parents c644e90 + 7d37d30 commit ddb1818
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 40 deletions.
10 changes: 5 additions & 5 deletions BuildFileForInnoSetup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Blink Eye"
#define MyAppVersion "1.1"
#define MyAppVersion "1.2"
#define MyAppPublisher "Noman Dhoni"
#define MyAppURL "https://blinkeye.vercel.app"
#define MyAppURL "https://blinkeye.vercel.app/"
#define MyAppExeName "BlinkEye.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{20148192-D3BB-4BFD-ACD6-E96DF5E4E50D}
AppId={{63B54945-8F59-4E5A-A170-A446A28BF68A}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
Expand All @@ -20,11 +20,11 @@ AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
DisableProgramGroupPage=yes
LicenseFile=C:\Users\Abdullah\Desktop\blink-eye\dist\LICENSE.txt
LicenseFile=C:\Users\Abdullah\Desktop\blink-eye\LICENSE.txt
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputDir=C:\Users\Abdullah\Desktop\New folder
OutputBaseFilename=Blink_Eye_Windows_64_V1.1
OutputBaseFilename=Blink_Eye_Windows_64_V1.2
SetupIconFile=C:\Users\Abdullah\Desktop\blink-eye\logo.ico
Compression=lzma
SolidCompression=yes
Expand Down
60 changes: 25 additions & 35 deletions blink-eye.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import tkinter as tk
import ctypes
import threading
import time
from tkinter import PhotoImage
import webbrowser
from plyer import notification
import webbrowser
import sys
import os
from datetime import datetime

# Global variable to track if the program has just been launched
launchedTime = 0

def resource_path(relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller """
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = sys._MEIPASS2
except Exception:
base_path = os.path.abspath(".")

return os.path.join(base_path, relative_path)

Logo = resource_path("logo.png")

class BlinkEyeApp:
def __init__(self):
self.root = tk.Tk()
Expand All @@ -36,13 +35,16 @@ def __init__(self):
button_image_path = resource_path("reminder-btn.png")
self.button_image = PhotoImage(file=button_image_path)

self.counter_label = tk.Label(self.root, text="", font=("Helvetica", 96), fg='white', bg='black')
self.counter_label = tk.Label(self.root, text="", font=("Helvetica", 160), fg='white', bg='black')
self.counter_label.place(relx=0.5, rely=0.4, anchor='center')

self.quote_label = tk.Label(self.root, text="Look 20 feet far away to save your eyes", font=("Helvetica", 16), fg='white', bg='black')
self.time_label = tk.Label(self.root, text="", font=("Helvetica", 24), fg='white', bg='black')
self.time_label.place(relx=0.5, rely=0.7, anchor='center')

self.quote_label = tk.Label(self.root, text="Look 20 feet far away to protect your eyes", font=("Helvetica", 32), fg='white', bg='black')
self.quote_label.place(relx=0.5, rely=0.8, anchor='center')

self.skip_button = tk.Button(self.root, image=self.button_image, command=self.skip_reminder, cursor='hand2', borderwidth=0, highlightthickness=0)
self.skip_button = tk.Button(self.root, image=self.button_image, command=self.skip_reminder, cursor='hand2', borderwidth=0, highlightthickness=0, relief=tk.FLAT, activebackground='black', activeforeground='black')
self.skip_button.place(relx=0.5, rely=0.9, anchor='center')

self.donate_button = tk.Button(self.root, text="Donate", font=("Helvetica", 12), fg='white', bg='black', bd=0, cursor='hand2', command=lambda: self.open_link("https://www.buymeacoffee.com/nomandhoni"))
Expand All @@ -54,51 +56,39 @@ def __init__(self):
self.website_button = tk.Button(self.root, text="Website", font=("Helvetica", 12), fg='white', bg='black', bd=0, cursor='hand2', command=lambda: self.open_link("https://blinkeye.vercel.app"))
self.website_button.place(relx=0.55, rely=0.95, anchor='center')

self.muted = False

def show_notification(self, message):
notification.notify(
title="Blink Eye",
message=message,
app_icon=resource_path("logo.ico"),
timeout=10,
)

def skip_reminder(self):
self.root.withdraw()
if self.muted:
self.toggle_mute()

def show_timer_popup(self):
while True:
self.root.deiconify()
self.root.attributes("-topmost", True)

for i in range(20, -1, -1):
current_time = datetime.now().strftime("%I:%M:%S %p")
self.counter_label.config(text=str(i) + "s")
self.time_label.config(text=current_time)
time.sleep(1)

self.root.withdraw()

if self.muted:
self.toggle_mute()

# Wait for 20 minutes before showing the next popup
time.sleep(1200)

def toggle_mute(self):
# Toggle audio mute/unmute using ctypes
if not self.muted:
ctypes.windll.user32.WaveOutSetVolume(0, 0)
else:
ctypes.windll.user32.WaveOutSetVolume(0, 0xFFFF)

self.muted = not self.muted

def open_link(self, link):
webbrowser.open(link)

def run(self):
global launchedTime
if launchedTime == 0:
notification.notify(
title="Blink Eye",
message="Your program has started running.",
app_icon=resource_path("logo.ico"),
timeout=3
)
# Wait for 20 minutes before showing the first popup
time.sleep(1200)
launchedTime += 1
threading.Thread(target=self.show_timer_popup).start()
self.root.mainloop()

Expand Down

0 comments on commit ddb1818

Please sign in to comment.