-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsystem_context.py
More file actions
29 lines (25 loc) · 811 Bytes
/
Copy pathsystem_context.py
File metadata and controls
29 lines (25 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import platform
import shutil
import os
def detect_package_manager():
if shutil.which("apt"):
return "apt"
elif shutil.which("dnf"):
return "dnf"
elif shutil.which("pacman"):
return "pacman"
elif shutil.which("zypper"):
return "zypper"
return "unknown"
def detect_session():
return os.environ.get("XDG_SESSION_DESKTOP", "unknown")
def detect_apps(apps):
return [app for app in apps if shutil.which(app)]
def get_context_summary():
return {
"os": platform.system() + " " + platform.release(),
"package_manager": detect_package_manager(),
"session": detect_session(),
"browsers": detect_apps(["firefox", "chrome", "chromium", "brave"]),
"text_editors": detect_apps(["code", "nano", "gedit", "vim"])
}