Xfce Forum

Sub domains
 

You are not logged in.

#1 2018-07-27 07:53:17

Friedrich
Member
Registered: 2016-09-18
Posts: 134

Rename files without a window

Hi,

can thunar rename files and folders without open an extra window and rename the files/folders directly? the windows file manager and also some file managers on linux behave like this, for example dolphin and pcmanfm-qt.

Offline

#2 2018-08-13 14:14:30

ema-pe
Member
Registered: 2018-03-20
Posts: 18

Re: Rename files without a window

I'm using Thunar by several years and never seen this feature. I suggest to open a bug on Bugzilla and propose it!

Offline

#3 2018-08-13 21:48:43

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

Re: Rename files without a window

A little fun with exploiting the thunar custom action and I could rename the file with the middle mouse button.
Just with the two small scripts. Not as perfect, opens at mouse pointer and doesn't always cover the file. Maybe I should try with the yad's form dialog. smile

Script #1

#!/bin/bash

# This script requires yad (yet another dialog) v0.40 or up
# Haven't tested with older versions. 
#
# 1. Save this script, make executable (chmod +x)
# _________________________________
# 2. Set the Thunar custom action
# _________________________________
# Name:     Rename with yad
# Command:  /path/to/this_script %n
# Appearance 
# Pattern: *
# Appear if selection contains: all
# _________________________________
#
# 3. Set the keayboard shortcut to
#    launch the custom action
# - Go to $HOME/.config/Thunar/uca.xml
#      Find a unique-id of the custom action
#      you previously set
#      e.g <unique-id>1395966727360904-5</unique-id>
# - Go to $HOME/.config/Thunar/accels.scm
#      Find the line that contains the unique id
#      add the keyboard shortcut and uncoment that line (remove the semicolon)
#      The line will look similar to next line:
#      (gtk_accel_path "<Actions>/ThunarActions/uca-action-1395966727360904-5" "<Primary><Shift>F12")
#      save accels.scm, logout and back in
# __________________________________
#
# Now ctrl+shift+F12 will launch the thunar custom action
# Presing return renames the selected file/folder
# Clicking outside or pressing escape aborts the renaming
#
# 4.   Setting Middle mouse click to launch the custom action
# -     Install xdotool
# Note:
#      The other script will work only if
#      "Double click to activate items" is set
#      in the file manager preferences is set.
#
# -    Save the other script, make executable (chmod +x)
#      The other script uses xdotool to emulate ctrl+shift+F12
#      on middle mouse click inside the Thunar window
#
#      Launch it in the terminal.
#      Open the Thunar and select a file with the middle mouse button click
# - If it works you could set the other script to run on boot.
# __________________________________
#
# The list of instructions is longer than this script.

if [[ -z "${1}" ]]; then
   exit 1
fi 

old_name="${1}"
new_name="$(yad --entry --no-buttons --skip-taskbar --mouse --close-on-unfocus --undecorated --entry-text="$1" --width=300)"

if [ $? -ne 0 ]; then
   exit
fi 

# "/" character is invalid on ext file systems
if [[ "${new_name}" == *[/]* ]]; then
   exit 1
fi

PWD=$(pwd)

# If the file exists on the path, asks to rename the destination
# Else just moves the file
if [[ -e "${PWD}/${new_name}" ]] ; then
     yad --text="File with name '${new_name}' already exists!" --button="gtk-ok!OK:0"
else
     mv -v "${PWD}/${old_name}" "${PWD}/${new_name}"
fi

Script #2

#!/bin/bash

MOUSE_ID=$(xinput --list | grep -i -m 1 'mouse' | grep -o 'id=[0-9]\+' | grep -o '[0-9]\+')

xinput --test-xi2 --root  $MOUSE_ID | grep "RawButtonPress" -A 3 --line-buffered | grep  "detail: 2" --line-buffered | while read -r line
do
    eval $(xdotool getmouselocation --shell)

    if [ "$(xprop -id $WINDOW WM_CLASS 2>/dev/null | awk '{print $4}')" == \"Thunar\" ]; then
        xdotool key ctrl+shift+F12
    fi
done

-----------------------------------------------------------------

I suppose the devs could do something similar.
There is already a window for renaming with the window that has one entry widget.
rkHcVzB.png
If they make the window undecorated, skip taskbar, remove the buttons, label and the pixbuf,
and position the window at the right place, it would have the same effect as the one in dolphin file manager.


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

Offline

#4 2018-08-13 22:41:14

MountainDewManiac
Member
From: Where Mr. Bankruptcy is Prez
Registered: 2013-03-24
Posts: 1,115

Re: Rename files without a window

Friedrich wrote:

can thunar rename files and folders without open an extra window and rename the files/folders directly? the windows file manager and also some file managers on linux behave like this, for example dolphin and pcmanfm-qt.

I am unsure whether or not I understand what you mean, exactly. It has been years since I used a Microsoft OS, and my experience with those others is both minimal and also some years in the past.

But I do remember a "feature" of a Microsoft file manager, where the user could simply left-click on a file name in the directory - and that file name would change to a textual input zone (I'm unsure of the technical term, but one could type a new name and press Enter).

Is this what you are speaking of? If so, while I do favor adding features that users want... I would hope that, if this one is added, if be added as an option. Because that behavior used to annoy the living <CENSORED> out of me every time I would accidentally activate it.

Regards,
MDM


Mountain Dew Maniac

How to Ask for Help <=== Click on this link

Offline

#5 2018-08-15 15:27:30

Friedrich
Member
Registered: 2016-09-18
Posts: 134

Re: Rename files without a window

MountainDewManiac wrote:

Is this what you are speaking of?

Yes, this is exactly what i mean. this isn't a "windows feature" also kde dolphin and pcmanfm-qt rename files in this way. i don't know whether the both program can rename files when click with the mouse on the file, but using f2.

Offline

Board footer

Powered by FluxBB