Developed by: Yazeed Ali Al-Ghamdi
This is a working prototype developed by Yazeed Ali Al-Ghamdi that adds Freeform Path Selection (Brush Selection) to the Nemo File Manager in Linux Mint. Instead of relying solely on the traditional box selection, users can now right-click and drag to draw a freeform path, intuitively selecting any file the path intersects.
I built this feature to solve a long-standing workflow limitation, hoping it helps the Linux community!
I modified src/nemo-icon-view.c to hook into pointer motion and button events without breaking core functionalities:
- Smart Timeout: Right-clicking initiates a
g_timeout_addsuspension. If released immediately without moving, the standard context menu pops up. If dragged (>10 pixels), path selection mode is activated. - Cairo Visual Feedback: Mouse movement coordinates are stored in a
GArrayand drawn usingcairo_t, dynamically pullingtheme_selected_bg_colorfor a native look. - Synthetic Event Injection: Bypassing standard external selection barriers, the code injects synthetic
GDK_BUTTON_PRESSevents (GDK_CONTROL_MASK+send_event = FALSE) to programmatically select files under the cursor path. - Spatial Hashing (Anti-Toggle Mechanism): Since
Ctrl+Clicktoggles selections, moving the cursor slowly would naturally deselect items. I solved this by implementing a "Spatial Memory" array that checks the squared distance (< 2025.0or ~45px) against all previously clicked points in the current stroke, ignoring duplicate synthetic clicks within that radius.
You can apply the attached .patch file directly to the Nemo source code:
git am 0001-Feature-Add-right-click-freeform-path-selection.patch
Looking forward to the Linux Mint community and core devs reviewing this concept, polishing it, and hopefully merging it into the official release. If you find this helpful, prayers and good wishes are highly appreciated!