Global search GUI for antiX

Forum Forums General Software Global search GUI for antiX

  • This topic has 175 replies, 12 voices, and was last updated Jan 13-9:33 pm by Brian Masinick.
Viewing 15 posts - 121 through 135 (of 176 total)
  • Author
    Posts
  • #124214
    Forum Admin
    anticapitalista

      What has gtp to do with finding files/folders?
      I don’t get it.

      Philosophers have interpreted the world in many ways; the point is to change it.

      antiX with runit - leaner and meaner.

      #124218
      Member
      PPC

        What has gtp to do with finding files/folders?
        I don’t get it.

        Nothing, just like finding stuff on the web, using ddgr has nothing to do with finding files/folders.
        I just thought it would be useful if antiX users could have (like available on some other OSes), out of the box (or by installing this script) the possibility to Find pretty much anything, in an easy and intuitive way:
        1- find files/folders on their home folder (and now, on any mounted drive or partition, and even on the Cloud) – the essencial part of the script, where it got it’s name from.
        2- find applications (either general applications or the ones that manage some of antiX’s settings, like Wallpaper, firewall, etc – not essential, since we already have app-select, but app-select does not find apps that don’t have .desktop files, Finder does, also finds command line apps)
        3- find stuff on the web (users can already to that using a web browser, but using ddgr allows users with machines too slow to regularly use a modern browser, quick access to search results. They only have to suffer opening a new browser window/tab, when they really have to)
        4- find answers to just about any question they can ask, in many languages (using tgpt, that seems to be pretty anonymous, since it runs from the terminal, not requiring any log-in)
        … all this using a common UI.

        Of course, finding answers to general questions, using tgtp is secondary, just a little addition. When I posted the first test version that included a “gpt” button, I warned users that having that feature depended on the reaction of the community and, of course, mainly, from your reaction.
        If you don’t like that feature, I can remove it from the public Finder version, almost instantly – you just have to say so.

        My original idea was to make an easy to use app that acted almost like an Oracle (providing the answer to just about any question the user could ask: where is this file? where is this application? Where can I find this on-line?… and even general questions, like “What is Linux? What is runnit? What are appimages?, etc”, this feature depends on using a conversational AI).
        By the way, I almost called this script “Oracle”, but I though people would think it had something to do with the company that has that name…

        EDIT: I forgot – the AI can even act as an instant translator, no other GUI required.
        Ex:Translate, to English "O Linux é o melhor Sistema do Mundo"
        Non English speaking users can just find the translation to almost anything, using that feature- although I dislike on-line translations, it’s better than not understanding anything, right?

        P.

        • This reply was modified 3 months, 1 week ago by PPC.
        • This reply was modified 3 months, 1 week ago by PPC.
        • This reply was modified 3 months, 1 week ago by PPC.
        #124276
        Member
        marcelocripe

          …that feature depended on the reaction of the community and, of course, mainly, from your reaction.

          I hope the PPC Finder continues to have the GPT search button. I, and most people I know will not search via Terminal, they will either use the PPC Finder or they will have to use the internet browser.
          I do think this is a very interesting feature to have in antiX.

          – – – – –

          …that feature depended on the reaction of the community and, of course, mainly, from your reaction.

          Eu espero que o Finder do PPC continue tendo o botão da pesquisa do GPT. Eu, e a maioria das pessoas que eu conheço não irão pesquisar via Terminal, ou usarão o Finder do PPC ou terão que usar o navegador de internet.
          Eu acho sim que este é um recurso muito interessante para termos no antiX.

          #124298
          Member
          ile

            Yes Wallon i got to that too many arguments. It is because we ran it in terminal?; when Finder is “Run” launched not in terminal, then the gui window closes and next call it will use the tgpt is installed.
            PPC the ‘New Search’ button is great.
            {not about honey not about war ; }

            Language tools by gpt is handy. (?)
            gpt will take input of “conjugate *verb*.”
            Aha, Brasilian, there is a package in the repository for conjugar.
            Language tool? Regional “to conjugate Portuguese verbs as spoken in” Brasil.
            Conjugate, Brasil. benefit?

            install the packages <gconjugue> and <gconjugue-common>

            Add a button to Finder that will call gconjugue with the input given;
            sample GConj Button 32 sample in Finder function main_window.

            main_window()
            {
            # Toggle the script off if already running (prevents file search running on empty, if user runs a second instance of the script) 
            # This is great if user is running the script from a taskbar icon, for example, and clicking it twice, to toggle on/off the search window.
            if pidof -x "finder" >/dev/null; then
                echo "$mv_starting_finder"
                else
            # close any previous window and then exit:
            kill $(xprop -name Finder _NET_WM_PID)
            exit
            fi
            # clean temporary file
            echo "" > /tmp/yad
            # Draw main window and get user input from search field and from buttons, using --on-top flag because of the default fluxbox configuration:
            yad --title="$mv_finder" --on-top --width=400 --image=/usr/share/icons/Adwaita/48x48/legacy/preferences-system-search-symbolic.symbolic.png --text="" --borders=10 --mouse --undecorated --close-on-unfocus --escape-ok --skip-taskbar --form --field="" --button="⌕ $mv_Files_2":2 --button="⌕ $mv_Apps_Settings_4":4 --button="GConj":32 --button="⌕ $mv_Web_44":44 --button="⌕ GPT":66 > /tmp/yad
            foo=$? && echo $foo >> /tmp/yad
            query=$(sed '1q;d' /tmp/yad| sed s'/.$//')
            button=$(sed '2q;d' /tmp/yad)
            # run selected action, acording to the selected button
            # 0 is when no button is pressed- the script interprets that as doing a file search for the text entered:
            if [[ $button -eq 0 ]]; then
            file_finder
            fi
            if [[ $button -eq 2 ]]; then
            file_finder
            fi
            if [[ $button -eq 4 ]]; then
            app_finder
            fi
            if [[ $button -eq 32 ]]; then
            echo $button
            gconjugue &
            sleep 0.9s
            xdotool type "$query"
            xdotool key Return Tab Tab Return
            fi
            if [[ $button -eq 44 ]]; then
            web_finder
            fi
            if [[ $button -eq 66 ]]; then
            interact_with_gpt
            fi
            }
            
            Attachments:
            #124300
            Member
            PPC

              @ile-Ah ah!

              Thanks for making me laugh. I needed that.
              I did not know about that nice little app, once again, thanks for letting me know about it.

              Now, seriously, I don’t think it’s a tool that will ever come with a search application by default, but you illustrated very well how I make my script to be easily extensible. Anyone can add new features to it.

              And yes, when I create a GUI script, it’s to help people that don’t want to use the terminal or manually edit files. I only run my scripts from the terminal when I’m testing them, that’s why they still keep some messages that I use to check for stuff, like internet connection, errors during search, etc…
              I always test my script on an installed antiX 22 and on antiX 23.1 live. When I make available a script with a problem, usually it’s because I make a tiny change after testing it in the “virgin, live” system. I know tgpt installs fine from the current Finder version, not because I tested Finder on my installed antiX (that already has tgpt installed), but because I checked it on the live version (that always requires dependencies to be installed).

              Any opinion on the new file search results with more details? Is that useful? Does it slow down the search too much?

              P.

              #124301
              Member
              ile

                PPC I am so glad it brought a smile to You.

                details are there. Not slow.

                #124302
                Member
                PPC

                  @ile – Great!

                  I’ll wait until the week-end, for anyone interested to test the script and then add file details to files searched in the /media folder too, and try to ship it to anticapitalista.
                  Unless a real bug is found or anticapitalista wants the GTP functionality to be removed, that will be the final, final version 1.0 of the script, as it will probably be in antix 23.1 final version (or so I hope).
                  I love this script, but I can’t wait for it to be completely finished- I’ve been saying for a while now that I have to put a break on the time I spend scripting stuff for antiX, but new ideas kept coming in…

                  EDIT: in case I never mentioned this before, Finder, because it can also find command line programs, it can often be used to run terminal commands directly, just like the “Run” menu entry (but always runs those commands inside a new terminal window, so even GUI apps, like volumeicon, when opened this way, leave a terminal window open. It’s a compromise, a way to run almost anything, with the side effect of, when running apps that don’t have a .desktop file, they always run from a terminal).
                  Ex: if you want to find all about the “ls” command, you can ask Finder to search for “man ls” and click the “search apps…” button. A terminal window opens almost instantly, showing the ls’s manual page… Yes, I know that after quitting any terminal app you have to close the terminal window. It’s a feature, not a bug (it allows commands like “top” to be launched from Finder and work properly)

                  P.

                  • This reply was modified 3 months, 1 week ago by PPC.
                  #124304
                  Member
                  Wallon

                    Dear PPC,

                    Line 452 says [… field=”CHATGTP: …] check whether this should be replaced by “CHATGPT”? The letters TP and PT are reversed.

                    Line 452 says [… –button=”x” …], you need to set the [“$mv_x”] variable to get the button translation.

                    I’ve appended the new pot file without the comments…

                    Dear ile,

                    Thanks for the explanation about “Too many arguments”. It’s true that I no longer get this message if I run the script directly outside a terminal.

                    Kind regards,
                    Wallon

                    Attachments:
                    #124307
                    Member
                    PPC

                      @Wallon – many thanks. I’ll fix line 452 on the final release, yes it’s a typo. Also the window’s name will just be “Finder”, since the window itself already includes a mention to the gpt… I’m thinking about changing that text to just “GTP” or “TGPT” since I don’t want the guys from Chatgtp to come knoking, telling what the script can’t use that name.
                      Any idea of exactly how that window should identify the software that “finds the answer” to the user’s question? If people read GTP, they may assume it’s related to that kind of software, but the “T” may confuse them. Like in the button on the main window, I did not want to use “AI” because… several reasons- this kind of programs are “Artificial” for sure, but not really “Intelligent”, also that term may scare some users. In a way, I’m glad tgpt really is “amnesiac”, can remember anything other than the last question the user made. This way it probably does not harvest any data from user’s questions (since it can’t really create a user profile)- it’s simply a tool to find answers to questions or follow prompts.

                      @all:

                      Note: tgpt does some complex stuff, like getting the context of your question. It’s easy to answer “What is the closest start to Earth?”, and that already implies some understanding of what the user wants… It’s more complex to get the answer to “What is the closest start to Earth, not counting the Sun?”.
                      This may be a great tool to help kids satisfy their curiosity, but as always, remind them that “the computer is not a person, but it can make mistakes or lie, just like a person”.

                      EDIT: in case you use Finder on a version previous to antiX 23, and you don’t see the “magnifying glass icon” that the script should display on it’s windows, that’s easy to solve, using a replacement icon:
                      antix Menu > Terminal > enter this command (and type your password, if asked to):
                      sudo cp /usr/share/icons/Adwaita/48x48/legacy/system-search.png /usr/share/icons/Adwaita/48x48/legacy/preferences-system-search-symbolic.symbolic.png

                      P.

                      • This reply was modified 3 months, 1 week ago by PPC.
                      • This reply was modified 3 months, 1 week ago by PPC.
                      #124313
                      Member
                      Wallon

                        Cher PPC,

                        I don’t think there’s any problem if you use the acronym GPT (Generative Pre-trained Transformer).
                        It’s not a registered and protected trademark.
                        It’s like the expressions for text messaging (SMS) or the Web. These are computer or electronic processes.
                        With the acronym (GPT), users will directly understand that there is an artificial intelligence that will process the request.

                        For your information, I tested Finder with antiX 23 Full 64 bits sysvinit version fr_BE (JWM window manager).

                        Kind regards,
                        Wallon

                        #124315
                        Member
                        PPC

                          I don’t think there’s any problem if you use the acronym GPT (Generative Pre-trained Transformer).

                          Yes, I fully agree. My fear was using “ChatGPT”. I’ve not researched it, but that name is probably trademarked, that’s why it will not be on the “final” version.

                          I also moved some text, including “GPT”, to localizable variables. I can already envision someone (that will not be named) transforming it into a very long explanation of what an AI is…

                          I’m attaching the current version of the script, so you can retouch the localization file, if you want to- I added some entries, all (I hope) are inside localizable variables. I moved (and changed a bit) the title of GPT’s save file window to one of those variables- I think that it was the only text I edited (for clarity, I never know what to expect users may think, even when looking at a simple “save as…” window).

                          EDIT:
                          Changes to this file:
                          – Every searched file result displays modification date and time and approximated size (not just files searched inside the home folder)
                          – Fixed the GPT window title and initial text; Edited GTP’s “save result…” window title – removed any mention to ChatGPT, just to be on the safe side… I have no idea for how long tgpt will work. If it’s ever placed off line, I don’t have a backup plan, so that feature will be dropped from the script…

                          • This reply was modified 3 months, 1 week ago by PPC.
                          Attachments:
                          #124322
                          Member
                          Wallon

                            Cher PPC,

                            Personally, I would also avoid using the name ChatGPT.
                            I consulted the documentation on Wikipedia and on various French sites to find out what GPT is called in French. It doesn’t exist! Everyone uses the name in English. I think it’s the same as the word “Web”. Nobody translates the word “Web” into French any more.

                            In my tests, I forgot to mention that if you write a little sentence to save the search, you can’t put spaces between the words in the file name. So you have to write something like: “save_my_search.txt”.
                            I don’t know how to warn the user of this restriction.

                            I haven’t yet tested your latest version finderRC1.tar.

                            Kind regards,
                            Wallon

                            #124325
                            Member
                            PPC

                              you can’t put spaces between the words in the file name

                              Thanks for noticing that detail. Users should always avoid using spaces in file/folder names (and also special characters), but I’ll fix that: line 462 should have the variable $file inside double quotes, like this:
                              cp /tmp/gpt_response.txt "$file"

                              I’m just too tired of this script, I keep missing basic details, like quoting variables…

                              P.

                              #124362
                              Member
                              PPC

                                OK, folks, another tiny batch of improvements:

                                -Now tgpt’s install process does not produce errors when Finder is run from the terminal (yes, I do know about the errors on the part of the script that always tries to close a previous existing window, even when none is found – I won’t tackle that- the script works fine as is, and it’s not really mean to be run from the terminal (if anyone as a problem with that, deal with it, the world is not perfect, and I’m not a professional programmer)
                                -In the window that asks user confirmation before trying to install tgpt, if user refuses to install, the script exits as it should (sorry I forgot to process the cancel button)
                                -In tgpt save window, file names *should not* include spaces, but now *can* include spaces.

                                By the way, the first improvement that I list here? I just adapted the answer GPT gave me. It did not “find” the solution I was looking for, but pointed me to the right way.

                                As you can see, only the “GTP” part of the script was changed, nothing more.

                                P.

                                Attachments:
                                #124381
                                Member
                                sybok

                                  Hi, @PPC, did not read the whole thread and I have some rather general comments to the RC2 (but most of them may apply to any other scripts any of the developers kindly provide us with):
                                  1) I sometimes find it useful to run:
                                  find .... 2>/dev/null
                                  when *normal user* searching across the whole system to avoid error messages such as “find: ‘/var/lib/polkit-1’: Permission denied” being printed to the output.
                                  This could potentially be an issue in case of a multi-user system and the command ‘find /media’ (line 106).
                                  The other instances of ‘find’ command seemed OK to me.

                                  2) Temporary output file(s) – please store in variables:
                                  Please do define a variable to store the ‘/tmp/resultado.txt’ (‘/tmp/list.txt’, ‘/tmp/list-sorted.txt’ etc.) and use the variable.
                                  This could increase typo-robustness (e.g. ‘/tmp/resultando.txt’ of the code (even though BASH may not worry about an undeclared variable…)
                                  the_results='/tmp/resultado.txt'

                                  3) Robustness against multiple concurrent runs:
                                  Also, in case of a multi-user system (e.g. server and several users connected via SSH and running the code at the same time) both running ‘finder’, one may wish to add a temporary string-prefix|suffix to distinguish the output of different runs.
                                  This would imply another generalisation to

                                  fix_unique="$$" # PID of this script
                                  #fix_unique="$(whoami)" # User-name, it could suffice unless the same user calls the script twice!
                                  #fix_unique="$(tr -dc 'A-Za-z0-9' </dev/random | head -c 13; echo)" # Random alpha-numeric string
                                  the_results="/tmp/${fix_unique}_resultado.txt"

                                  The random string is a (tested) copy-paste from https://stackoverflow.com/questions/2493642/how-can-a-linux-unix-bash-script-get-its-own-pid#2493661

                                  This multi-run robustness is another case for using dedicated variables to store (auxiliary) output file-names.

                                  Personally, I do not bother with it (multi-run robustness) in my own scripts for my own use.
                                  Still, I would prefer a system-wide script to be on the safe(r) side.
                                  (This might bite me back when|if I contribute something that is accepted and I forget about my own suggestion…)

                                  4) Readability, syntactic sugar-coating:
                                  Please, fix your indentation and unify to use either space (disclaimer: my preferred choice) or tab.
                                  This would make the code much more readable IMHO.

                                  5) You and other developers are kindly encouraged to use a linter such as ‘shellcheck’.
                                  I found that it does often provide useful hints even though its suggestions to (safer) double quote may sometimes breaking the code (when iterating over the to-be-quoted or passing as multiple arguments where splitting into words is desirable).

                                  EDIT: In retrospect, I see that I had opportunity to come up with the item 3) in the past. Sadly, it did not cross my mind to consider it to be an issue at that time… Better late than never.

                                  • This reply was modified 3 months, 1 week ago by sybok.
                                Viewing 15 posts - 121 through 135 (of 176 total)
                                • You must be logged in to reply to this topic.