deragon / autopoweroff

Manage automatic poweroff and other actions (suspend / custom) when specific conditions are reunited.
GNU General Public License v2.0
52 stars 7 forks source link

Retire gksu / Polkitd integration #1

Closed Gaff closed 5 years ago

Gaff commented 6 years ago

Hi,

Do you have any plans to move off gksu and onto polkit? Turns out the latest Ubuntu doesn't even have gksu any more. See: https://answers.launchpad.net/ubuntu/+source/gksu/+question/669978

Thanks!

deragon commented 6 years ago

I should... if only time would permit it. I need to learn everything from scratch regarding Polkit.

That said, gksu 2.0.2-9ubuntu1 is still available on Ubuntu 18.04 LTS Bionic Beaver; I have it on my laptop.

edgimar commented 5 years ago

There isn't so much to learn:

When configuring the package(e.g. in the postinst script), test whether the gksu executable exists. If it does exist, then nothing should change from how you currently have it. If gksu doesn't exist, however, then two additional steps are needed:

  1. replace gksu with pkexec in /usr/bin/autopoweroff
  2. add a /usr/share/polkit-1/actions/com.github.deragon.autopoweroff.policy file, which contains the following:

    
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE policyconfig PUBLIC
    "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
    "http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
    <policyconfig>
    
    <action id="org.freedesktop.policykit.pkexec.run-autopoweroff">
    <description>Run Autopoweroff GUI</description>
    <message>Authentication is required to run autopoweroff-gui</message>
    <defaults>
      <allow_any>no</allow_any>
      <allow_inactive>no</allow_inactive>
      <allow_active>auth_admin_keep</allow_active>
    </defaults>
    <annotate key="org.freedesktop.policykit.exec.path">/usr/sbin/autopoweroff-gui</annotate>
    <annotate key="org.freedesktop.policykit.exec.allow_gui">TRUE</annotate>
    </action>


You will probably also want to make sure that the postrm script cleans up this policy file if it exists.
ithinkmatt commented 5 years ago

That explains it. Can't use on Ubuntu 18.10. Too bad the GKSU package isn't supported or available at all to install. :(

deragon commented 5 years ago

Fixed. Could you please try out the following deb package?

https://toile.deragon.biz/autopoweroff-3.1.0-1.noarch.deb

thomasvjohansen commented 5 years ago

just tried it on latest Elementary OS 5.0, it installs fine and when running it prompt for admin rights, after that it does'nt open.

deragon commented 5 years ago

@thomasvjohansen , I cannot help you. Under Ubuntu 18.04, the package works fine for me. Can you check the logs under /var/log to see if any error shows up when you start the GUI, after you enter your password? I need clues to what is going on on the Elementary OS.

thomasvjohansen commented 5 years ago

@deragon, my fault... elementary OS doesnt use gnome, apparently, its using Pantheon....

the error is: "Sorry, but this application requires Gnome 3.0 resources that are not installed on this machine. Following is the specific error

  No module named gi"
deragon commented 5 years ago

@thomasvjohansen , you are suffering from issue #2. The package I provided for this issue does not contain the fix for the second issue. Once I have confirmation that this issue has been fixed, I will merge with issue #2 and officially release a new version of Autopoweroff. So please confirm that all is working fine now after installing:

sudo apt install python-gi

It should not download that much; you must have most Gnome libraries already installed since so many applications are Gnome based.

deragon commented 5 years ago

So, anybody can report if the problem is fixed? Independent testing would be nice to have. I could then release a new official version of Autopoweroff once I get confirmation of any one of you that subscribed to this issue.

edgimar commented 5 years ago

It installs fine for me on Ubuntu 18.04, if that helps.

deragon commented 5 years ago

@edgimar, I am about to release a new version of Autopoweroff and I would like to give you credit since you provided the solution for me. Please tell me how do you want credit be attributed to you. You can provide me your name and email if you desire, here or by writing to me at hans@deragon.biz.

baoanhng commented 5 years ago

Thank you. I also ran into a problem which it could not installed on Kubuntu as there is no gksu but kdesu.

The 3.1.0 package works.

joemarchese commented 5 years ago

Fixed. Could you please try out the following deb package?

https://toile.deragon.biz/autopoweroff-3.1.0-1.noarch.deb

Fixed the issue for me. Thank you.

mikerm19 commented 5 years ago

I was able to install the 3.1.0 version on a brand new lubuntu install, so your change seems to have worked. Thank you for the program!

deragon commented 5 years ago

This issue is fix in release 3.1.0.