Python can handle the "~" if subprocess is called with "shell=True".

It would be easier for users if they didn't have to include the expanduser
so I wonder if we could change spawn to use shell=True.

I can look at this later but have a list of things I'm working on.


On Wed, 9 Jun 2021, 08:17 shulem magus, <[email protected]> wrote:

> Nice, glad it helped. I don't think Python recognises the ~ the same way
> as the shell does. I guess os.path.expanduser is used in place of the ~ in
> Python. I agree, it is rather unintuitive. I just looked it up now.
>
> On Wed, 9 Jun, 2021, 12:35 Aditya Manga, <[email protected]> wrote:
>
>> !! It worked! Thank you so much! Thats a weird error that kinda
>> intuitvely makes sense actually even though I don't technically understand
>> why. (I'm presuming the use of "~" is custom to the user and hence it
>> doesn't recognize it through the qtile config running it as a 'non-user').
>>
>> Thank you so much though!
>>
>> On Wednesday, June 9, 2021 at 3:01:44 PM UTC+8 [email protected] wrote:
>>
>>> Could you try mentioning the full path in the key binding? Instead of
>>> using ~/. config/rofi/scripts/appsmenu.sh, use
>>> /home/adi/.config/rofi/scripts/appsmenu.sh.
>>>
>>> On Wed, 9 Jun, 2021, 06:52 Aditya Manga, <[email protected]> wrote:
>>>
>>>> Hey Magus - sorry for the delay. I've attached both the rofi script and
>>>> the log below. I did try chmodding and the script does indeed work through
>>>> the terminal - furthermore if I replace the script path with a regular rofi
>>>> command it works perfectly fine.
>>>>
>>>> I also tried using a simple .sh file (not attached) that simply
>>>> contained the script as follows:
>>>>
>>>> #!/bin/sh
>>>>
>>>> <rofi command>
>>>>
>>>> which also *didn't* work when ran through qtile, *did* work when ran
>>>> through the command line, and the solo <rofi command> also *worked*
>>>> when ran through both qtile (by just replacing the sh command with the
>>>> regular command) and the command line.
>>>> On Tuesday, June 8, 2021 at 5:09:55 PM UTC+8 [email protected] wrote:
>>>>
>>>>> It'd be great if you could post the contents of the log and the rofi
>>>>> script. Also, is the file executable? (Did you chmod 755 the file?) And if
>>>>> so does it work directly from the terminal? like sh ~/location of
>>>>> script/script.sh?
>>>>>
>>>>>
>>>>> On Tue, 8 Jun, 2021, 14:25 Aditya Manga, <[email protected]> wrote:
>>>>>
>>>>>> Thanks for the messages,
>>>>>>
>>>>>> Magus - I checked the cat logs and there are a bunch of errors though
>>>>>> I can't really make sense of them relating to the script/command. The
>>>>>> script is a rofi script that opens a rofi window. I can attach my full 
>>>>>> log
>>>>>> and send it to the thread if it would help, however I've added an excerpt
>>>>>> of the errors I get upon restarting qtile (there are no changes to the 
>>>>>> log
>>>>>> file after running the keybind).
>>>>>>
>>>>>> And ah Justine I looked through your config - thank you. Would the
>>>>>>
>>>>>> qtile.cmd_spawn(os.path.expanduser("~/path/to/file.sh")
>>>>>>
>>>>>> code work even in keybinds to execute a bash script?
>>>>>>
>>>>>> On Tuesday, June 8, 2021 at 4:47:05 PM UTC+8 Justine Smithies wrote:
>>>>>>
>>>>>>> Take a look at my config here as it should help.
>>>>>>>
>>>>>>> https://github.com/justinesmithies/dotfiles
>>>>>>>
>>>>>>> On Tue, 8 Jun 2021, 08:58 Aditya Manga, <[email protected]> wrote:
>>>>>>>
>>>>>>>> Hi, I understand this might be a slightly newbie question however
>>>>>>>> I'm at a loss for what to try after several attempts.
>>>>>>>>
>>>>>>>> I'm trying to run a .sh script through a mod + R keybind however I
>>>>>>>> can't seem to figure out how to make it work. My code is:
>>>>>>>>
>>>>>>>> Key([mod], "r",
>>>>>>>>     lazy.spawn("sh ~/.config/rofi/scripts/appsmenu.sh"),
>>>>>>>> desc="Spawn a command using a prompt widget"),
>>>>>>>>
>>>>>>>> This code allows qtile to restart however the keybinding doesn't
>>>>>>>> work - I've confirmed that the code does work within a terminal. I've 
>>>>>>>> also
>>>>>>>> tried using the shell command. Furthermore I tried using lazy.spawncmd
>>>>>>>> however in that case qtile simply didn't even restart.
>>>>>>>>
>>>>>>>> I'd appreciate any help in being able to run the .sh script through
>>>>>>>> the key binding as it's a method I plan to use a lot more in the 
>>>>>>>> future for
>>>>>>>> more complicated, longer scripts.
>>>>>>>>
>>>>>>>> --
>>>>>>>>
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>> Groups "qtile-dev" group.
>>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>>> send an email to [email protected].
>>>>>>>> To view this discussion on the web visit
>>>>>>>> https://groups.google.com/d/msgid/qtile-dev/01eccd4e-f473-4340-b634-eeadc655030dn%40googlegroups.com
>>>>>>>> <https://groups.google.com/d/msgid/qtile-dev/01eccd4e-f473-4340-b634-eeadc655030dn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>>> .
>>>>>>>>
>>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "qtile-dev" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> send an email to [email protected].
>>>>>>
>>>>> To view this discussion on the web visit
>>>>>> https://groups.google.com/d/msgid/qtile-dev/6f37d0ad-0be8-4399-9b6f-2c34dbcea94bn%40googlegroups.com
>>>>>> <https://groups.google.com/d/msgid/qtile-dev/6f37d0ad-0be8-4399-9b6f-2c34dbcea94bn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>>
>>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "qtile-dev" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>>
>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/qtile-dev/df5fe4db-55d0-4512-a3b0-e5c6b72776a6n%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/qtile-dev/df5fe4db-55d0-4512-a3b0-e5c6b72776a6n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
>> You received this message because you are subscribed to the Google Groups
>> "qtile-dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/qtile-dev/d52f7647-4fe2-4e2f-80ae-ff7ea405ba1cn%40googlegroups.com
>> <https://groups.google.com/d/msgid/qtile-dev/d52f7647-4fe2-4e2f-80ae-ff7ea405ba1cn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "qtile-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/qtile-dev/CALCidozAZTOr%3D4tiB8CFm4CiN4Kr1ryc2KYZcP8Xuw1dxfsEZQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/qtile-dev/CALCidozAZTOr%3D4tiB8CFm4CiN4Kr1ryc2KYZcP8Xuw1dxfsEZQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"qtile-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qtile-dev/CADPQLhAXQA7w-bBW%2BHbEWWju_6QF41XXnuP4nRPhKxk8hrYEkg%40mail.gmail.com.

Reply via email to