Dotfiles config update (2023-05-12)

This commit is contained in:
q3aql 2023-05-12 00:32:49 +02:00
parent 10a6993d47
commit c7bede915c

View File

@ -2,6 +2,13 @@
import tkinter as tk import tkinter as tk
import os import os
import psutil
def check_process_running(process_name):
for proc in psutil.process_iter(['name']):
if proc.info['name'] == process_name:
return True
return False
class MainWindow: class MainWindow:
def __init__(self, master): def __init__(self, master):
@ -10,7 +17,7 @@ class MainWindow:
# Set theme and window size # Set theme and window size
master.configure(bg='#262321') master.configure(bg='#262321')
master.geometry('250x150') master.geometry('250x215')
self.boton1 = tk.Button(master, text="Enable Caffeine Mode", command=self.exec_command1, bg='#703207', fg="white") self.boton1 = tk.Button(master, text="Enable Caffeine Mode", command=self.exec_command1, bg='#703207', fg="white")
self.boton1.pack(side=tk.TOP, pady=10) self.boton1.pack(side=tk.TOP, pady=10)
@ -18,13 +25,17 @@ class MainWindow:
self.boton2 = tk.Button(master, text="Disable Caffeine Mode", command=self.exec_command2, bg='#703207', fg="white") self.boton2 = tk.Button(master, text="Disable Caffeine Mode", command=self.exec_command2, bg='#703207', fg="white")
self.boton2.pack(side=tk.TOP, pady=10) self.boton2.pack(side=tk.TOP, pady=10)
self.boton3 = tk.Button(master, text="Exit", command=self.exec_command3, bg='#703207', fg="white") self.boton3 = tk.Button(master, text="Check Status", command=self.exec_command3, bg='#703207', fg="white")
self.boton3.pack(side=tk.TOP, pady=10) self.boton3.pack(side=tk.TOP, pady=10)
self.boton4 = tk.Button(master, text="Exit", command=self.exec_command4, bg='#703207', fg="white")
self.boton4.pack(side=tk.TOP, pady=10)
# Set center buttons # Set center buttons
self.boton1.pack(side=tk.TOP, padx=10, pady=10, fill=tk.BOTH) self.boton1.pack(side=tk.TOP, padx=10, pady=10, fill=tk.BOTH)
self.boton2.pack(side=tk.TOP, padx=10, pady=10, fill=tk.BOTH) self.boton2.pack(side=tk.TOP, padx=10, pady=10, fill=tk.BOTH)
self.boton3.pack(side=tk.TOP, padx=10, pady=10, fill=tk.BOTH) self.boton3.pack(side=tk.TOP, padx=10, pady=10, fill=tk.BOTH)
self.boton4.pack(side=tk.TOP, padx=10, pady=10, fill=tk.BOTH)
def exec_command1(self): def exec_command1(self):
print('# Enabled Caffeine Mode') print('# Enabled Caffeine Mode')
@ -43,6 +54,27 @@ class MainWindow:
print('# Disabled Caffeine Mode') print('# Disabled Caffeine Mode')
def exec_command3(self): def exec_command3(self):
message = tk.Tk()
message.title("Caffeine.py")
# Set theme and window size
message.configure(bg='#262321')
message.geometry('190x105')
# Verificar si el proceso swayidle está en ejecución
if check_process_running("swayidle"):
label = tk.Label(message, text="Caffeine Mode is Disabled.", bg='#703207', fg="white")
else:
label = tk.Label(message, text="Caffeine Mode is Enabled.", bg='#703207', fg="white")
# Show window message
label.pack(side=tk.TOP, pady=10)
# Add close button
button = tk.Button(message, text="Close", command=message.destroy, bg='#703207', fg="white")
button.pack(side=tk.TOP, padx=10, pady=10, fill=tk.BOTH)
# Init events bucle
message.mainloop()
def exec_command4(self):
command = "exit" command = "exit"
os.system(command) os.system(command)
exit() exit()