omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

XDG_DESKTOP_DIR="$HOME" makes apps scatter .desktop shortcuts into the home directory

Open rogerfsh opened this issue 3 months ago • 2 comments

Summary

omarchy-provision-user points DESKTOP, TEMPLATES and PUBLICSHARE at $HOME and removes the folders:

# /usr/bin/omarchy-provision-user  (omarchy 4.0.2-1, lines ~98-101)
xdg-user-dirs-update --set TEMPLATES "$HOME"
xdg-user-dirs-update --set PUBLICSHARE "$HOME"
xdg-user-dirs-update --set DESKTOP "$HOME"
rmdir ~/Templates ~/Public ~/Desktop 2>/dev/null || true

The intent is clear and I agree with it — Hyprland has no desktop metaphor, so three permanently empty folders are noise. Pointing an XDG dir at the home directory is also the freedesktop-documented way to say "this directory doesn't exist here", so this isn't a hack.

The problem is that apps don't interpret it that way. Nothing reads XDG_DESKTOP_DIR=$HOME as "there is no desktop, skip it". They read it as "the desktop is ~" and write there. So the setting that exists to keep $HOME tidy is the thing that untidies it.

Impact

On one machine, after about a day of ordinary use, ~ had collected:

steam.desktop                                     # byte-identical to /usr/share/applications/steam.desktop
chrome-<id>-Default.desktop                       # Chrome PWA shortcut
chrome-<id>-Default.desktop                       # Chrome PWA shortcut
chrome-<id>-Default.desktop                       # Chrome PWA shortcut

Two things make this worse than ordinary clutter:

  1. The files are inert. Walker and the app menu read ~/.local/share/applications/, where correct copies already exist. The ~ copies are never used by anything.
  2. They are stale duplicates. The Chrome PWA copies in ~ lacked the %U argument and the MimeType= line that the ~/.local/share/applications/ versions carry, so they were also worse copies — e.g. missing x-scheme-handler/mailto registration.

Users are unlikely to connect loose .desktop files in $HOME to an XDG setting, so they accumulate indefinitely.

Reproduce

On a stock Omarchy install:

  1. omarchy-install-steam (or install Steam by any means) and let it create a desktop shortcut, and/or
  2. In Chrome, open any site → Cast, save and share → Install page as app
  3. ls ~/*.desktop

Expected: nothing in $HOME. Actual: one .desktop file per shortcut.

Suggested fix

Keep the intent, drop the side effect — give DESKTOP a real but out-of-the-way target rather than $HOME:

xdg-user-dirs-update --set DESKTOP "$HOME/.local/share/desktop"

No visible folder in $HOME, and anything that insists on writing a desktop shortcut lands somewhere ignorable. TEMPLATES and PUBLICSHARE are rarely written to by anything, so they matter less — but the same reasoning applies.

An alternative, if a hidden path feels wrong, is to leave the folders in place and accept three empty directories; that at least confines the writes.

Environment

  • omarchy 4.0.2-1
  • xdg-user-dirs 0.20-1
  • /etc/xdg/user-dirs.defaults ships the standard layout (DESKTOP=Desktop, TEMPLATES=Templates, PUBLICSHARE=Public); the $HOME values come from omarchy-provision-user, not the system default.

Related

  • #1331 — proposal that Omarchy avoid creating files in the user's home directory (same concern, other direction)

rogerfsh avatar Sep 01 '26 05:09 rogerfsh

I would like to work on this. Proposed scope: point new installs to a hidden desktop directory, add an idempotent migration only when the current XDG desktop value is exactly HOME, preserve user-customized paths, and avoid moving or deleting existing .desktop files. I will add focused fresh-install/migration tests and run the project CLI/full test suites.

motodriver avatar Sep 01 '26 07:09 motodriver

Confirmed in source on current quattro (988f44ea): bin/omarchy-provision-user:109 sets DESKTOP to $HOME on a fresh install, and the 3.x upgrade sets it the same way in bin/omarchy-upgrade-to-quattro:2068. Apps that create desktop shortcuts write them to that directory, so they land in ~. I did not run the Steam or Chrome reproduction on a worker. The mechanism is explicit in the source, and whether an app writes to XDG_DESKTOP_DIR is that app's behaviour, not something Omarchy controls.

The fix is already open as #9563, which says Fixes #9556. It points new installs at ~/.local/share/desktop and adds a migration that changes the setting only where it is still exactly $HOME. On an upgraded machine that migration would correct the value: the upgrade sets DESKTOP before it runs pending migrations. #9563 will be reviewed separately. #9562 took the same approach and was closed in favour of #9563.

This review was done by Opus 5.5 alone. No second opinion ran, because the configured reviewer (Codex Medium) had reached its daily limit.

Next step is the maintainer's: whether to take #9563.

omarchybot avatar Oct 09 '26 12:10 omarchybot