fix autostart setting

This commit is contained in:
2026-08-12 17:01:24 +02:00
parent d5f092883a
commit 35ff9bae5e
2 changed files with 46 additions and 3 deletions

12
gui.py
View File

@@ -278,22 +278,25 @@ Type=Application
Name=f0ckm Uploader GUI
Comment=System tray GUI and settings for f0ckm Uploader
Exec={exec_path}
Icon=cloud-upload-symbolic
Icon=f0ckm-uploader
Terminal=false
Categories=Utility;Network;
StartupNotify=false
X-GNOME-Autostart-enabled=true
"""
with open(autostart_path, "w") as f:
f.write(content)
os.chmod(autostart_path, 0o755)
print(f"[f0ckm-gui] Autostart desktop file written to {autostart_path}", flush=True)
except Exception as e:
print(f"Failed to create autostart entry: {e}")
print(f"Failed to create autostart entry: {e}", flush=True)
else:
if os.path.exists(autostart_path):
try:
os.remove(autostart_path)
print(f"[f0ckm-gui] Autostart desktop file removed from {autostart_path}", flush=True)
except Exception as e:
print(f"Failed to remove autostart entry: {e}")
print(f"Failed to remove autostart entry: {e}", flush=True)
# ==========================================
# Connection Tester Worker
@@ -1975,6 +1978,9 @@ def main():
if not os.path.exists(CONFIG_PATH):
save_config(DEFAULT_CONFIG)
cfg = get_env_config()
set_autostart(cfg.get("autostart", False))
tray_app = SystemTrayApp()
local_http_bridge.request_upload.connect(tray_app.upload_target_direct)
tray_app.show()

View File

@@ -117,6 +117,43 @@ EOF
echo "Initial configuration created at $CONFIG_FILE"
fi
# 6. Ensure autostart state matches config.json
python3 -c '
import json, os
try:
cfg_path = os.path.expanduser("~/.config/f0ckm-uploader/config.json")
if os.path.exists(cfg_path):
with open(cfg_path, "r", encoding="utf-8") as f:
cfg = json.load(f)
autostart = cfg.get("autostart", False)
autostart_dir = os.path.expanduser("~/.config/autostart")
autostart_path = os.path.join(autostart_dir, "f0ckm-uploader-gui.desktop")
if autostart:
os.makedirs(autostart_dir, exist_ok=True)
exec_path = os.path.expanduser("~/.local/bin/f0ckm-uploader-gui")
content = f"""[Desktop Entry]
Type=Application
Name=f0ckm Uploader GUI
Comment=System tray GUI and settings for f0ckm Uploader
Exec={exec_path}
Icon=f0ckm-uploader
Terminal=false
Categories=Utility;Network;
StartupNotify=false
X-GNOME-Autostart-enabled=true
"""
with open(autostart_path, "w", encoding="utf-8") as f:
f.write(content)
os.chmod(autostart_path, 0o755)
print(f"Synced autostart desktop entry: {autostart_path}")
else:
if os.path.exists(autostart_path):
os.remove(autostart_path)
print(f"Removed autostart desktop entry: {autostart_path}")
except Exception as e:
print(f"Warning: could not sync autostart entry: {e}")
'
echo "Installation complete!"
echo "The script has been installed to $INSTALL_DIR/f0ckm-uploader"
echo "The GUI has been installed to $INSTALL_DIR/f0ckm-uploader-gui"