Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 27 additions & 23 deletions UnixDRP.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,55 +7,59 @@

LaunchCode = "939904925494829086" # paste your client id here
theShell = os.environ['SHELL']

# identify terminal and get terminal data
def getData():

# identifying terminal
if "gnome-terminal-server" in (i.name() for i in psutil.process_iter()):
state = "On GNOME-terminal"
largeImage = "terminal"
largeText = "GNOME-terminal"

elif "konsole" in (i.name() for i in psutil.process_iter()):
state = "On KDE-Konsole"
largeImage = "konsole"
largeText = "KDE-Konsole"
else:
(state, largeImage, largeText) = ("On Linux Terminal", None, "Linux Terminal") # default values
state, largeImage, largeText = "On Linux Terminal", None, "Linux Terminal" # default values

# identifying shell
shells = ["ZSH", "Bash", "Tmux", "Fish", "Dash"]

(details, smallImage, smallText) = ("Using a shell", None, None) # default values
details, smallImage, smallText = "Using a shell", None, None # default values
for shell in shells:
if theShell == f"/usr/bin/{shell.lower()}":
if theShell.endswith(shell.lower()):
details = f"Using {shell} shell"
smallImage = shell.lower()
smallText = f"{shell} shell"

return state, largeImage, largeText, details, smallImage, smallText

timeOfStart = time.time() # shows the elapsed time at the bottom (needs to be started in Slushy.update())
timeOfStart = time.time() # shows the elapsed time at the bottom (needs to be started in Slushy.update())

print("Started\n")

print("started\n")
# Initialize Presence once
Slushy = Presence(client_id=LaunchCode)
try:
Slushy.connect()
print("Connect success!")
except Exception as e:
print(f"Failed to connect: {e}")
exit(1)

while True:
try:
(state, largeImage, largeText, details, smallImage, smallText) = getData()

Slushy = Presence(client_id=LaunchCode)
Slushy.connect()
Slushy.update(start=timeOfStart,
state=state,
large_image=largeImage,
large_text=largeText,
details=details,
small_image=smallImage,
small_text=smallText)
print("Connect success!")
state, largeImage, largeText, details, smallImage, smallText = getData()
Slushy.update(
start=timeOfStart,
state=state,
large_image=largeImage,
large_text=largeText,
details=details,
small_image=smallImage,
small_text=smallText
)
time.sleep(30)
except:
print("Failed to connect\nWaiting...\n")
except Exception as e:
print(f"Update failed: {e}\nWaiting...\n")
time.sleep(5)
pass
continue