Xfce Forum

Sub domains
 

You are not logged in.

#1 2015-07-08 22:07:06

Tuxy
Member
From: /home/tux
Registered: 2015-04-26
Posts: 3
Website

[WORKAROUND] Thunar - Create New File

If you ever used Thunar file manager, you know that there is no "Create File" shortcut,
there is only one to create "New Folder" using SHIFT+CTRL+N 

Make sure to install "zenity" package if you don't have it.

Create a script in /home/USER/newfile.sh

#!/bin/sh

file=$(zenity --entry \
        --title "Create New File" \
	--text "Enter the new name:" \
	--entry-text ""); touch "$file"

Set file permission: chmod +x newfile.sh

Then in Thunar create custom action:
"Edit" => "Configure custom actions..."

Name: Create New File
Description: Create new file using zenity
Command: ~/newfile.sh
(under Appearance Conditons tab)
File Pattern: *
(then select all of the "Appears if selection contains")

Then open your ~/.config/Thunar/uca.xml and find where you have name "<name>Create New File</name>" under it you should see <unique-id> remember the id.

Then open your ~/.config/Thunar/accels.scm file and uncomment your (gtk_accel_path "<Actions>/ThunarActions/uca-action-YOUR-UNIQUE-ID" "") after that apply shortcut key, I used "<Primary><Shift>f"

So in the end it should look simular to this; (gtk_accel_path "<Actions>/ThunarActions/uca-action-1234567890-2" "<Primary><Shift>f")

Log-Off, and Log back in and open your Thunar to try this new shortcut :-)

Now when I press SHIFT+CTRL+F or CTRL+SHIFT+F I get dialog like this;

FECvpJV.png

Its a bit ugly but works for me!

Last edited by Tuxy (2015-07-08 22:30:01)


--{ Using Arch Linux Since 2011-10-25 }--
Keybase @ https://keybase.io/tuxy
GitHub @ https://github.com/tuxy

Offline

#2 2015-07-09 17:48:26

Mark7
Member
Registered: 2007-10-05
Posts: 119

Re: [WORKAROUND] Thunar - Create New File

But there is a create new file shortcut.  It's just not called that (Create New Document is what you're looking for)

BopwT0Ll.png

Offline

#3 2015-07-09 18:03:04

Tuxy
Member
From: /home/tux
Registered: 2015-04-26
Posts: 3
Website

Re: [WORKAROUND] Thunar - Create New File

@ Mark7, you've obviously haven't read the whole post. I know there is a menu link, but the whole point to this workaround is to use "shortcut" > "SHIFT+CTRL+F" to create new file and not having to use a mouse.


--{ Using Arch Linux Since 2011-10-25 }--
Keybase @ https://keybase.io/tuxy
GitHub @ https://github.com/tuxy

Offline

#4 2015-07-11 09:28:29

Mark7
Member
Registered: 2007-10-05
Posts: 119

Re: [WORKAROUND] Thunar - Create New File

Ah right.

Thunar doesn't do keyboard bindings?

Offline

#5 2015-07-11 09:50:19

Tuxy
Member
From: /home/tux
Registered: 2015-04-26
Posts: 3
Website

Re: [WORKAROUND] Thunar - Create New File

@ Mark7, Not for "File" => "Create Document" => "Empty File"

But you can do for some other menu items in ~/.config/Thunar/accels.scm file.


--{ Using Arch Linux Since 2011-10-25 }--
Keybase @ https://keybase.io/tuxy
GitHub @ https://github.com/tuxy

Offline

#6 2016-05-18 11:40:41

mDfRg
Member
From: @mindefrag
Registered: 2016-05-18
Posts: 1
Website

Re: [WORKAROUND] Thunar - Create New File

Great work @Tuxy! I can confirm it works! Do you have any idea how to make it work in attached directories (like SAMBA share)? It appears that no custom action work in such folders...

Edit: at least it works with MOUNTED samba shares (via mount -t cifs //192.168.1.*/foo /mnt/bar).

Last edited by mDfRg (2016-05-18 12:21:00)

Offline

#7 2016-05-19 12:35:49

Misko_2083
Member
Registered: 2015-10-13
Posts: 211
Website

Re: [WORKAROUND] Thunar - Create New File

mDfRg
Another way to do it is with the 'file selection' dialog

#!/bin/sh

file=$(zenity --title 'Select Filename & Destination' \
--width=400 --height=500 --file-selection \
--save --confirm-overwrite)
if [ "$?" = "0" ]; then
   touch "$file"
fi

It asks for confirmation to overwrite if the file exists and lets you choose the path and create folders.
Just add the keyboard combo to run the script, no custom action needed.


Do you want to exit the Circus?
https://www.youtube.com/watch?v=ZJwQicZHp_c

Offline

#8 2021-02-15 10:04:18

gphilippi
Member
Registered: 2021-02-15
Posts: 1

Re: [WORKAROUND] Thunar - Create New File

Hi guys.

I made this script by try merge the minimalist entry interface of zenity with the --confirm-overwrite param in file selection.

#!/bin/sh

file=$(zenity --entry \
	       --title "Create New File" \
		--text "Enter the file name:" \
		--width=300 \
		--entry-text ""); 

while 
	test -e "$file" 
do
	file=$(zenity --entry \
	       --title "Create New File" \
		--text "File already exists. \nEnter a new file name:" \
		--width=300 \
		--entry-text "$file"); 
done

if [ "$file" != "" ] 
  then
	touch "$file"
fi

Is my first script. Hope you like.

Last edited by gphilippi (2021-02-15 10:05:35)

Offline

#9 2023-08-12 16:47:20

buddy99
Member
Registered: 2023-08-12
Posts: 1

Re: [WORKAROUND] Thunar - Create New File

I like Tuxy solution and made it simplier.
Thunar Edit>configure custom actions>new (plus sign)
Name: Create new file
Command: file=$(zenity --entry --title "Create New File" --text "Enter the new name:" --entry-text ""); touch "$file"
Shortcut: Shift+Ctrl+m (for example)
Tab Appearance: Pattern *, mark all boxes
That's it!

Offline

#10 2023-09-21 09:03:53

Sur3
Member
Registered: 2023-09-17
Posts: 3

Re: [WORKAROUND] Thunar - Create New File

With GTK<3.10 you could change all accels, meaning, you could have set a keybinding on every menu entry, but the GTK developers removed this feature because they think keyboard shortcuts should not be user editable:
"It's not a regression, if it's planned." - https://gitlab.gnome.org/GNOME/gtk/-/issues/5242

Last edited by Sur3 (2023-09-21 09:09:02)

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.010 seconds, 7 queries executed - Memory usage: 560.72 KiB (Peak: 577.56 KiB) ]