CachyOS / CachyOS/distribution

Custom Actions Broken on Thunar 4.20.6

Open
#294 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
No language data
Stars
27
Forks
2
PR merge metrics
No merged PRs in 30d

Description

# **Bug Report: Thunar UCA (Custom Actions) Failing After Update on CachyOS (znver4 Build)**

## **System**
- **OS:** CachyOS (znver4-optimized packages)
- **Thunar versions involved:**
- 4.20.5-1.1 → 4.20.6-1.1 → 4.20.6-1.2
- **Desktop:** XFCE 4.20
- **Plugins:**
- thunar-archive-plugin 0.6.0-1.1
- thunar-media-tags-plugin 0.6.0-1.1
- thunar-volman 4.20.0-2.1
- **Hardware:** x86_64_v4 (Zen 4 optimized)

---

# **Summary of the Issue**

After a system update, Thunar’s **User Custom Actions (UCA)** became unreliable:

- Custom actions **disappeared** from context menu or **silently failed**
- Inline UCA scripts produced errors such as:

_: line X: ${base*}: bad substitution

- Incorrect filename handling:
- `example.txt` → `_1`
- Extensions missing
- Filenames mis-split
- Some actions (e.g., “Open Terminal Here”) stopped appearing
- Reinstalling/downgrading Thunar did not fix the issue
- Clearing config/cache directories did not fully remove corrupted behavior

---

# **Observed Technical Symptoms**

### **1. Thunar-generated wrapper code included invalid expansions**
Even though user scripts contained no `${base*}`, Thunar’s internal wrapper generated:

${base*}

leading to `bad substitution`.

### **2. Inline UCA scripts sometimes executed using `/bin/sh` instead of `bash`**
Despite using:

bash -c '

Thunar occasionally invoked the script under `sh`, causing pattern expansions (`${var%.*}`, `${var##*.}`) to fail.

### **3. `%f` argument contained unexpected trailing whitespace**
Example:

"example.txt "

This prevented extension detection, causing filenames to become `_1`.

### **4. Thunar used stale cached UCA metadata**
Even after replacing `uca.xml`, Thunar continued executing outdated, corrupted wrapper code.

### **5. znver4 builds showed distinct behavior in UCA wrapping**
Specifically around:
- shell fallback
- argument expansion
- internal wrapper generation

---

# **Troubleshooting Steps Attempted (Ineffective)**

The following did *not* resolve the problem:

- Reinstalling:
- thunar
- thunar-archive-plugin
- thunar-media-tags-plugin
- thunar-volman
- exo
- Downgrading Thunar (from 4.20.6 to 4.20.5 resulted in partial success)
- Regenerating `uca.xml` manually
- Clearing:
- `~/.config/Thunar/uca.xml.broken`
- `~/.cache/Thunar`
- `~/.local/share/Thunar`
- Killing Thunar/XFCE processes (`thunar --quit`, `pkill thunar`, etc.)
- Forcing bash via `/usr/bin/env bash`

None of these steps completely removed the erroneous `${base*}` expansion or filename corruption.

---

# **Root Causes Identified**

1. **Stale wrapper scripts** being executed even after UCA file replacement
2. **znver4 builds of Thunar producing different wrapper behavior**
3. **Trailing whitespace in `%f` expansion** from Thunar
4. **Malformed `` quoting causing fallback to `/bin/sh`**

---

# **Final Working Solution**

Moved all shell logic out of Thunar’s XML and into an **external script**, avoiding Thunar’s wrapper system entirely as well as downgrading to Thunar 4.20.5 .

### `/usr/local/bin/thunar-duplicate` (bash):

- Cleans `%f` input
- Correctly splits filenames & extensions
- Handles multi-dot extensions (e.g. `archive.tar.gz`)
- Works reliably across all file types
- Fully bypasses Thunar’s UCA wrapper and shell fallback issues

### UCA entry now simply:

/usr/local/bin/thunar-duplicate %F

This completely resolved:
- bad substitution errors
- missing extensions
- silent action failures
- wrapper corruption
- znver4 inconsistencies

---

# **Expected Behavior**
- Thunar should not generate invalid wrapper code (`${base*}`)
- `%f` expansion should not include trailing whitespace
- UCA commands should use the declared shell consistently
- Clearing/reinstalling Thunar should purge broken UCA caches
- UCA execution should be predictable across optimized builds (znver4 vs generic)

---

# **Request to Maintainers**

1. Investigate Thunar’s UCA wrapper on znver4 builds for:
- invalid variable expansions
- quoting/escaping inconsistencies
- shell fallback behavior
2. Improve UCA cache invalidation
3. Verify correctness of `%f` / `%F` argument expansion
4. Ensure inline `` scripts consistently use `bash -c` when declared
5. Consider recommending external scripts for complex UCA actions to avoid wrapper issues
6. Consider maintaining on Thunar on 4.20.5 until UCA support is restored

#Working example:
UCA entry:
/usr/local/bin/thunar-duplicate %F

Executable script:
#!/usr/bin/env bash

for f in "$@"; do
f_clean="$(printf "%s" "$f" | sed 's/[[:space:]]*$//')"

dir="$(dirname -- "$f_clean")"
base="$(basename -- "$f_clean")"

if [[ "$base" == *.* ]]; then
name="${base%.*}"
ext=".${base##*.}"
else
name="$base"
ext=""
fi

n=1
candidate="${name}_${n}${ext}"

while [[ -e "$dir/$candidate" ]]; do
n=$((n+1))
candidate="${name}_${n}${ext}"
done

cp -a -- "$f_clean" "$dir/$candidate"

# Delayed selection (key fix)
( sleep 0.2 && thunar --select "$dir/$candidate" ) &
done

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.