Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Same command works from terminal but doesn't when automated #821

Open
DeutscheGabanna opened this issue Oct 30, 2023 · 4 comments
Open

Same command works from terminal but doesn't when automated #821

DeutscheGabanna opened this issue Oct 30, 2023 · 4 comments

Comments

@DeutscheGabanna
Copy link

DeutscheGabanna commented Oct 30, 2023

Let's say I open up another terminal, for example - kgx - or even cool-retro-term. I want a new instance of cool-retro-term with a specific command, so I type in:

cool-retro-term -e /bin/bash -c 'source ~/.bashrc; filetags <some_files_comma_separated>'

For example:

cool-retro-term -e /bin/bash -c 'source ~/.bashrc; filetags "/home/deutschegabanna/local/documents/biel-incongruity-of-company-law-terms-mix -- article legal.html" "/home/deutschegabanna/local/documents/english-for-tax-professionals-reference-book-en -- finance legal book.txt" "/home/deutschegabanna/local/documents/semi-automatic-wild-cards-for-polish-inflections.txt"'

It works. Another window pops up with the correct output for tagging files:

Please enter tags, separated by " "; abort with Ctrl-C; complete 10 tags with TAB
                     
         .--------, 
        | o   ?   | 
         `--------' 
                     

  Top nine previously used tags in this directory:
    article (1) ⋅ book (2) ⋅ dictionary (3) ⋅ finance (4) ⋅ languages (5) ⋅ legal (6) ⋅ personal (7) ⋅ politics (8) ⋅ tech (9)

Tags: 

But now let's do exactly the same, but from Nautilus automated script. (I know what you want to reply - "It's a Nautilus issue" - please, let me explain in full).

My .sh script basically amounts to running the same command as above. Identical:

cool-retro-term -e /bin/bash -c 'source ~/.bashrc; filetags "/home/deutschegabanna/local/documents/biel-incongruity-of-company-law-terms-mix -- article legal.html" "/home/deutschegabanna/local/documents/english-for-tax-professionals-reference-book-en -- finance legal book.txt" "/home/deutschegabanna/local/documents/semi-automatic-wild-cards-for-polish-inflections.txt"'

How do I know this? By outputting the wanna-be-result into a file. The script:

#!/bin/bash

# Declare an array to store file paths
file_paths=()

# Split the selected file paths into an array
IFS=$'\n' read -d '' -ra file_paths <<< "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"

# Iterate through the array and format the paths
for file in "${file_paths[@]}"; do
    # Enclose each file path in quotation marks and append it to the array
    formatted_file="\"$file\""
    formatted_paths+=("$formatted_file")
done

# Join the array into a single string with space-separated items
formatted_paths="${formatted_paths[*]}"

# Open new instance of the terminal and run filetags <filepaths>
# THIS IS THE DEBUG LINE TO COMPARE FINAL COMMANDS
echo "cool-retro-term -e /bin/bash -c 'source ~/.bashrc; filetags $formatted_paths'" > try.txt
cool-retro-term -e /bin/bash -c 'source ~/.bashrc; filetags $formatted_paths'

And the moment of truth, let's compare try.txt to my manual command:

cool-retro-term -e /bin/bash -c 'source ~/.bashrc; filetags "/home/deutschegabanna/local/documents/biel-incongruity-of-company-law-terms-mix -- article legal.html" "/home/deutschegabanna/local/documents/english-for-tax-professionals-reference-book-en -- finance legal book.txt" "/home/deutschegabanna/local/documents/semi-automatic-wild-cards-for-polish-inflections.txt"'

They are the same!
And yet, if I launch my Nautilus script, the cool-retro-term opens... starts complaining about missing pip packages (as if the .bashrc environmental vars weren't properly loaded) and exits within milliseconds.

How do I fix this? I debugged this to my limit, trying for three days now.

@Sectonidse
Copy link

I have the same issue and want it fixed... I tried to execute cool-retro-term from standard terminal - works, from scripts (such as bash, Python scripts and even Cinnamon launchers and launching command through KDE Connect) - doesn't work.

@Sectonidse
Copy link

The interesting thing is, when trying to execute cool-retro-term with --verbose, it doesn't tell that there's errors, it only tells that qml is loading, then storing the settings.

@Sectonidse
Copy link

Sectonidse commented Jan 4, 2024

What i found out is that it keeps running if you append & sleep 5 into the command, but the window instantly closes when launched... I consider this a bug now.

@DeutscheGabanna
Copy link
Author

Yeah, I tried to get some attention in a similar thread here: #728 (comment) but to no avail @Sectonidse

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants