I didn't know about the shell=true option. So that would allow me to use my
original version as using notify-send or dunstify allows me to display
without the title whereas the python way always seems to need the title
line be it empty or not so creating a larger notification.

On Mon, 29 Mar 2021, 11:39 Guillaume Gelin, <[email protected]> wrote:

> or you could have probably used qtile.cmd_spawn('...', shell=True)
>
> :)
>
> Le dim. 28 mars 2021 à 22:49, elParaguayo <[email protected]> a
> écrit :
>
>> Great - and sorry, looks like I pasted some bits of the code twice in
>> that email!
>>
>> On Sunday, 28 March 2021 at 21:47:20 UTC+1 [email protected] wrote:
>>
>>> Thank you that was exactly what I was looking for and worked a treat. ;)
>>>
>>> On Sunday, 28 March 2021 at 21:35:29 UTC+1 elParaguayo wrote:
>>>
>>>> OK so a couple of things here:
>>>>
>>>> 1) That $(cat...) syntax is really shell syntax so I don't think works
>>>> in python. Even if it could, I'd recommend writing this in a more pythonic
>>>> (sorry, hate that word) way.
>>>> 2) You don't need notify-send as qtile has a notification utility
>>>>
>>>> So... this is untested but hopefully will get you on your way:
>>>>
>>>> from libqtile.utils import send_notification
>>>>
>>>>
>>>> def right_clicked():
>>>>     # Read your file and store contents in a variable
>>>>     with open("/tmp/network.tmp", "r") as tmpfile:
>>>>         tmp = tmpfile.read()
>>>>
>>>>     # Send the notification - you could replace this with subprocess
>>>> calling "notify-send" if you'd prefer!
>>>>     send_notification("Title here", tmp)from libqtile.utils import
>>>> send_notification
>>>>
>>>>
>>>> def right_click():
>>>>     with open("/tmp/network.tmp", "r") as tmpfile:
>>>>         tmp = tmpfile.read()
>>>>     send_notification("Title here", tmp)
>>>>
>>>>
>>>> Your mouse_callback could then just be "Button3": right_clicked
>>>>
>>>>
>>>> Probably lots of bugs here but that's how I'd look to do it.
>>>>
>>>> On Sunday, 28 March 2021 at 21:16:58 UTC+1 Justine Smithies wrote:
>>>>
>>>>> I've created a widget which works fine but now I'm adding mouse
>>>>> callbacks. Button1 works as expected for testing but button3 is driving me
>>>>> made as that notify line works from the command line but in qtile it
>>>>> literally echoes "$(cat /tmp/network.tmp)" via notify-send instead of the
>>>>> output that i get doing the same in a terminal like below.
>>>>>
>>>>> notify-send "$(cat /tmp/network.tmp)"'
>>>>>
>>>>> The line in my config is
>>>>>
>>>>> widget.GenPollText(update_interval=1, **widget_defaults, func=lambda:
>>>>> subprocess.check_output(os.path.expanduser("~/.local/bin/network.sh")).decode(),
>>>>> mouse_callbacks = {'Button1': lambda: qtile.cmd_spawn("dunstify 'Left'"),
>>>>> 'Button3': lambda: qtile.cmd_spawn('notify-send "$(cat
>>>>> /tmp/network.tmp)"')}),
>>>>>
>>>>> Someone please help i'm pulling my hair out lol
>>>>>
>>>> --
>> 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/6f320554-f189-47a7-827c-c5c1035440a3n%40googlegroups.com
>> <https://groups.google.com/d/msgid/qtile-dev/6f320554-f189-47a7-827c-c5c1035440a3n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> --
> Guillaume Gelin
>
> --
> 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/CAPn4x%2BpGUL0%3De0aVvchKBh6AbCE-HBni__5WeuTcMYFjRsdFtA%40mail.gmail.com
> <https://groups.google.com/d/msgid/qtile-dev/CAPn4x%2BpGUL0%3De0aVvchKBh6AbCE-HBni__5WeuTcMYFjRsdFtA%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/CADrRWNZJWNXGDmnCq20uSZ_Or1Np6_-5txVO2VhMNTvyFcH2gg%40mail.gmail.com.

Reply via email to