Repository navigation
feat(shell): add HatchZip to Thunar's right-click menu - #118
Conversation
|
Thanks for adding Thunar support. I tested I found four configuration cases worth handling before merge.
I verified these through |
962e40c to
73521a6
Compare
|
Thanks for testing this so carefully, all four were real. Fixed in 73521a6. The file is now read as XML instead of searched as text: comments, CDATA, processing instructions and the doctype are skipped while looking for the root and its actions, so the
There's a test for each in |
|
Thanks for the update. I retested I found two more ways an existing config or action can be lost:
The XML scan still accepts some malformed input. I tried a user action named These results come from the shell registration code. They don't cover the live Thunar menu. |
|
Thanks for another careful pass. All three reproduced here and are fixed in 359ddce.
Each case has a test in |
xevrion
left a comment
There was a problem hiding this comment.
Thanks, this is careful work: ownership by the direct <unique-id> child, everything else copied byte for byte, and the stale-marker fixes all hold up. Two things before merging:
- Unregister leaves behind a
uca.xmlHatchZip created from the system defaults. When the user has none,thunar_currentcopies$XDG_CONFIG_DIRS/Thunar/uca.xmland writes the marker, butthunar_unregisteronly deletes the file when what's left equalsTHUNAR_EMPTY. A copy of the defaults never does, so it stays and shadows later distro updates to them (the testthunar_keeps_every_action_that_is_not_hatchzipspins that). When the marker exists and what's left equals what the file was created from, remove it; storing a hash of the source in the marker would do. - A Thunar file HatchZip can't edit now blocks every other file manager. Thunar goes first and errors, so a KDE, GNOME or Nemo user with an odd
~/.config/Thunar/uca.xml(non-UTF-8, or anything the parser refuses) gets no menus at all, where on main they would. The GUI switch hits the same path (main_window.rs:684). Please skip Thunar with a "Thunar: skipped, " line and still register the others.
Smaller, here or as a follow-up:
- Thunar reads
uca.xmlonce at startup and doesn't watch it, and in an Xfce session it usually runs as a daemon. So the actions don't appear until it restarts, and if the user then edits custom actions in Thunar, it rewrites the file from its stale list and drops ours. The result line should say to restart Thunar (thunar -q). - Thunar matches patterns case-sensitively (
g_pattern_match_simple), so*.zipmissesGAME.ZIP. Upper-case variants would cover it. write_atomichas nosync_allbefore the rename, so a crash on XFS or btrfs can leave an emptyuca.xmland lose the user's actions. It also replaces a symlinkeduca.xml(stow and other dotfile managers) with a regular file, and drops the original permissions.- Minor:
- When the copied system file can't be parsed, the error names the user path, which doesn't exist yet.
- An unreadable system file is skipped silently.
entities_okaccepts any named entity, but GMarkup only takes the five predefined ones.is_registeredstill only checks the KDE file, so existing installs won't get the Thunar actions until the switch is toggled.- TODO.md's Thunar lines can be ticked.
|
Thanks, went through all of it in 4822547.
fmt, clippy (CI flags) and the tests pass with and without |
|
Thanks, the six points look right in the code. CI found something on Linux, though, and it's a useful one: the Ubuntu runner has a real
|
|
I reproduced both CI failures on The two CLI tests use separate data directories and share the Thunar config. Both registrations open the same Ubuntu Noble's packaged |
|
I also tested With no user edits, Thunar assigned a missing ID to Ubuntu’s stock “Open Terminal Here” action and rewrote |
Thunar keeps all custom actions in one uca.xml the user edits too, so only the action blocks with a hatchzip- unique-id are added or removed. When the user has no uca.xml yet, the system one is copied in first so "Open Terminal Here" doesn't disappear, and a file that isn't an actions file is left alone.
The end tag and actions are now found by walking the elements, skipping comments, CDATA, processing instructions and the doctype. A file that isn't a well formed <actions> document is refused before any menu is written, <actions /> is handled like <actions/>, and unregister only deletes uca.xml when HatchZip created it, so a user's own empty file stays.
An action is HatchZip's only when its direct <unique-id> child starts with hatchzip-, so an id mentioned in a comment no longer removes a user action. Text and tags with an unescaped & are refused, as Thunar's parser would. Unregister clears the ownership mark even when the file is already gone, and register drops a mark that sits next to a file without HatchZip's actions.
…real config - unregister returns the skipped lines like register does, so a Thunar file HatchZip can't edit no longer fails --unregister-shell or the switch - each write_atomic call uses its own temp name, so two registrations at once can't interleave into one file - a generated copy that Thunar has rewritten on load still goes on unregister when its actions match the system file's - GUI tests point XDG_CONFIG_HOME and XDG_CONFIG_DIRS at a temp folder
4822547 to
863ceee
Compare
|
Rebased on main (the conflict was the Settings window change in
@garvrao80, thanks for the live Thunar run. When Thunar rewrites the copy on load, unregister now compares the actions that are left with the system file's (child elements and their text, ignoring fmt, clippy with |
|
Thanks, this covers everything from my last comment. One small optional thing: a uca.xml that starts with a UTF-8 BOM is still refused ( |
|
GMarkup skips a leading BOM, so parse_uca now allows one before the root and the file keeps it after the edit. Added a register/unregister round trip with a BOM to the Thunar test, in 67d3b69. |
xevrion
left a comment
There was a problem hiding this comment.
Thanks, great work @ardazeybek and @garvrao80!
What this changes
Adds HatchZip to Thunar's right-click menu, the "Thunar custom actions" item in TODO.md.
--register-shellnow also writes the five actions into$XDG_CONFIG_HOME/Thunar/uca.xml, under a HatchZip submenu, and--unregister-shelltakes them out again.Why
Thunar was the one common Linux file manager left out. It keeps every custom action in a single file the user edits too, which is why it was skipped before, so the change is careful about that file:
<action>blocks whoseunique-idstarts withhatchzip-are added or removed. Everything else stays byte for byte.uca.xmlit finds. When the user has none yet, the system one from$XDG_CONFIG_DIRSis copied in first, otherwise "Open Terminal Here" would disappear from the menu.Dirsgetsconfigandsystem_configfor this; Windows and macOS leave them empty.Verification
On Arch Linux with Thunar 4.20.10 (Hyprland), using
registerwith a stand-in forhatchzip-guithat writes its arguments to a file:My Games/a b.zipshows a HatchZip submenu with all five actions. "Open Terminal Here" is still in the menu.--keep-archive,--extract-hereand the full path, the spaces intact.uca.xmlitself when it loads it (tabs, a generatedunique-idfor its own action).--unregister-shellon that rewritten file removed exactly HatchZip's five actions and left Thunar's.Not verified: editing the actions through Thunar's "Configure custom actions" dialog, and Thunar versions before 4.18, which have no
<submenu>and would show the five actions at the top level.cargo fmt --all --checkandcargo clippy --all-targets -- -D warningspass (clippy forhatchzip-shell)cargo testpasses (hatchzip-shell; the change is limited to that crate and a comment inhatchzip-gui)