Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 12 Dec 2017, 21:46
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
How to capture selected-files with key press in Rox?
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [5 Posts]  
Author Message
arivas_2005

Joined: 25 Feb 2007
Posts: 191

PostPosted: Sun 22 Oct 2017, 00:13    Post subject:  How to capture selected-files with key press in Rox?
Subject description: SOLVED!
 

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/viewtopic.php?t=107816&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, 11:25; edited 1 time in total
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1397
Location: Japan

PostPosted: Sun 22 Oct 2017, 02:26    Post subject:  

Try
Code:
#!/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.
Back to top
View user's profile Send private message 
arivas_2005

Joined: 25 Feb 2007
Posts: 191

PostPosted: Sun 22 Oct 2017, 16:23    Post subject:  

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:
#!/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
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1397
Location: Japan

PostPosted: Mon 23 Oct 2017, 08:07    Post subject:  

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:
#!/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
big_rox_rename_dialog.png
 Description   
 Filesize   23.75 KB
 Viewed   74 Time(s)

big_rox_rename_dialog.png

Back to top
View user's profile Send private message 
arivas_2005

Joined: 25 Feb 2007
Posts: 191

PostPosted: Mon 23 Oct 2017, 11:26    Post subject:  

thank you very much
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [5 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0446s ][ Queries: 15 (0.0065s) ][ GZIP on ]