Skip to content
Open
Show file tree
Hide file tree
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
37 changes: 37 additions & 0 deletions debug_caps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

import os
import shutil
import subprocess
import sys

# Locate getcap
getcap = shutil.which("getcap")
if not getcap:
possible_paths = ["/usr/sbin/getcap", "/sbin/getcap"]
for p in possible_paths:
if os.path.exists(p):
getcap = p
break

print(f"Using getcap: {getcap}")

# Binaries
bin_dir = os.path.abspath("bin/linux-x86_64")
singbox = os.path.join(bin_dir, "sing-box")
xray = os.path.join(bin_dir, "xray")

for binary in [singbox, xray]:
print(f"Checking: {binary}")
if os.path.exists(binary):
cmd = [getcap, binary]
try:
res = subprocess.run(cmd, capture_output=True, text=True)
print(f"Result ({res.returncode}): {res.stdout.strip()}")
if "cap_net_admin" in res.stdout:
print("HAS CAP_NET_ADMIN")
else:
print("MISSING CAP_NET_ADMIN")
except Exception as e:
print(f"Error: {e}")
else:
print("Does not exist")
75 changes: 75 additions & 0 deletions debug_tray.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

import sys
# Inject system packages if needed (mimicking main.py)
import os
if sys.platform.startswith("linux"):
system_packages = "/usr/lib/python3/dist-packages"
if os.path.exists(system_packages) and system_packages not in sys.path:
try:
import gi
except ImportError:
sys.path.append(system_packages)

import pystray
from PIL import Image, ImageDraw

def create_image():
# Generate an image with a specific color
width = 64
height = 64
color1 = "blue"
color2 = "white"
image = Image.new('RGB', (width, height), color1)
dc = ImageDraw.Draw(image)
dc.rectangle((width // 2, 0, width, height // 2), fill=color2)
dc.rectangle((0, height // 2, width // 2, height), fill=color2)
return image

def setup(icon):
icon.visible = True

def on_quit(icon, item):
icon.stop()

def main():
print(f"Python: {sys.version}")

try:
import gi
print(f"PyGObject (gi) imported: {gi.__file__}")
try:
gi.require_version('AppIndicator3', '0.1')
from gi.repository import AppIndicator3
print("AppIndicator3 found via gi")
except Exception as e:
print(f"AppIndicator3 check failed: {e}")

try:
gi.require_version('AyatanaAppIndicator3', '0.1')
from gi.repository import AyatanaAppIndicator3
print("AyatanaAppIndicator3 found via gi")
except Exception as e:
print(f"AyatanaAppIndicator3 check failed: {e}")

except ImportError:
print("PyGObject (gi) NOT found")

image = create_image()

# Try to force AppIndicator backend explicitly to see if it works validation
# os.environ['PYSTRAY_BACKEND'] = 'appindicator'

print("Creating icon...")
icon = pystray.Icon(
'test_icon',
image,
menu=pystray.Menu(
pystray.MenuItem('Quit', on_quit)
)
)

print("Running icon... (Check your system tray)")
icon.run(setup)

if __name__ == "__main__":
main()
Loading
Loading