Skip to content

Commit d975a73

Browse files
authored
Add visible Linux setup launcher (#13)
1 parent 8c8f965 commit d975a73

8 files changed

Lines changed: 200 additions & 28 deletions

File tree

‎README.html‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ <h2>🚀 Features</h2>
8383
<li>🔒 Raw Markdown HTML is sanitized by default; use <code>--unsafe-html</code> to preserve it for trusted input</li>
8484
<li>👀 <code>--watch</code> flag enables auto-rerender on file change (with debouncing)</li>
8585
<li>🌐 <code>--open</code> flag renders to a temp dir and launches the system default browser</li>
86-
<li>🧑‍🚀 <code>--setup</code> / no-arg interactive first-run guide, plus a Windows/Linux <code>mdo-setup</code> launcher that opens it for file-manager users</li>
86+
<li>🧑‍🚀 Explicit <code>--setup</code> first-run guide, plus a Windows/Linux <code>mdo-setup</code> launcher that opens it for file-manager users</li>
8787
<li>🧭 Built-in <code>--install-file-manager</code> / <code>--uninstall-file-manager</code> integration (no separate install scripts needed)</li>
8888
<li>⚡ Fast and self-contained — no required runtime assets; <code>mdo.exe</code> remains the core CLI</li>
8989
<li>🧩 Built on <code>pulldown-cmark</code>, <code>clap</code>, and <code>notify</code></li>
@@ -194,7 +194,7 @@ <h3>Examples</h3>
194194
used by normal mdo output:</p>
195195
<pre><code class="language-bash">python scripts/build-docs.py
196196
</code></pre>
197-
<p>The homepage source is <code>docs/index.md</code>; it uses only Markdown and the <code>--css docs/assets/site.css</code> override so the docs-only presentation is layered after
197+
<p>The homepage source is <code>docs/index.md</code>; it uses only Markdown and the <code>--css docs/assets/site.css</code> override so the docs-only presentation is layered after
198198
mdo's embedded simple.css and typography defaults. The sample preview source is
199199
<code>docs/assets/sample.md</code>; <code>scripts/build-docs.py</code> renders it with
200200
<code>docs/assets/sample.css</code> to demonstrate per-page CSS overrides. The GitHub Pages
@@ -243,10 +243,11 @@ <h3>First-run setup</h3>
243243
<p>On Windows, double-click <code>mdo-setup.exe</code> to open that same guided setup in a
244244
fresh Windows Terminal (<code>wt</code>) window, falling back to a plain new console if
245245
<code>wt</code> is unavailable — the no-terminal entry point for Explorer users. On
246-
Linux, run <code>mdo-setup</code> to get setup in your <code>$TERMINAL</code> or a known terminal emulator
247-
(<code>gnome-terminal</code>, <code>konsole</code>, <code>xterm</code>, and others); it is also what <code>mdo-open</code>
248-
runs when launched with no file. Double-clicking the bare <code>mdo-setup</code> binary from
249-
a file manager is not reliable on Linux, so prefer <code>mdo --setup</code> from a shell.
246+
Linux, launch <strong>mdo Setup</strong> from your application menu, or run <code>mdo-setup</code> to
247+
open guided setup in your <code>$TERMINAL</code> or a known terminal emulator
248+
(<code>gnome-terminal</code>, <code>konsole</code>, <code>xterm</code>, and others). It is also what <code>mdo-open</code>
249+
runs when launched with no file. Running <code>mdo-setup</code> repairs its per-user
250+
application-menu entry if needed.
250251
This preserves <code>mdo</code> as the normal CLI. On Windows, launching <code>mdo-open.exe</code>
251252
directly with no file opens the same guided setup in a fresh Windows Terminal
252253
(<code>wt</code>) window using the <strong>One Half Light</strong> color scheme, centered on the active
@@ -274,9 +275,14 @@ <h2>Linux file manager integration</h2>
274275
show an action-oriented entry instead of a tool-name-only entry. Rerunning the
275276
installer also removes older Nautilus Scripts entries named <strong>Preview with
276277
mdo</strong> or <strong>Render with mdo</strong>.</p>
278+
<p>The hosted Linux installer also writes the separate, visible
279+
<code>~/.local/share/applications/mdo-setup.desktop</code> launcher. It has no MIME types
280+
and remains installed if you run <code>mdo --uninstall-file-manager</code>; that command
281+
only removes the hidden <strong>Open as HTML</strong> file-handler integration.</p>
277282
<p>Linux release archives also include <code>mdo-setup</code>, which opens the same first-run
278-
setup in a terminal window. It launches your <code>$TERMINAL</code> or a known terminal
279-
emulator (<code>gnome-terminal</code>, <code>konsole</code>, <code>xterm</code>, and others); if none is found it
283+
setup in a terminal window and registers itself as <strong>mdo Setup</strong> in Linux
284+
application menus. It launches your <code>$TERMINAL</code> or a known terminal emulator
285+
(<code>gnome-terminal</code>, <code>konsole</code>, <code>xterm</code>, and others); if none is found it
280286
shows a <code>zenity</code>/<code>kdialog</code>/<code>yad</code> notice pointing you to <code>mdo --setup</code>. If you
281287
launch <code>mdo-open</code> directly with no file, it opens <code>mdo-setup</code> when the setup
282288
helper is present.</p>
@@ -413,6 +419,6 @@ <h2>📄 License</h2>
413419
<p>at your option, matching the licensing of the upstream project.</p>
414420

415421
</main>
416-
<footer class="mdo-generated">Generated by <a href="https://maphew.github.io/mdo/">mdo</a> 0.4.0 in 0.006s on <time datetime="2026-06-18">2026-06-18</time>.</footer>
422+
<footer class="mdo-generated">Generated by <a href="https://maphew.github.io/mdo/">mdo</a> 0.4.0 in 0.001s on <time datetime="2026-07-10">2026-07-10</time>.</footer>
417423
</body>
418424
</html>

‎README.md‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,11 @@ you can immediately verify the browser-opening flow.
259259
On Windows, double-click `mdo-setup.exe` to open that same guided setup in a
260260
fresh Windows Terminal (`wt`) window, falling back to a plain new console if
261261
`wt` is unavailable — the no-terminal entry point for Explorer users. On
262-
Linux, run `mdo-setup` to open guided setup in your `$TERMINAL` or a known terminal emulator
263-
(`gnome-terminal`, `konsole`, `xterm`, and others); it is also what `mdo-open`
264-
runs when launched with no file. Double-clicking the bare `mdo-setup` binary from
265-
a file manager is not reliable on Linux, so prefer `mdo --setup` from a shell.
262+
Linux, launch **mdo Setup** from your application menu, or run `mdo-setup` to
263+
open guided setup in your `$TERMINAL` or a known terminal emulator
264+
(`gnome-terminal`, `konsole`, `xterm`, and others). It is also what `mdo-open`
265+
runs when launched with no file. Running `mdo-setup` repairs its per-user
266+
application-menu entry if needed.
266267
This preserves `mdo` as the normal CLI. On Windows, launching `mdo-open.exe`
267268
directly with no file opens the same guided setup in a fresh Windows Terminal
268269
(`wt`) window using the **One Half Light** color scheme, centered on the active
@@ -297,9 +298,15 @@ show an action-oriented entry instead of a tool-name-only entry. Rerunning the
297298
installer also removes older Nautilus Scripts entries named **Preview with
298299
mdo** or **Render with mdo**.
299300

301+
The hosted Linux installer also writes the separate, visible
302+
`~/.local/share/applications/mdo-setup.desktop` launcher. It has no MIME types
303+
and remains installed if you run `mdo --uninstall-file-manager`; that command
304+
only removes the hidden **Open as HTML** file-handler integration.
305+
300306
Linux release archives also include `mdo-setup`, which opens the same first-run
301-
setup in a terminal window. It launches your `$TERMINAL` or a known terminal
302-
emulator (`gnome-terminal`, `konsole`, `xterm`, and others); if none is found it
307+
setup in a terminal window and registers itself as **mdo Setup** in Linux
308+
application menus. It launches your `$TERMINAL` or a known terminal emulator
309+
(`gnome-terminal`, `konsole`, `xterm`, and others); if none is found it
303310
shows a `zenity`/`kdialog`/`yad` notice pointing you to `mdo --setup`. If you
304311
launch `mdo-open` directly with no file, it opens `mdo-setup` when the setup
305312
helper is present.

‎docs/assets/sample.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,6 @@ <h2>Commands</h2>
117117
<p>Use <code>--bare</code> when another template owns the document shell.</p>
118118

119119
</main>
120-
<footer class="mdo-generated">Generated by <a href="https://maphew.github.io/mdo/">mdo</a> 0.4.0 in 0.001s on <time datetime="2026-06-18">2026-06-18</time>.</footer>
120+
<footer class="mdo-generated">Generated by <a href="https://maphew.github.io/mdo/">mdo</a> 0.4.0 in 0.001s on <time datetime="2026-07-10">2026-07-10</time>.</footer>
121121
</body>
122122
</html>

‎docs/index.html‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,7 @@ <h3>Explore first</h3>
15621562
<p>Setup explains the render-and-open workflow, the normal convert-once command, and the reversible integration commands.</p>
15631563
<h3>Opt in when ready</h3>
15641564
<p>Running <code>mdo</code> with no arguments prints a short <strong>Open Markdown as HTML</strong> landing page and exits successfully; use <code>mdo --help</code> for the full CLI reference. Run <code>mdo --setup</code> when you want guided setup. On Windows and Linux it can offer to install <strong>Open as HTML</strong> for the current user only. The default answer is <strong>Yes</strong>, but mdo still does not change the default Markdown app. Choose <strong>No</strong> to skip or run setup again later.</p>
1565-
<p>After you press Enter to finish setup, mdo opens a short welcome sample so you can immediately verify the browser-opening flow. On Windows, double-click <code>mdo-setup.exe</code> to open that same guided setup in a fresh Windows Terminal (<code>wt</code>) window, falling back to a plain new console if <code>wt</code> is unavailable. On Linux, run <code>mdo-setup</code> to open guided setup in your <code>$TERMINAL</code> or a known terminal emulator (<code>gnome-terminal</code>, <code>konsole</code>, <code>xterm</code>, and others); it is also what <code>mdo-open</code> runs when launched with no file. Double-clicking the bare binary from a file manager is not reliable on Linux, so prefer <code>mdo --setup</code> from a shell.</p>
1565+
<p>After you press Enter to finish setup, mdo opens a short welcome sample so you can immediately verify the browser-opening flow. On Windows, double-click <code>mdo-setup.exe</code> to open that same guided setup in a fresh Windows Terminal (<code>wt</code>) window, falling back to a plain new console if <code>wt</code> is unavailable. On Linux, launch <strong>mdo Setup</strong> from your application menu or run <code>mdo-setup</code> to open guided setup in your <code>$TERMINAL</code> or a known terminal emulator (<code>gnome-terminal</code>, <code>konsole</code>, <code>xterm</code>, and others); it is also what <code>mdo-open</code> runs when launched with no file. Running it repairs its per-user application-menu entry if needed.</p>
15661566
<p>On Windows, launching <code>mdo-open.exe</code> directly with no file opens the same guided setup in a fresh Windows Terminal (<code>wt</code>) window using the <strong>One Half Light</strong> color scheme, centered on the active display; if <code>wt</code> is unavailable, it falls back to a plain new console.</p>
15671567
<h2>Usage</h2>
15681568
<p>By default, <code>mdo</code> writes a styled HTML file beside the source Markdown file. Use <code>--open</code> to render into a stable temp path and launch the default browser.</p>
@@ -1616,7 +1616,7 @@ <h3>Windows Explorer</h3>
16161616
<li><strong>Open with</strong> offers <strong>Open as HTML</strong>.</li>
16171617
<li>If <strong>Open as HTML</strong> is made the default handler, double-click opens the browser.</li>
16181618
<li>If <code>mdo-open.exe</code> is next to <code>mdo.exe</code>, it is used for flash-free Explorer launches; otherwise the single <code>mdo.exe</code> binary still works.</li>
1619-
<li><code>mdo-setup.exe</code> and no-file <code>mdo-open.exe</code> open the guided setup in a fresh <code>wt</code> window with the <strong>One Half Light</strong> color scheme and center it on the active display, falling back to a plain new console when <code>wt</code> cannot be started.</li>
1619+
<li><code>mdo-setup.exe</code> and no-file <code>mdo-open.exe</code> open guided setup in a fresh <code>wt</code> window with the <strong>One Half Light</strong> color scheme and center it on the active display, falling back to a plain new console when <code>wt</code> cannot be started.</li>
16201620
<li>Windows Open With should show the friendly name <strong>Open as HTML</strong> with the mdo icon instead of exposing the wrapper file name.</li>
16211621
</ul>
16221622
<h3>Linux File Managers</h3>
@@ -1626,6 +1626,7 @@ <h3>Linux File Managers</h3>
16261626
mdo --uninstall-file-manager
16271627
</code></pre>
16281628
<ul>
1629+
<li>The hosted installer registers a visible <strong>mdo Setup</strong> application-menu entry at <code>~/.local/share/applications/mdo-setup.desktop</code>; running <code>mdo-setup</code> repairs it for Cargo or Homebrew installs. It is separate from the hidden <code>mdo.desktop</code> file handler and remains after <code>mdo --uninstall-file-manager</code>.</li>
16291630
<li><code>mdo-setup</code> opens the same first-run setup in a terminal window (your <code>$TERMINAL</code> or a known emulator such as <code>gnome-terminal</code>, <code>konsole</code>, or <code>xterm</code>); if none is found it shows a <code>zenity</code>/<code>kdialog</code>/<code>yad</code> notice pointing to <code>mdo --setup</code>.</li>
16301631
<li>Most XDG file managers show <strong>Open With -&gt; Open as HTML</strong> for Markdown files.</li>
16311632
<li>GNOME Files/Nautilus uses the same Open With entry; no duplicate Scripts item is installed.</li>
@@ -1664,6 +1665,6 @@ <h2>Project Links</h2>
16641665
<p>mdo is dual-licensed under MIT or Apache-2.0 and forked with gratitude from Hafiz Ali Raza's original Markdown-to-HTML CLI.</p>
16651666

16661667
</main>
1667-
<footer class="mdo-generated">Generated by <a href="https://maphew.github.io/mdo/">mdo</a> 0.4.0 in 0.004s on <time datetime="2026-06-18">2026-06-18</time>.</footer>
1668+
<footer class="mdo-generated">Generated by <a href="https://maphew.github.io/mdo/">mdo</a> 0.4.0 in 0.001s on <time datetime="2026-07-10">2026-07-10</time>.</footer>
16681669
</body>
16691670
</html>

‎docs/index.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Setup explains the render-and-open workflow, the normal convert-once command, an
107107

108108
Running `mdo` with no arguments prints a short **Open Markdown as HTML** landing page and exits successfully; use `mdo --help` for the full CLI reference. Run `mdo --setup` when you want guided setup. On Windows and Linux it can offer to install **Open as HTML** for the current user only. The default answer is **Yes**, but mdo still does not change the default Markdown app. Choose **No** to skip or run setup again later.
109109

110-
After you press Enter to finish setup, mdo opens a short welcome sample so you can immediately verify the browser-opening flow. On Windows, double-click `mdo-setup.exe` to open that same guided setup in a fresh Windows Terminal (`wt`) window, falling back to a plain new console if `wt` is unavailable. On Linux, run `mdo-setup` to open guided setup in your `$TERMINAL` or a known terminal emulator (`gnome-terminal`, `konsole`, `xterm`, and others); it is also what `mdo-open` runs when launched with no file. Double-clicking the bare binary from a file manager is not reliable on Linux, so prefer `mdo --setup` from a shell.
110+
After you press Enter to finish setup, mdo opens a short welcome sample so you can immediately verify the browser-opening flow. On Windows, double-click `mdo-setup.exe` to open that same guided setup in a fresh Windows Terminal (`wt`) window, falling back to a plain new console if `wt` is unavailable. On Linux, launch **mdo Setup** from your application menu or run `mdo-setup` to open guided setup in your `$TERMINAL` or a known terminal emulator (`gnome-terminal`, `konsole`, `xterm`, and others); it is also what `mdo-open` runs when launched with no file. Running it repairs its per-user application-menu entry if needed.
111111

112112
On Windows, launching `mdo-open.exe` directly with no file opens the same guided setup in a fresh Windows Terminal (`wt`) window using the **One Half Light** color scheme, centered on the active display; if `wt` is unavailable, it falls back to a plain new console.
113113

@@ -192,6 +192,7 @@ mdo --install-file-manager --set-default
192192
mdo --uninstall-file-manager
193193
```
194194

195+
- The hosted installer registers a visible **mdo Setup** application-menu entry at `~/.local/share/applications/mdo-setup.desktop`; running `mdo-setup` repairs it for Cargo or Homebrew installs. It is separate from the hidden `mdo.desktop` file handler and remains after `mdo --uninstall-file-manager`.
195196
- `mdo-setup` opens the same first-run setup in a terminal window (your `$TERMINAL` or a known emulator such as `gnome-terminal`, `konsole`, or `xterm`); if none is found it shows a `zenity`/`kdialog`/`yad` notice pointing to `mdo --setup`.
196197
- Most XDG file managers show **Open With -> Open as HTML** for Markdown files.
197198
- GNOME Files/Nautilus uses the same Open With entry; no duplicate Scripts item is installed.

‎docs/install.sh‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ done
8888
echo "mdo installed to ${install_dir}"
8989
"${install_dir}/mdo" --version
9090

91+
if [ "$os" = "Linux" ]; then
92+
"${install_dir}/mdo-setup" --register-launcher-only
93+
fi
94+
9195
case ":${PATH}:" in
9296
*":${install_dir}:"*) ;;
9397
*)

‎src/bin/mdo-setup.rs‎

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,18 @@ fn main() -> ExitCode {
2828

2929
#[cfg(target_os = "linux")]
3030
fn main() -> ExitCode {
31-
match linux_setup::run() {
31+
let register_only = std::env::args_os()
32+
.nth(1)
33+
.is_some_and(|arg| arg == "--register-launcher-only");
34+
let result = if register_only {
35+
linux_setup::register_launcher().map(|path| {
36+
println!("Installed application launcher: {}", path.display());
37+
})
38+
} else {
39+
linux_setup::run()
40+
};
41+
42+
match result {
3243
Ok(()) => ExitCode::SUCCESS,
3344
Err(e) => {
3445
linux_setup::error_dialog(
@@ -81,6 +92,7 @@ mod linux_setup {
8192
];
8293

8394
pub fn run() -> io::Result<()> {
95+
continue_after_launcher_registration(register_launcher());
8496
let mdo = sibling_binary("mdo")?;
8597
if !mdo.exists() {
8698
return Err(io::Error::new(
@@ -116,6 +128,23 @@ mod linux_setup {
116128
Ok(())
117129
}
118130

131+
pub fn register_launcher() -> io::Result<PathBuf> {
132+
let setup_exe = std::env::current_exe()?;
133+
mdo_cli::file_manager::install_linux_setup_launcher_for_exe(&setup_exe)
134+
}
135+
136+
fn continue_after_launcher_registration(result: io::Result<PathBuf>) -> bool {
137+
match result {
138+
Ok(_) => true,
139+
Err(error) => {
140+
eprintln!(
141+
"mdo setup warning: could not register the application-menu launcher: {error}"
142+
);
143+
false
144+
}
145+
}
146+
}
147+
119148
fn spawn_setup_in_terminal(mdo: &Path) -> bool {
120149
for (program, lead) in preferred_terminals() {
121150
if !command_on_path(program) {
@@ -277,6 +306,23 @@ mod linux_setup {
277306
);
278307
}
279308
}
309+
310+
#[test]
311+
fn normal_onboarding_continues_after_launcher_registration_failure() {
312+
let result = Err(io::Error::new(
313+
io::ErrorKind::PermissionDenied,
314+
"applications directory is read-only",
315+
));
316+
317+
assert!(!continue_after_launcher_registration(result));
318+
}
319+
320+
#[test]
321+
fn normal_onboarding_accepts_successful_launcher_registration() {
322+
assert!(continue_after_launcher_registration(Ok(PathBuf::from(
323+
"/tmp/applications/mdo-setup.desktop"
324+
))));
325+
}
280326
}
281327
}
282328

0 commit comments

Comments
 (0)