How to capture selected-files with key press in Rox?

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
arivas_2005
Posts: 212
Joined: Sun 25 Feb 2007, 14:39

How to capture selected-files with key press in Rox?

#1 Post by arivas_2005 »

regards
reading the pages

How to select files inside a ROX window by a bash script?
http://www.murga-linux.com/puppy/viewtopic.php?t=86079
picture: ROX-Filer_selection.png

Drag, drop and go
http://www.murga-linux.com/puppy/viewto ... 6&start=30
pag 3, picture: drag-and-drop.png

I have the curiosity to try another way (with its support, of course!)
I want to capture the 'names selected' with a script launched by the F2 key

For example, using the figure : ROX-Filer_selection.png
a) to capture them with right click use in script I use listfiles = @
b) with drag-drop - I use a variable (F.E. "${DROP_ZONE// \//\n/}" in drag&drop)
c) with control + c, I can use something with xdotool key
but, ??
how do I capture it with a script launched with a key F2 (assigned to F2 key)?
-- how to detect the files that are selected in rox with the script (launch pressed F2 key) --

Thanks you
Last edited by arivas_2005 on Mon 23 Oct 2017, 15:25, edited 1 time in total.

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#2 Post by MochiMoppel »

Try

Code: Select all

#!/bin/bash
SRC=$(xclip -o)        # Assign names (full paths) of selected files to variable
SRC=${SRC// \//$'\n'/} # Put every file name on new line
Xdialog -left -backtitle "You selected:" -msg "$SRC" x
The script requires xclip to be installed. It's included in most Puppies, some use xsel which in this case uses same syntax.
I assume that you know how to assign a keyboard shortcut to scripts, so I don't explain it here but I strongly recommend not to use F2 or any other function key.

arivas_2005
Posts: 212
Joined: Sun 25 Feb 2007, 14:39

#3 Post by arivas_2005 »

Thansk you!. MochiMoppel
I try to make a script to rename (larger)
rename in rox has a very small window
script is executed by pressing F2
Code:

Code: Select all

#!/bin/bash
#secure window rox
window_top=`xprop -id $(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2) _NET_WM_NAME | grep -i miniature`
length_top=${#window_top}
	if [ "$length_top" -eq 0 ];then
		exit
	fi
# capture selected file
	sleep 0.1
	SRC=$(xclip -o)        # Assign names (full paths) of selected files to variable
	lengthcopy=${#SRC} #  problem when clipboard has other contents and/or file not selected
	if [ "$lengthcopy" -gt 0 ];then
			xdotool key Ctrl+c
			sleep 0.3
			xdotool getactivewindow windowmove 900 1  
			newvalue=`Xdialog --title "rename" --stdout --inputbox "Base name \n ""$SRC"" \n Now, Can Modified \n " 0 0 "$SRC"`
	else
		Xdialog --msgbox "Not selected" x
		exit
	fi
# ...
Xdialog --msgbox "NAMES equals \n""$SRC"" \n ""$newvalue" 0 0
# ---
wmctrl -c "Copy"

exit
You can not find a way to suspend the scritp when no files are selected and you accidentally press F2
I try to use ctrl+c as a reference to see if there is a selection but I can not organize it

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#4 Post by MochiMoppel »

You are trying to solve the wrong problem.
Don't reinvent the wheel when your only problem is ROX-Filer's small Rename dialog.

You've got xdotool, so use it. I'm not an expert in xdotool but I know that it can do what you want.

Below demo script works for me. It assumes that in ROX-Filer you have assigned a shortcut to the Rename dialog. By default there is none. I use Ctrl+r.
It also assumes that you have assigned a shortcut to the script. If you still prefer F2 .... OK, your choice, I warned you.

Select a file in ROX-Filer and run the script.

Code: Select all

#!/bin/bash
WNAME=$(xdotool getactivewindow getwindowname) # get title of active window
[[ ${WNAME::1} != [/~] ]] && exit              # exit if first character is not '/' or '~' (AFAIK all ROX-Filer titles start with '/' or '~')
sleep .5
xdotool key Ctrl+r                             # Press Ctrl+r (or whatever shortcut is assigned to ROX-Filer Rename dialog
xdotool getactivewindow windowsize	400 100    # Set dialog size to 400x100
Attachments
big_rox_rename_dialog.png
(23.75 KiB) Downloaded 116 times

arivas_2005
Posts: 212
Joined: Sun 25 Feb 2007, 14:39

#5 Post by arivas_2005 »

thank you very much

Post Reply