#ifndef STRAWBERRY_APP_AUTOSTART_HPP #define STRAWBERRY_APP_AUTOSTART_HPP // "Start at login" for the tray app, via the XDG autostart standard: // $XDG_CONFIG_HOME/autostart/strawberry-tray.desktop (default // ~/.config/autostart). GNOME, KDE, XFCE, LXQt, Cinnamon, MATE and systemd's // xdg-desktop-autostart.target (uwsm, some sway setups) run these entries. // Plain sway/i3/Hyprland sessions do not; session_hint() then says how to // start the tray from the compositor config instead of pretending it worked. // // No Qt here, so it is unit-tested without a display. #include namespace strawberry::app { struct AutostartEnv { std::string xdg_config_home; // $XDG_CONFIG_HOME, may be empty std::string home; // $HOME std::string current_desktop; // $XDG_CURRENT_DESKTOP, e.g. "sway:wlroots" bool autostart_target_active = false; // systemctl --user is-active xdg-desktop-autostart.target }; AutostartEnv autostart_env_from_process(); /// The entry file this app owns. std::string autostart_file(const AutostartEnv& env); /// The .desktop entry written for `exec_path` (an absolute path). std::string autostart_entry(const std::string& exec_path); /// True if the entry exists and is not disabled (Hidden=true or /// X-GNOME-Autostart-enabled=false). bool autostart_enabled(const AutostartEnv& env); /// Writes (atomically: temp file + rename) or removes the entry. bool set_autostart(const AutostartEnv& env, bool enable, const std::string& exec_path, std::string& error); /// True when the session is known to run XDG autostart entries. bool session_runs_xdg_autostart(const AutostartEnv& env); /// Empty when the entry is enough; otherwise one sentence on how to start /// the tray in this session (e.g. a sway `exec` line). std::string session_hint(const AutostartEnv& env, const std::string& exec_path); } // namespace strawberry::app #endif // STRAWBERRY_APP_AUTOSTART_HPP