I played around with the widget a bit, and the following seems to work fine:

(replaces a line of code in the __init__-method)

        if self.execute:
            def prepare():
                def worker():
                    try:
                        check_call(self.execute, shell=True)
                    except:  # noqa: E722
                        logger.exception("Problem running update script: 
%s", self.execute)
                    self.qtile.call_soon_threadsafe(self.tick)
                threading.Thread(target=worker).start()
            self.add_callbacks({'Button1': prepare})

The try/except can possibly be skipped, since it wasn't there before.

On Saturday, 7 November 2020 at 14:26:29 UTC+1 tcld wrote:

> And you're certain that's not caused by your changes? If not, how about 
> you open a PR?
> (When doing certain things in the main thread, it freezes up. It's pretty 
> easy to get there.)
>
> On Saturday, 7 November 2020 at 14:19:36 UTC+1 elParaguayo wrote:
>
>> Thanks. I guess there's something wrong with my setup then as that 
>> doesn't work for me. Process is still spawning in the background.
>>
>> The system also gets stuck when the update check is being run (hadn't 
>> noticed the default 60 second interval).
>>
>> On Sat, 7 Nov 2020 at 12:59, tcld <[email protected]> wrote:
>>
>>> I'm doing this:
>>>
>>>         widget.CheckUpdates(distro='Arch_checkupdates', 
>>> display_format='Updates: {updates}',
>>>                             execute='alacritty --title "updates" 
>>> --command ' + home + '/.config/qtile/do_update.sh',
>>>                             update_interval=900),
>>> With the script being called containg this code:
>>>
>>> #!/bin/sh
>>> echo "Installing updates..."
>>> sudo pacman -Syyu
>>> read -n 1 -p "Press any key to quit..."
>>>
>>> I'll give the widget code another look, since it might teach me 
>>> something about threads in Python. :)
>>>
>>> On Saturday, 7 November 2020 at 12:42:22 UTC+1 elParaguayo wrote:
>>>
>>>> I'm drawing a complete blank here as I can't get the widget to spawn 
>>>> the update process in a visible terminal. I've tried using kitty as per 
>>>> Justine's original post to see if the issue was with me using alacritty 
>>>> but 
>>>> that's not working either.
>>>>
>>>> The process spawns in the background and makes qtile unresponsive. I 
>>>> have to switch to a different TTY to kill the process to unlock qtile.
>>>>
>>>> I'd be *fairly *optimistic that the changes I've made would work but 
>>>> it's impossible for me to test.
>>>>
>>>> On Sat, 7 Nov 2020 at 10:16, elParaguayo <[email protected]> wrote:
>>>>
>>>>> May have been over-confident!
>>>>>
>>>>> I've cloned it but I can't actually get the widget to create a 
>>>>> terminal to run the update command. The window doesn't display so it's 
>>>>> just 
>>>>> trying to run in the background (my execute command calls alacritty and 
>>>>> the 
>>>>> update command).
>>>>>
>>>>> Need to understand what the issue here is before I can test.
>>>>>
>>>>> On Saturday, 7 November 2020 at 10:01:04 UTC tcld wrote:
>>>>>
>>>>>> Then please go for it. :)
>>>>>>
>>>>>> On Saturday, 7 November 2020 at 10:57:56 UTC+1 elParaguayo wrote:
>>>>>>
>>>>>>> It's a pretty simple edit to the code, I think. I don't currently 
>>>>>>> have the repository cloned because I'm running the version from the 
>>>>>>> Arch 
>>>>>>> repos but I'm happy to clone and make a pull request for this. 
>>>>>>>
>>>>>>> I'll need to run against the 0.16.1 tag rather than the latest 
>>>>>>> commit but assume that's ok.
>>>>>>>
>>>>>>> On Sat, 7 Nov 2020 at 09:04, tcld <[email protected]> wrote:
>>>>>>>
>>>>>>>> I have come across this as well. At the moment the widget updates 
>>>>>>>> in predefined intervals. So if you wait a "little" (mine updates every 
>>>>>>>> 15 
>>>>>>>> minutes), the display will be changed accordingly.
>>>>>>>>
>>>>>>>> I'll have a look at the code, maybe the update can be triggered 
>>>>>>>> after the "execute"-command is finished.
>>>>>>>>
>>>>>>>> On Thursday, 5 November 2020 at 22:47:53 UTC+1 Justine Smithies 
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> Thanks for your reply. A code modification was what I was thinking 
>>>>>>>>> but wondered if I could avoid that. Possibly not though.
>>>>>>>>>
>>>>>>>>> On Thu, 5 Nov 2020, 21:36 el Paraguayo, <[email protected]> 
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>> Looking at the code, the button press just runs the "execute" 
>>>>>>>>>> command but doesn't trigger a refresh of the widget (see: 
>>>>>>>>>> https://github.com/qtile/qtile/blob/master/libqtile/widget/check_updates.py#L71
>>>>>>>>>> ).
>>>>>>>>>>
>>>>>>>>>> You could either modify the code in the widget to trigger a 
>>>>>>>>>> refresh or write a shell script that runs your update command and 
>>>>>>>>>> then 
>>>>>>>>>> refreshes the widget, and use that shell script in your "execute" 
>>>>>>>>>> field.
>>>>>>>>>>
>>>>>>>>>> However, I'm not sure how you can trigger the refresh from a 
>>>>>>>>>> shell script but it feels like it should be possible! 
>>>>>>>>>>
>>>>>>>>>> On Thu, 5 Nov 2020 at 11:08, Justine Smithies <
>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>
>>>>>>>>>>> Wondering if anyone has an issue with widget.CheckUpdates. I'm 
>>>>>>>>>>> using Arch with yay and have that set in the distro field and in 
>>>>>>>>>>> the custom 
>>>>>>>>>>> command I have checkuodates+aur which runs fine and shows updates. 
>>>>>>>>>>> I have 
>>>>>>>>>>> kitty -e yay -Syu in the execute field so when I click on the 
>>>>>>>>>>> updates bar 
>>>>>>>>>>> when there are some showing it opens the terminal and updates. The 
>>>>>>>>>>> issue I 
>>>>>>>>>>> have is that after this when the terminal window closes it still 
>>>>>>>>>>> says the 
>>>>>>>>>>> updates are available when I think it should re run the 
>>>>>>>>>>> widget.CheckUpdates 
>>>>>>>>>>> so it sees none are now available and clears the update widget.
>>>>>>>>>>>
>>>>>>>>>>> PS I'm loving Qtile and learning a new language at the same time 
>>>>>>>>>>> after spending a long time jumping from KDE to xfce and back.
>>>>>>>>>>>
>>>>>>>>>>> Justine
>>>>>>>>>>>
>>>>>>>>>>> -- 
>>>>>>>>>>> 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/CADrRWNY2O0NyYDo%2BkNy8%2BR6tYeBm%3DumcxUWbJ_wHdhC4G%2BtXpA%40mail.gmail.com
>>>>>>>>>>>  
>>>>>>>>>>> <https://groups.google.com/d/msgid/qtile-dev/CADrRWNY2O0NyYDo%2BkNy8%2BR6tYeBm%3DumcxUWbJ_wHdhC4G%2BtXpA%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/CADPQLhDBoSnp2bXdoONex6SHkBXWxLnhqkOUmUJVDYuSgXpy_A%40mail.gmail.com
>>>>>>>>>>  
>>>>>>>>>> <https://groups.google.com/d/msgid/qtile-dev/CADPQLhDBoSnp2bXdoONex6SHkBXWxLnhqkOUmUJVDYuSgXpy_A%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/3fbe80ec-4fbe-482c-a0d2-048ebada2d65n%40googlegroups.com
>>>>>>>>  
>>>>>>>> <https://groups.google.com/d/msgid/qtile-dev/3fbe80ec-4fbe-482c-a0d2-048ebada2d65n%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/b6561e53-ea24-4cfa-b680-e184b52dff3bn%40googlegroups.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/qtile-dev/b6561e53-ea24-4cfa-b680-e184b52dff3bn%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/184a81c3-2977-4cf6-a060-94ae90b8880en%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/qtile-dev/184a81c3-2977-4cf6-a060-94ae90b8880en%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/86a88e75-6fc3-4a62-a5fc-df52394a2fe4n%40googlegroups.com.

Reply via email to