lipido / kargos

KDE Plasma port of GNOME Argos and OSX BitBar
GNU General Public License v3.0
126 stars 13 forks source link

"refresh" should run after "bash" if both attributes are set for an item #16

Closed kennethso168 closed 6 years ago

kennethso168 commented 6 years ago

Per bitbar API:

refresh=.. to make the item refresh the plugin it belongs to. If the item runs a script, refresh is performed after the script finishes. eg. refresh=true

This make sense for some use cases like a Trello todo list. When a "done" submenu item is clicked, it runs a script that make an HTTP PUT request to move the item to a designated list for done items, then the whole widget refreshes to remove the done item.

However, I think such behaviour is currently not possible for kargos, either for the "IconifiableButton" (the button you get without onclick defined) or for direct clicking of the item when onclick=bash. I have looked at the source code (sorry not familiar with qml), and it seems that the "IconifiableButton" does not honor any refresh attribute. And for the case when onclick is defined, the widget is updated before running bash

It would be nice if you could implement such behaviour. Thanks a lot!

Edit: after testing it seems that refresh works when onclick=bash. Therefore this problem only applies to the "IconifiableButton".

lipido commented 6 years ago

I have added this feature in e1877cfbe5d221a66e0649d7e923d36dff04db1c Could you try it?

kennethso168 commented 6 years ago

Thanks. Currently a little bit busy so I'll try out at maybe this weekend

kennethso168 commented 6 years ago

Tried and tested with the following script and it works as expected:

test_kargos_refresh.30m.sh:

#!/bin/bash
echo "Refreshed at: $(date +%H:%M:%S:%N)"
echo "---"
echo 'Click | refresh=true bash='\''notify-send "Time is $(date +%H:%M:%S:%N)"; sleep 5'\'

Result: a notification appears (take note of the time), and the text on panel should refresh around 5 seconds later.

So this is fixed and I'll close the issue. Thanks a lot for your great work.

Btw, are you interested in implementing greater compatibility with the bitbar standard? (specifically, my biggest wish would be the templateImage=.., since currently there is no way to show a custom image on the panel in kargos). If so I'll open more issues here.