[ui] Add auto-mount on first launch functionality #52
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
|
||||
namespace repertory::utils {
|
||||
#if defined(__linux__)
|
||||
struct create_autostart_opts final {
|
||||
struct autostart_cfg final {
|
||||
std::string app_name;
|
||||
std::optional<std::string> comment;
|
||||
bool enabled{true};
|
||||
@@ -51,7 +51,7 @@ template <typename thread_t>
|
||||
#endif // defined(__APPLE__)
|
||||
|
||||
#if defined(__linux__)
|
||||
[[nodiscard]] auto create_autostart_entry(create_autostart_opts opts,
|
||||
[[nodiscard]] auto create_autostart_entry(const autostart_cfg &cfg,
|
||||
bool overwrite_existing = true)
|
||||
-> bool;
|
||||
#endif // defined(__linux__)
|
||||
|
@@ -180,11 +180,11 @@ auto convert_to_uint64(const pthread_t &thread) -> std::uint64_t {
|
||||
#endif // !defined(__APPLE__)
|
||||
|
||||
#if defined(__linux__)
|
||||
auto create_autostart_entry(create_autostart_opts opts, bool overwrite_existing)
|
||||
auto create_autostart_entry(const autostart_cfg &cfg, bool overwrite_existing)
|
||||
-> bool {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto file = desktop_file_path_for(opts.app_name);
|
||||
auto file = desktop_file_path_for(cfg.app_name);
|
||||
if (utils::file::file{file}.exists() && not overwrite_existing) {
|
||||
return true;
|
||||
}
|
||||
@@ -198,10 +198,10 @@ auto create_autostart_entry(create_autostart_opts opts, bool overwrite_existing)
|
||||
return false;
|
||||
}
|
||||
|
||||
auto exec_line = opts.exec_path;
|
||||
if (not opts.exec_args.empty()) {
|
||||
auto exec_line = cfg.exec_path;
|
||||
if (not cfg.exec_args.empty()) {
|
||||
exec_line += ' ';
|
||||
exec_line += join_args_for_exec(opts.exec_args);
|
||||
exec_line += join_args_for_exec(cfg.exec_args);
|
||||
}
|
||||
|
||||
std::ofstream out(file, std::ios::binary | std::ios::trunc);
|
||||
@@ -212,30 +212,30 @@ auto create_autostart_entry(create_autostart_opts opts, bool overwrite_existing)
|
||||
out << "[Desktop Entry]\n";
|
||||
out << "Type=Application\n";
|
||||
out << "Version=1.0\n";
|
||||
out << "Name=" << opts.app_name << "\n";
|
||||
out << "Name=" << cfg.app_name << "\n";
|
||||
out << "Exec=" << exec_line << "\n";
|
||||
out << "Terminal=" << (opts.terminal ? "true" : "false") << "\n";
|
||||
out << "Terminal=" << (cfg.terminal ? "true" : "false") << "\n";
|
||||
|
||||
if (opts.comment && !opts.comment->empty()) {
|
||||
out << "Comment=" << *opts.comment << "\n";
|
||||
if (cfg.comment && not cfg.comment->empty()) {
|
||||
out << "Comment=" << *cfg.comment << "\n";
|
||||
}
|
||||
|
||||
if (opts.icon_path && !opts.icon_path->empty()) {
|
||||
out << "Icon=" << *opts.icon_path << "\n";
|
||||
if (cfg.icon_path && not cfg.icon_path->empty()) {
|
||||
out << "Icon=" << *cfg.icon_path << "\n";
|
||||
}
|
||||
|
||||
if (!opts.only_show_in.empty()) {
|
||||
if (not cfg.only_show_in.empty()) {
|
||||
out << "OnlyShowIn=";
|
||||
for (std::size_t idx = 0U; idx < opts.only_show_in.size(); ++idx) {
|
||||
for (std::size_t idx = 0U; idx < cfg.only_show_in.size(); ++idx) {
|
||||
if (idx != 0U) {
|
||||
out << ';';
|
||||
}
|
||||
out << opts.only_show_in[idx];
|
||||
out << cfg.only_show_in[idx];
|
||||
}
|
||||
out << ";\n";
|
||||
}
|
||||
|
||||
if (not opts.enabled) {
|
||||
if (not cfg.enabled) {
|
||||
out << "X-GNOME-Autostart-enabled=false\n";
|
||||
out << "Hidden=true\n";
|
||||
}
|
||||
|
Reference in New Issue
Block a user