I'd like pressing backspace to step one level up (outside) in a directory hierarchy instead of going to the previous opened location. How to configure this in Thunar?
2 Answers
You need to have editable keyboard accelerators turned on as documented under "How do I assign different keyboard shortcuts?" on this page*. Then hover over menu Go->Open Parent and press backspace to clear the current shortcut and then press backspace again to assign backspace as the shortcut.
That should add this line:
(gtk_accel_path "<Actions>/ThunarWindow/open-parent" "BackSpace")
to your ~/.config/Thunar/accels.scm
*This setting is also exposed in the Gnome Configuration Editor under:
desktop->gnome->interface->can_change_accels
- 115
- 6
- 421
- 4
- 9
This problem has haunted me since the gtk_accel_path method stopped working around Ubuntu version 21.10. I'm running thunar version 4.16.10. I think I have a solution using autokey-gtk:
Install autokey
sudo apt install autokey-gtk
Open the AutoKey application, click New, then Script, and then I named it backspace_for_parent (your choice). Replace # Enter script code with the following:
win_class = window.get_active_class()
win_title = window.get_active_title()
if win_class == 'Thunar.Thunar' and win_title.startswith("/"):
keyboard.send_keys("<alt>+<up>")
else:
keyboard.send_keys("<backspace>")
(The second startswith condition above was needed to allow normal backspace when renaming files or setting the name of a new folder.)
Then, below, for Hotkey, click Set. Click Press to Set and hit backspace and then click OK.
Finally, at the top, click Save.
Now, in Thunar, hitting the backspace key opens the parent folder!
This is slightly suboptimal in that it uses an external application, but AutoKey is fantastic and it's already part of my daily workflow, so nbd from my perspective.
Hope this helps someone.
Inspiration taken from:
https://unix.stackexchange.com/a/491868/126708
- 115
- 6
-
Nice answer. The only thing I would add would be to set a window filter in AutoKey looking for the window class. This wouldn't change it's behavior, but it would free up the backspace key as a hotkey that could be assigned to another script or phrase that had a different window filter that is mutually exclusive with this window filter. You can visit us on [Gitter](https://gitter.im/autokey/autokey) if you like. – Joe Feb 08 '23 at 15:08
-
1Thanks for the feedback. How specifically would you do the window filter? I hardly recall posting the above answer and am quite rusty. Perhaps related, I've run into a problem with the above where, when 1) using `Synergy` to control a separate machine 2) using a VM via boxes and 3) using the launcher app `Kupfer`, backspace functions as a double backspace, which is quite unpleasant. Any ideas appreciated. – Adam Smith Feb 15 '23 at 17:59
-
Select your script in the left panel of the AutoKey main menu after selecting the folder it's in. On the right bottom panel, Click `Set` to the right of Window Filter. Type Thunar.Thunar and then select OK. Now your script will still work as is, but you could eliminate the test for win_class because the filter assures that will be true. Since it's a regex, putting a backslash before the dot would be technically correct, but it will work either way in this case. – Joe Feb 19 '23 at 15:32
-
I'm not familiar with either of those other programs. We could work through it and see how far we get, but that's not appropriate in comments here. To get more interactive help with this, visit us on [Gitter](https://gitter.im/autokey/autokey). We also have other [places](https://github.com/autokey/autokey/wiki/Community) you can go, but that's the best one for this issue. – Joe Feb 19 '23 at 15:50
-
I set script's **Window Filter** to `Thunar.Thunar` and revised script to be only `keyboard.send_keys("
+ – Adam Smith Feb 21 '23 at 16:35")`. This solves `Kupfer` and `boxes` VM problems! (Can't test `Synergy` rn.) But, it breaks backspace in two situations: 1) when renaming file/folder 2) when creating a new folder. As a workaround, I'll use delete instead. A nice add to `autokey` may be adding GUI filter (like **Window Filter** currently) to allow control over `win_title.startswith`. If I could put `/` in `win_title.startswith` via GUI, I believe it'd solve two issues above. Thank you! -
Glad it helped! Please file an enhancement [issue](https://github.com/autokey/autokey/issues) for your new filter idea. It needs a bit of elaboration and discussion and it will be lost here. – Joe Feb 23 '23 at 09:06