diff --git a/.gitignore b/.gitignore index 4956c52..3a088e0 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ coverage.out coverage.html results.sarif .DS_Store +__debug_bin* \ No newline at end of file diff --git a/README.md b/README.md index 4b288e4..602dd11 100644 --- a/README.md +++ b/README.md @@ -268,6 +268,25 @@ sudo ./scripts/linux-install-deps.sh ./iptw ``` The script detects your distro (Fedora, RHEL, Debian/Ubuntu, Arch, openSUSE) and installs the correct packages automatically. Pass the path to the `iptw` binary as the first argument so it can verify all libraries resolved correctly after installation. +**Tray icon not visible on GNOME (Wayland)** + +Stock GNOME does not ship a StatusNotifierItem host (system tray), so the iptw tray icon will not appear by default. Install the AppIndicator extension to restore it: + +- **Fedora:** + ```bash + sudo dnf install gnome-shell-extension-appindicator + ``` +- **Ubuntu / Debian:** + ```bash + sudo apt install gnome-shell-extension-appindicator + ``` +- **From the GNOME Extension website:** + Visit [extensions.gnome.org/extension/615/appindicator-support](https://extensions.gnome.org/extension/615/appindicator-support/) and click the toggle to install. + +After installation, enable the extension and restart GNOME Shell (`Alt+F2` β†’ `r` on X11, or log out and back in on Wayland), then re-launch iptw. The globe tray icon will appear in the top bar. + +> **Note:** The HTTP map UI (`http://127.0.0.1:/map.html`) works regardless of whether the tray icon is visible β€” check the terminal output for the exact URL when running with `--foreground`. + **Permission Denied** - Make the binary executable: `chmod +x iptw` diff --git a/cmd/iptw/main.go b/cmd/iptw/main.go index d4acc9a..d2df140 100644 --- a/cmd/iptw/main.go +++ b/cmd/iptw/main.go @@ -4,6 +4,8 @@ import ( "flag" "fmt" "log/slog" + "net/http" + _ "net/http/pprof" "iptw/internal/config" "iptw/internal/geoip" @@ -24,9 +26,11 @@ func main() { var forceStart bool var showVersion bool var foreground bool + var pprofAddr string flag.BoolVar(&forceStart, "force", false, "Force start even if another instance appears to be running") flag.BoolVar(&showVersion, "version", false, "Show version information") flag.BoolVar(&foreground, "foreground", false, "Run in the foreground (keep terminal attached)") + flag.StringVar(&pprofAddr, "pprof", "", "Enable pprof profiling server on the given address (e.g. 127.0.0.1:6060)") flag.Parse() // Handle version request @@ -42,6 +46,17 @@ func main() { // the parent exits immediately. This is a no-op on Windows. maybeDaemonize(foreground) + // Start pprof server if requested. + if pprofAddr != "" { + go func() { + slog.Info("pprof profiling server starting", "addr", pprofAddr, + "hint", "go tool pprof http://"+pprofAddr+"/debug/pprof/profile") + if err := http.ListenAndServe(pprofAddr, nil); err != nil { //nolint:gosec + slog.Error("pprof server stopped", "error", err) + } + }() + } + // On Windows GUI builds, set up file logging immediately so that any // startup failure is recorded even before the config is read. if closer := logging.SetupWindowsFileLogger(slog.LevelDebug); closer != nil { diff --git a/internal/background/background.go b/internal/background/background.go index 2186e19..0816eb4 100644 --- a/internal/background/background.go +++ b/internal/background/background.go @@ -81,31 +81,42 @@ func setMacOSBackground(imagePath string) error { func setLinuxBackground(imagePath string) error { slog.Debug("πŸ–ΌοΈ Setting Linux desktop background:", "imagePath", imagePath) - // Try different desktop environments - commands := [][]string{ - // GNOME/Ubuntu - {"gsettings", "set", "org.gnome.desktop.background", "picture-uri", "file://" + imagePath}, - // KDE - {"qdbus", "org.kde.plasmashell", "/PlasmaShell", "org.kde.PlasmaShell.evaluateScript", - fmt.Sprintf(` - var allDesktops = desktops(); - for (i=0;i