test new systray #50

Merged
zach merged 6 commits from new-systray into main 2026-04-09 19:26:57 +02:00
2 changed files with 71 additions and 0 deletions
Showing only changes of commit 32b77e0ced - Show all commits
+39
View File
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
import glob
import json
import os
import pwd
@@ -17,21 +18,59 @@ INVALID_SHELLS = {
# Minimum UID for regular users (typically 1000 on most Linux distributions)
MIN_UID = 1000
GREETER_IMAGES_DIR = "/etc/zshell-greeter/images"
def get_face_path(home: str, username: str) -> str:
"""Get the path to the user's face/avatar image if it exists."""
greeter_candidates = [
os.path.join(GREETER_IMAGES_DIR, f"{username}.face"),
os.path.join(GREETER_IMAGES_DIR, f"{username}.face.icon"),
]
for path in greeter_candidates:
if os.path.isfile(path):
return path
for path in sorted(glob.glob(os.path.join(GREETER_IMAGES_DIR, f"{username}.*"))):
if os.path.isfile(path):
return path
direct_path = os.path.join(GREETER_IMAGES_DIR, username)
if os.path.isfile(direct_path):
return direct_path
accountsservice_user = f"/var/lib/AccountsService/users/{username}"
if os.path.isfile(accountsservice_user):
try:
with open(accountsservice_user, "r", encoding="utf-8") as handle:
for line in handle:
if line.startswith("Icon="):
icon_path = line.split("=", 1)[1].strip()
if icon_path:
if not os.path.isabs(icon_path):
icon_path = os.path.join("/var/lib/AccountsService/icons", icon_path)
if os.path.isfile(icon_path):
return icon_path
except OSError:
pass
# Check common locations for user avatars
candidates = [
os.path.join(home, ".face"),
os.path.join(home, ".face.icon"),
f"/var/lib/AccountsService/icons/{username}",
f"/usr/share/pixmaps/faces/{username}",
]
for path in candidates:
if os.path.isfile(path):
return path
for path in sorted(glob.glob(f"/var/lib/AccountsService/icons/{username}.*")):
if os.path.isfile(path):
return path
return ""
+32
View File
@@ -7,6 +7,38 @@ main() {
sudo mkdir -p "/etc/zshell-greeter/images"
sudo cp "$WALLPAPER" "/etc/zshell-greeter/images/greeter_bg.png"
sudo cp "$SCHEME" "/etc/zshell-greeter/scheme.json"
while IFS=: read -r username _ uid _ _ home _; do
if [[ -z "$username" || -z "$uid" || -z "$home" ]]; then
continue
fi
if [[ "$uid" -lt 1000 ]]; then
continue
fi
face_path=""
for candidate in "$home/.face" "$home/.face.icon"; do
if [[ -f "$candidate" ]]; then
face_path="$candidate"
break
fi
done
if [[ -n "$face_path" ]]; then
ext="${face_path##*.}"
case "$face_path" in
"$home/.face" | "$home/.face.icon")
ext=""
;;
esac
if [[ -n "$ext" ]]; then
sudo cp "$face_path" "/etc/zshell-greeter/images/${username}.${ext}"
else
sudo cp "$face_path" "/etc/zshell-greeter/images/${username}.face"
fi
fi
done </etc/passwd
}
main "$@"