I-Dream-in-Code / kde-arch-update-plasmoid

30 stars 9 forks source link

Support for Yakuake #17

Closed naraesk closed 6 years ago

naraesk commented 6 years ago

This is a feature request. :-)

I have yakuake running all the time. Would be nice if the kde-arch-update-plasmoid would be able to fetch the running yakuake instance and execute the commands with this instance.

I-Dream-in-Code commented 6 years ago

There's no documentation for yakuake so I can't figure out yakuake scripting.

If you know yakuake scripting I'd be happy to merge your patch

naraesk commented 6 years ago

Thanks for your response. From my point of view, the easiest way is to use qdbus to interact with yakuake. The following shell script checks if yakuake is running, starts a new session and runs a predefined command:

RUNNING =`ps cax | grep yakuake`
if [ -z "$RUNNING" ]; then
    /usr/bin/yakuake & > /dev/null 
    sleep 3 
fi

SESSION=$(qdbus-qt5 org.kde.yakuake /yakuake/sessions org.kde.yakuake.addSession)
qdbus-qt5 org.kde.yakuake /yakuake/tabs setTabTitle $SESSION "update"
qdbus-qt5 org.kde.yakuake /yakuake/sessions runCommandInTerminal $SESSION "sudo pacman -Syu"

I know, that's not really a patch. But that should be all you need, shouldn't it? You just have to run the script. Might be a bit more beautiful using C++ with QProcess and QtDbus modules, but it will work.

I-Dream-in-Code commented 6 years ago

The command I use for upgrade in both konsole and aur is

'sh -c "sudo pacman -Syu ; echo Update Finished'"

can yakuake support chain commands?

naraesk commented 6 years ago

Sure, no problem. Yakuake is based on KonsolePart and should support everything Konsole supports.

I-Dream-in-Code commented 6 years ago

I'll look into it.

I-Dream-in-Code commented 6 years ago

So I don't understand dbus well enough to implement this myself.

HOWEVER I did make a yakuake branch that has all the rest of the plasmoid logic filled in minus implenting the qdbus calls so you can submit the patch

it's in worker.cpp lines 365 and 390

naraesk commented 6 years ago

Thanks, I'll have a look at it on the weekend

I-Dream-in-Code commented 6 years ago

thanks for coding it

bc5c5781d1ab6ff01451ca227da3aac594897be0 is the master merge

I-Dream-in-Code commented 6 years ago

@naraesk when I run either command it parses it correctly but when yakuake runs it asks for sudo password then immediately quits and runs update finished

It passes over the sudo prompt and doesn't wait for a password.

Is this a configuration on my end? or do I need to change the code?

naraesk commented 6 years ago

Sorry, it's my bad. I configured my system a while ago so to use pacman without asking for a password, that's why it was working for me. But i can fix it

I-Dream-in-Code commented 6 years ago

@naraesk

0303868d2e1fc12f08c256f30ae19e8c3e8cd0ff fixed the intialization and plugged the memory leak resulting in it

you need to fix the actual call so it waits to accept sudo password

naraesk commented 6 years ago

If yakuake is already running, your changes lead to an infinite loop since this -> yakuakeProcess will always be NULL.

I-Dream-in-Code commented 6 years ago

You're right.

I fixed it but I still feel like there's a memory leak maybe?

If someone quits yakuake when it's started from the plasmoid then the Qprocess yakuakeProcess pointer isn't freed the process is just destroyed and you make new again.

I can check if PID<=0 to free it

I-Dream-in-Code commented 6 years ago

so I realized there's deleteLater() function that cleans up the memory for me

anyways the infinite loop is fixed now along with the memory leak

I-Dream-in-Code commented 6 years ago

@naraesk I just need you to fix the actual asking for sudo password issue now

I-Dream-in-Code commented 6 years ago

My only guess (though I can't figure out the commands even with intensive websearching) is that when it runs the window isn't visible and so it's ignoring the password prompt.

So if the window was visible then maybe it'd work?

ghost commented 6 years ago

After recent updates clicking on "Update System" does nothing on my machine. Downgrading to 3.5.4-1 fixes this. Can we revert all latest changes instead of commenting them out?

I-Dream-in-Code commented 6 years ago

@fancytenseletters i reverted it and added pkgver() function with tags

I-Dream-in-Code commented 6 years ago

@naraesk I merged with master thanks for fixing it @fancytenseletters I reverted but then fixed yakuake

AUR package and master are both updated

ghost commented 6 years ago

@I-Dream-in-Code it still doesn't work for me. "Update system" doesn't execute any command. Also there is no yakuake in options (have it installed but don't want to use it anyway).

Tried disabling/enabling aur, konsole output, version number but nothing helps.

I-Dream-in-Code commented 6 years ago

@fancytenseletters sorry that merge failed

it's updated now

ghost commented 6 years ago

It works now! Thx.