Page 1 of 1
Weird behavior after modifying Pfind func script
Posted: Sun Aug 22, 2021 12:34 pm
by miltonx
Here is some background info:
I have many .txt files on an ntfs partition, and frequently need to Pfind some of them to edit. When the relevent files are found in Pfind, they cannot be double clicked to edit, because puppy (or rox-filer or pfind) sees any plain text file on a non-linux partition as executable. Double-clicking simply runs them. Have to use right-click and choose "open as text". I find this very annoying and decided to modify the Pfind program. And that's the scenario where weird things happend.
System: fossapup64_9.5
First attempted solution (with weird behavior):
I modified the following part of /usr/local/pfind/func:
Code: Select all
-execute) #open with MIME-type settings
$FILEMANAGER "$2"
;;
to:
Code: Select all
-execute) #open with MIME-type settings
if echo "$2" | grep -i "\.txt$"
then
leafpad "$2"
else
$FILEMANAGER "$2"
fi
;;
Then I tested it like this:
Code: Select all
echo "galculator" > /mnt/sdb2/zzz.txt
Then search out this file with Pfind. Double click it. It is opened by leafpad. Seems OK, Huh? Here is the weird thing. When I close the leafpad window and the Pfind window, Galculator pops up!
Second solution which worked without any problem:
The above code in /usr/local/pfind/func was modifed to:
Code: Select all
-execute) #open with MIME-type settings
if [[ "$2" == *.txt ]]
then
leafpad "$2"
else
$FILEMANAGER "$2"
fi
;;
I don't see any substantial difference between solution 1 and 2, but why did solution 1 turn wacky? What am I missing?
Re: Weird behavior after modifying Pfind func script
Posted: Wed Aug 25, 2021 10:33 pm
by April
Does "\.txt$" get all the texts?
Fossa seems full of problem behaviours but I would say the chosen action for text files is wrong . Maybe check that and change it rather than change the script.?
In xenialpup64-7.5 double clicking on a found file in Pfind just opens it as text .It does not run it in any way I can see.
First time I have ever used "galculator".
Re: Weird behavior after modifying Pfind func script
Posted: Thu Aug 26, 2021 12:26 am
by bigpup
Well I have Fossapup64 9.5 installed and fully updated by using Quickpet->Info->Fossapup updates.
Pfind is version 6.3
I can search for .txt on ntfs formatted partition Windows 10 is installed on.
A list of .txt files for search result.
Double clicking on them seems to do nothing.
But I can right click on a .txt file
Select open as text
It Shows the contents of the file displayed in Geany program.
I wonder why double clicking does nothing in my Pfind?
Is that what your code change is allowing?
Double click to do something?
Re: Weird behavior after modifying Pfind func script
Posted: Thu Aug 26, 2021 2:32 am
by miltonx
bigpup wrote: ↑Thu Aug 26, 2021 12:26 am
Double clicking on them seems to do nothing.
Actually, pfind is doing something when you double-click. It tries to open the txt file by running "$filemanager" command on the file. $filemanager is usually defined by pfind to be equal to the "rox" command. That is, under the hood this command is run:
Code: Select all
rox the-file-you-double-clicked.txt
You can do some experiment in the terminal by running the above command line, and you will find that the "rox" command runs any .txt file on an ntfs partition as an executable rather than a plain text. However, on an ext partition, it will depend on whether the file is executable or not. If executable, it will be run as a program. If not, it will be opened by text editor.
Well, what I was trying to do is to add some condition in the pfind script to rectify that. That is, whenever a .txt file is found by pfind, I used the "leafpad" command rather than "$filemanager" / "rox".
Re: Weird behavior after modifying Pfind func script
Posted: Thu Aug 26, 2021 2:40 am
by miltonx
April wrote: ↑Wed Aug 25, 2021 10:33 pm
Does "\.txt$" get all the texts?
Fossa seems full of problem behaviours but I would say the chosen action for text files is wrong . Maybe check that and change it rather than change the script.?
In xenialpup64-7.5 double clicking on a found file in Pfind just opens it as text .It does not run it in any way I can see.
First time I have ever used "galculator".
"\.txt$" is a pattern meant to identify those files whose names end with ".txt". I wrote this because I only wanted to set my customized action on .txt files. For other file name extensions, I do not want to customize any action, no matter if they are actually text files or not.
"galculator" is a build-in calculator app in fossapup64_9.5. I wrote it in the .txt file in order to test if the .txt file was run as a script. It proved true. You can try testing it by making a .txt file in an ntfs partition. The file should contain some kind of command like "galculator". Then you open a terminal and run "rox this-file.txt", and see.
Re: Weird behavior after modifying Pfind func script
Posted: Thu Aug 26, 2021 9:48 am
by April
My sda1 is a ntfs hard disk and does not execute the chosen file ,rather opens it in text..
In xenialpup64-7.5 double clicking on a found file in Pfind just opens it as text .It does not run it in any way I can see.
- gmtp(1).jpg (20.85 KiB) Viewed 133 times