From 23f07670aaa4277ede60474ecc12a52104dbf1e7 Mon Sep 17 00:00:00 2001 From: archnotwindows <108471111+archnotwindows@users.noreply.github.com> Date: Fri, 29 Jul 2022 23:24:24 +0200 Subject: [PATCH 1/8] Update main.py --- main.py | 101 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 65 insertions(+), 36 deletions(-) diff --git a/main.py b/main.py index 962d130..fb6e655 100644 --- a/main.py +++ b/main.py @@ -1,43 +1,22 @@ -#Libraries for create a window + + import tkinter as tk -#Libraries for execute command import subprocess -#Libraries for read web browser history -from browser_history import get_history -#Libraries for date time -from datetime import datetime -#Libraries for read csv -import csv -#Print all browser history on cvs -outputs = get_history() -outputs.save("history.csv") -#Get current date -now = datetime.now() -date_time_str = now.strftime("%Y-%m-%d %H:%M") -print('DateTime String:', date_time_str) -#Search Youtube Link on history.csv -how_to_search = 'https://www.youtube.com/' -rows = [] -with open('history.csv', 'rt') as f: - reader = csv.reader(f, delimiter=',') - for line in reader: - if how_to_search in line: - print("Yes!") -#Create a window -window = tk.Tk() -#Resolution program + + +window = tk.Tk() window.geometry("800x500") -#Title program -window.title("Poweroffer") -#Background program +window.title("poweroffer") + window.configure(background="blue") + window.grid_columnconfigure(0, weight=1) -#Welcome text + scritta = tk.Label(window, text="Welcome!", font=("Helvetica",15)) scritta.grid(row=0, column=0, sticky="N", padx=20, pady=10) @@ -45,14 +24,64 @@ sito = tk.StringVar text_input= tk.Entry(textvariable=sito) text_input.grid(row=3, column=0, sticky="WE", padx=10, pady=10) -#Button stop procrastinating -second_button= tk.Button(text="Stop procrastinating") + + + +def spegni(): + subprocess.run('shutdown now', shell=True) + subprocess.run('shutdown -s -t O', shell=True) + + +def smetti(): + sito = text_input.get() + print(sito) + + f = open ("siti.dat","w") + f.write(sito) + f.close() + + a = open("executable.py","w") + a.write("#!/usr/bin/env python3 \n") + a.write("import os,json,lz4.block,time \n") + a.write("f = open(\"siti.dat\",\"r\") \n") + a.write("sito = f.read()\n") + a.write("d = open(\"/home/usr/snap/firefox/common/.mozilla/firefox/8gnxd9f4.default/sessionstore-backups/recovery.jsonlz4\", \"rb\") \n") + a.write("magic = d.read(8)\n") + a.write("data = json.loads(lz4.block.decompress(d.read()).decode(\"utf-8\"))\n") + a.write("d.close()\n") + a.write("current_window = \"\"\n") + a.write("for win in data.get(\"windows\"):\n") + a.write(" for tab in win.get(\"tabs\"):\n") + a.write(" i = int(tab.get(\"index\")) - 1 \n") + a.write(" current_window = tab.get(\"entries\")[i].get(\"url\")\n") + a.write("print(current_window)\n") + a.write("if sito in str(current_window):\n") + a.write(" print(\"Yes\")\n") + a.write(" os.system(\"shutdown now\")") + a.close() + + + b = open("executable.sh", "w") + b.write("#!/bin/bash\n") + b.write("/home/lorenzo/Scrivania/poweroffer/executable.py") + b.close() + + + + +second_button= tk.Button(text="Stop procrastinating", command=smetti) + second_button.grid(row=5, column=0, sticky="WE", padx=15, pady=8) -#Button for shutdown pc -first_button = tk.Button(text="have a break from the pc") + + +first_button = tk.Button(text="have a break from the pc", command=spegni) + first_button.grid(row=1, column=0, sticky="W", padx=50, pady=50) -#Always open window + + + + if __name__ == "__main__": - window.mainloop() \ No newline at end of file + window.mainloop() From c072966e14400b96647e9dcb696a44f976989515 Mon Sep 17 00:00:00 2001 From: archnotwindows <108471111+archnotwindows@users.noreply.github.com> Date: Fri, 29 Jul 2022 23:26:15 +0200 Subject: [PATCH 2/8] Delete .gitignore --- .gitignore | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 8e4b555..0000000 --- a/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -executable.py -executable.sh -siti.dat -history.txt -history.csv -test.py -.~lock.history.csv# \ No newline at end of file From d24beed30cc579973c08373628f48a3d9eb5cc30 Mon Sep 17 00:00:00 2001 From: archnotwindows <108471111+archnotwindows@users.noreply.github.com> Date: Fri, 29 Jul 2022 23:31:10 +0200 Subject: [PATCH 3/8] Update README.md --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bd17657..ba19f67 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,7 @@ -Poweroffer is a small and simple Python program that is used to remove distractions (like Youtube) and not procrastinate. - +Whith this simple python program you will be able to not procrastinate during the day in some sort of website (like Youtube) that you can choose! so try it out!! ## Getting Started - Install **[Python](https://python.org)** on your machine. **Version 3.10 or higher is required!** @@ -34,7 +33,7 @@ pip install -r requirements.txt ``` - To start Poweroffer, write the following command in the console: ```console -python main.py +python3 main.py ``` ## License @@ -44,7 +43,7 @@ This project is licensed under either of: ## Contact -[![gmail](https://img.shields.io/badge/Gmail-D14836?style=for-the-badge&logo=Gmail&logoColor=white)](mailto:) +[![gmail](https://img.shields.io/badge/Gmail-D14836?style=for-the-badge&logo=Gmail&logoColor=white)](mailto:lorenzo020406@gmail.com) [![github](https://img.shields.io/badge/GitHub-000000?style=for-the-badge&logo=GitHub&logoColor=white)](https://github.com/archnotwindows) [![twitter](https://img.shields.io/badge/Twitter-007fff?style=for-the-badge&logo=twitter&logoColor=white)](https://twitter.com/Lollopro59_) [![instagram](https://img.shields.io/badge/Instagram-8f00ff?style=for-the-badge&logo=instagram&logoColor=white)](https://www.instagram.com/lollog020406/) From 91886d81626d6a81d46df1c4b6a3ac4d81f491ac Mon Sep 17 00:00:00 2001 From: archnotwindows <108471111+archnotwindows@users.noreply.github.com> Date: Fri, 29 Jul 2022 23:34:59 +0200 Subject: [PATCH 4/8] Update README.md --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/README.md b/README.md index ba19f67..9a48878 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,38 @@ Whith this simple python program you will be able to not procrastinate during th - Install **[Python](https://python.org)** on your machine. **Version 3.10 or higher is required!** - Clone the repository on your machine. +- Put the poweroffer extracted folder in the Desktop +0 - Install tkinter with these commands "sudo apt-get install python3-tk" and "pip install tk" + +1 - Install os,json and time ( but probably these libraries are already installed on your system) + +2 - become a root user ( with " su " command and continue to do all the operations with root) + +3 - Install lz4.block with this command "pip install lz4" + +4 - download all the repository files and put the poweroffer folder in your desktop + +5 - open a terminal emulator and write "crontab -e" ( if is your first time you may have to choose witch editor you wanna use) + +6 - write at the end of the file this string " * * * * * /bin/bash /home/your-username/Desktop/poweroffer/executable.sh " + +7 - close the editor and save the changes + +8 - search for this file "recovery.jsonlz4" and copy it's path + +9 - edit the main.py file and scroll down until you see this + +![Istantanea_2022-07-21_14-07-03](https://user-images.githubusercontent.com/108471111/180209819-e4a4d0e0-80db-4a75-8689-e00b6b1ed44a.png) + + +10 - replace the selected area with the path you have copied + +11 - exit from the root user and login to your everyday user + +11 - open a terminal and run the index.py file using " python3 index.py " to execute the program ( use this command every time you wanna run my program :) + + + - Open your console in the cloned repository. - To complete the installation, write the following command in the console: ```console From 723c4d2f73e24f0ad0cf2ede56d1ed8d4ddec36d Mon Sep 17 00:00:00 2001 From: archnotwindows <108471111+archnotwindows@users.noreply.github.com> Date: Fri, 29 Jul 2022 23:42:06 +0200 Subject: [PATCH 5/8] Update README.md --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 9a48878..ae4a6a4 100644 --- a/README.md +++ b/README.md @@ -23,10 +23,14 @@ Whith this simple python program you will be able to not procrastinate during the day in some sort of website (like Youtube) that you can choose! so try it out!! ## Getting Started - -- Install **[Python](https://python.org)** on your machine. **Version 3.10 or higher is required!** -- Clone the repository on your machine. -- Put the poweroffer extracted folder in the Desktop + WARNING!! to use this software you must use a linux distro and the Firefox web browser + +0 - Install **[Python](https://python.org)** on your machine. **Version 3.10 or higher is required!** + +1 - Clone the repository on your machine. + +2 - Put the poweroffer extracted folder in the Desktop + 0 - Install tkinter with these commands "sudo apt-get install python3-tk" and "pip install tk" 1 - Install os,json and time ( but probably these libraries are already installed on your system) @@ -58,10 +62,6 @@ Whith this simple python program you will be able to not procrastinate during th -- Open your console in the cloned repository. -- To complete the installation, write the following command in the console: -```console -pip install -r requirements.txt ``` - To start Poweroffer, write the following command in the console: ```console From 900eb363de1820dc7a886f2465ce2774b684bfd2 Mon Sep 17 00:00:00 2001 From: archnotwindows <108471111+archnotwindows@users.noreply.github.com> Date: Fri, 29 Jul 2022 23:43:29 +0200 Subject: [PATCH 6/8] Update README.md --- README.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/README.md b/README.md index ae4a6a4..b26d16b 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Whith this simple python program you will be able to not procrastinate during the day in some sort of website (like Youtube) that you can choose! so try it out!! ## Getting Started - WARNING!! to use this software you must use a linux distro and the Firefox web browser + **WARNING!! to use this software you must use a linux distro and the Firefox web browser** 0 - Install **[Python](https://python.org)** on your machine. **Version 3.10 or higher is required!** @@ -62,12 +62,6 @@ Whith this simple python program you will be able to not procrastinate during th -``` -- To start Poweroffer, write the following command in the console: -```console -python3 main.py -``` - ## License This project is licensed under either of: From 0a3d0201e97d403d50528398789e4a5b96f21325 Mon Sep 17 00:00:00 2001 From: archnotwindows <108471111+archnotwindows@users.noreply.github.com> Date: Fri, 29 Jul 2022 23:52:18 +0200 Subject: [PATCH 7/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b26d16b..ceddc67 100644 --- a/README.md +++ b/README.md @@ -73,4 +73,4 @@ This project is licensed under either of: [![github](https://img.shields.io/badge/GitHub-000000?style=for-the-badge&logo=GitHub&logoColor=white)](https://github.com/archnotwindows) [![twitter](https://img.shields.io/badge/Twitter-007fff?style=for-the-badge&logo=twitter&logoColor=white)](https://twitter.com/Lollopro59_) [![instagram](https://img.shields.io/badge/Instagram-8f00ff?style=for-the-badge&logo=instagram&logoColor=white)](https://www.instagram.com/lollog020406/) -[![stackoverflow](https://img.shields.io/badge/StackOverFlow-FF8000?style=for-the-badge&logo=stackoverflow&logoColor=white)](https://stackoverflow.com/users/) +[![stackoverflow](https://img.shields.io/badge/StackOverFlow-FF8000?style=for-the-badge&logo=stackoverflow&logoColor=white)](https://stackoverflow.com/users/19628082/archnotwindows) From a915947e8b006b515462d1fa5fe7be8e3d83aced Mon Sep 17 00:00:00 2001 From: archnotwindows <108471111+archnotwindows@users.noreply.github.com> Date: Fri, 29 Jul 2022 23:52:53 +0200 Subject: [PATCH 8/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ceddc67..b232e04 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# PowerOffer +# Poweroffer