Skip to content

Commit

Permalink
modify env
Browse files Browse the repository at this point in the history
  • Loading branch information
arpy8 committed Apr 1, 2024
1 parent 2a7b164 commit 8421dc4
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 8 deletions.
2 changes: 1 addition & 1 deletion api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ def get_all_messages():
print("Error sending message:", str(e))

if __name__ == "__main__":
app.run()
app.run()
1 change: 0 additions & 1 deletion disdial/__chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def send_message_to_server(message):
try:
response = requests.post(API_URL, json=data, headers=_chat_headers)
response.raise_for_status()
# update_logs(f"[{current_time}] {username}: {data['message']}")
return f"[{current_time}] {username}: {data['message']}"

except requests.exceptions.RequestException as e:
Expand Down
11 changes: 9 additions & 2 deletions disdial/__constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import os
from disdial.__utils import path_converter
import pkg_resources

def path_converter(file_name):
return pkg_resources.resource_filename('disdial', file_name)

TOKEN = os.environ.get('DD_TOKEN')
CHANNEL_ID = os.environ.get('DD_CHANNEL_ID')
Expand All @@ -15,4 +18,8 @@
HEADERS={
'Authorization': f'Bot {TOKEN}',
'Content-Type': 'application/json',
}
}

LOCALAPP_DATA = os.getenv('LOCALAPPDATA')
PACKAGE_PATH = os.path.join(LOCALAPP_DATA, 'Packages', 'Microsoft.WindowsTerminal_8wekyb3d8bbwe')
SETTINGS_PATH = os.path.join(PACKAGE_PATH, 'LocalState', 'settings.json')
54 changes: 53 additions & 1 deletion disdial/__utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import os
import time
import json
import random
import webbrowser
import pkg_resources
import pyautogui as pg
from termcolor import colored
from disdial.__constants import SETTINGS_PATH


animations = [[".(^-^)'", "-(^-^)-", "'(^-^).", "-(^-^)-", ".(^-^)'", "-(^-^)-", "'(^-^).", "-(^-^)-"],
Expand Down Expand Up @@ -66,4 +69,53 @@ def loading_animation2():
time.sleep(random.uniform(0.12, 0.25))
print("\r", end='', flush=True)

os.system('cls' if os.name == 'nt' else 'clear')
os.system('cls' if os.name == 'nt' else 'clear')


def set_terminal_opacity(transparent: bool = True) -> str:
print(f"{'Restoring' if not transparent else 'Modifying'} terminal opacity...")

opacity_value = 0 if transparent else 100

try:
if os.path.exists(SETTINGS_PATH):
with open(SETTINGS_PATH, 'r') as f:
settings_content = json.load(f)

if "opacity" not in settings_content["profiles"]["defaults"]:
settings_content["profiles"]["defaults"]["opacity"] = opacity_value
with open(SETTINGS_PATH, "w") as file:
json.dump(settings_content, file)
return "Opacity appended successfully."

opacity = int(settings_content["profiles"]["defaults"]["opacity"])

if opacity != opacity_value:
settings_content["profiles"]["defaults"]["opacity"] = opacity_value
with open(SETTINGS_PATH, "w") as file:
json.dump(settings_content, file)
return "Opacity updated successfully."
else:
return "Opacity already set to the desired value."
else:
return "Settings file not found."

except Exception as e:
return f"An exception occurred: {e}"


def modify_env(transparent: bool = True) -> None:
set_terminal_opacity(transparent)

print("\033[H\033[J")

if transparent:
pg.press('f11')
time.sleep(0.05)
pg.hotkey('fn', 'f11')
time.sleep(0.05)
pg.press('f11')
else:
pg.press('f11')

print("\033[H\033[J")
3 changes: 2 additions & 1 deletion disdial/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def is_key_pressed(key):
def input_loop():
temp_list = get_all_messages()
history = []
temp_set = set()

try:
modify_env(True)
update_screen()

while True:
Expand All @@ -54,6 +54,7 @@ def input_loop():

except KeyboardInterrupt:
print("\n\nExiting...")
modify_env(False)
exit(0)

except EOFError:
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

setup(
name="disdial",
version="1.3.2.1",
version="1.3.2.2",
author="Arpit Sengar (arpy8)",
description="A terminal-based IRC-inspired package that enables users to chat on a single server with everyone..",
long_description=long_description,
long_description_content_type="text/markdown",
install_requires=["wheel", "termcolor", "setuptools", "argparse", "requests", "pytz", "argparse", "datetime", "keyboard"],
install_requires=["wheel", "termcolor", "setuptools", "argparse", "requests", "pytz", "argparse", "datetime", "keyboard", "pyautogui"],
entry_points={
"console_scripts": [
"disdial=disdial.main:main",
Expand Down

0 comments on commit 8421dc4

Please sign in to comment.