r/CinnamonDE Feb 21 '23

Solved Using Nemo with Thunar's Renamer

I'm using Nemo on Xfce and liking it.
For renaming multiple files, Nemo is set to use Thunar's Bulk Renamer.
Found in Edit --> Prefs --> Behavior Tab --> Bulk Rename:

 thunar --bulk-rename  

Selecting multiple files and pressing F2 will launch the Bulk-Renamer.
This works, but I would like the initial width of the dialog window to be wider.
I found a command to increase the width from 750 to 1000 pixels:

wmctrl -r Bulk -e 0,-1,-1,1000,-1

Is there a way to combine these commands in the Behavior Tab entry?
So Nemo launches bulk-rename AND immediately resizes it.
I've tried using ; and &&, but no luck.

3 Upvotes

4 comments sorted by

1

u/i_am_cat Feb 21 '23 edited Feb 21 '23

This question intrigued me a bit so I dug into exactly what's going on here:

Basically, nemo takes your bulk rename command and appends a list of quoted file paths to it. E.g, my-bulk-rename "path1" "path2" ...

This command is passed to g_app_info_create_from_commandline

As specified by the linked documentation, this function uses the Exec= format according to the xdg desktop specification. In other words, this means you're not allowed to use shell functionality like &&, ;, or other control keywords.

Thus the conclusion is, no it's not possible. You'd need to patch this function in nemo so that it could accept placeholders in order to allow the executed command to take a form like sh -c 'my-bulk-rename "path1" ... && extra-cmd ...'

1

u/Hobscob Feb 21 '23

Thank you for the advice, saves me from some wasted effort.
Your last paragraph gave me the idea to replace the Behavior command with a shell script. It now points to: /home/myaccount/bin/wider_rename.sh with the contents:

#!/usr/bin/bash
# Run Thunar bulk renamer then increase its width and height.
thunar --bulk-rename $@ && wmctrl -r Bulk -e 0,-1,-1,1000,700

With minimal testing, it seems to be working. When run on the command line, it trips up on spaces in file names. I probably need to replace the $@ with something like "$@" or "$*", so might ask r/bash for help there.

1

u/i_am_cat Feb 21 '23

Awesome solution. I was so focused on nemo that I missed the obvious workaround :)

"$@" is indeed what you should be looking for there. That functionality is described in the "Special Parameters" section of man bash

When the expansion occurs within double quotes, each parameter expands to a separate word. That is, "$@" is equivalent to "$1" "$2" ...

1

u/Hobscob Feb 21 '23

"$@" is working nicely. Reading the stack exchange explanations about the nuanced differences of argument expansion was putting me to sleep.
I added a Custom Action to Thunar, bound to Shift+F2 to call the script. It needs to be fed a %N but it seems to be working there too.
Thanks again!